org.opencyc.kif
Class KifFileLoader

java.lang.Object
  |
  +--org.opencyc.kif.CycBulkAssertions
        |
        +--org.opencyc.kif.KifFileLoader

public class KifFileLoader
extends CycBulkAssertions

Provides the behavior and attributes of OpenCyc KifFileLoader.

Assertions are read from a file load(File file) or added in via addOrder() The assertions may then be added to a OpenCyc server in the given setdefaultMt Most of the routines are based on StreamTokenizer with settings: commentChar(';'); quoteChar('"'); eolIsSignificant(false); Unless the public boolean load(StreamTokenizer st) is dirrectly called

Author:
Douglas R. Miles

Field Summary
protected  java.util.ArrayList cycAssertionsDefintional
           
protected  CycAssertionsFactory CycAssertionsFactory
          Cyc api support.
protected  java.util.ArrayList cycAssertionsOfRest
           
protected  java.util.ArrayList cycAssertionsPredicateDefs
           
protected  java.util.ArrayList cycAssertionsSecondaryConstantDefs
           
protected  java.util.ArrayList cycAssertionsSpecialCollectionDefs
           
protected  java.util.ArrayList cycKifFileLoaderDefs
           
protected  java.util.ArrayList cycUnOrderedAssertions
           
protected  boolean isAssertedDuringLoad
           
 boolean isOrderedLoad
           
 boolean isSuoKif
           
protected  java.util.ArrayList kifToCycLMap
           
static int verbosity
          Verbosity indicator 0 indicates quiet on a range of 0 ...
 
Fields inherited from class org.opencyc.kif.CycBulkAssertions
cycAccess, cycAssertionsForBaseKB, cycOrderedAssertions, defaultCyclist, defaultMt, defaultProject, isTestedClean
 
Constructor Summary
KifFileLoader(CycAssertionsFactory ca)
          Constructs a new KifFileLoader.
 
Method Summary
 void addCollection(CycConstant collection)
           
 void addFile(java.io.Writer feedbackMl, java.io.File file)
          Adds the File to KB in defaultMt.
 void addFile(java.io.Writer feedbackMl, java.io.File file, CycFort mt)
          Adds the File to KB into Mt.
 void addFile(java.io.Writer feedbackMl, java.io.File file, java.lang.String mt)
          Adds the File to KB into Mt.
 void addFileEachLine(java.io.Writer feedbackMl, java.io.File file, java.lang.String mt)
          Adds the File to KB into Mt.
 void addIsa(CycConstant term, java.lang.String type)
           
 void addKifCycLMap(java.lang.String kif, java.lang.String cycl)
           
 boolean addOrder(CycList sentence)
          Adds the sentence (CycList) to this AssertionCollection.
 boolean addOrderComment(CycList sentence)
          Adds the comment based sentence (CycList) to this AssertionCollection.
 boolean addOrderGenlMt(CycList sentence)
          Adds the MetaRelation based sentence (CycList) to this AssertionCollection.
 boolean addOrderGenls(CycList sentence)
          Adds the genls based sentence (CycList) to this AssertionCollection.
 boolean addOrderGround(CycList sentence)
          Adds the gaf based sentence (CycList) to this AssertionCollection.
 boolean addOrderIsa(CycList sentence)
          Adds the isa based sentence (CycList) to this AssertionCollection.
 boolean addOrderMetaRelation(java.lang.String cycPredicate, CycList sentence)
          Adds the MetaRelation based sentence (CycList) to this AssertionCollection.
 boolean addOrderNonFortPred(CycList sentence)
          Adds the gaf based sentence (CycList) to this AssertionCollection.
 boolean addOrderNonGround(CycList sentence)
          Adds the non gaf based sentence (CycList) to this AssertionCollection.
 void addPredicate(CycConstant predicate)
           
 boolean addSentence(java.lang.String sentence)
          Adds the sentence (String) to this AssertionCollection.
 void clearKifCycLMap()
           
static void concatArrayList(java.util.ArrayList holder, java.util.ArrayList list)
           
 void doLine(CycList sentence)
           
 boolean getGlobalFlag(java.lang.String flag)
           
 java.util.ArrayList getKifCycLMap()
           
 void load(java.io.File file)
          Adds the File to this AssertionCollection.
 void load(java.io.InputStream is)
          Adds the contents of the InputStream to this AssertionCollection.
 void load(java.io.Reader r)
          Adds the contents of the Reader to this AssertionCollection.
 void load(java.io.StreamTokenizer st)
          Adds the contents of the StreamTokenizer to this AssertionCollection.
 void makeStdSUOKIFMap()
           
 void orderAssertions()
          Adds the AssertionCollection to Mt
 void setGlobalFlag(java.lang.String flag)
           
 void setKifCycLMap(java.util.ArrayList kifmap)
           
 void unsetGlobalFlag(java.lang.String flag)
           
 
Methods inherited from class org.opencyc.kif.CycBulkAssertions
addSentence, commitAssertions, commitAssertions, cyclify, equals, getDefaultCyclist, getDefaultMt, getDefaultProject, resetAll, setDefaultCyclist, setDefaultCyclist, setDefaultMt, setDefaultMt, setDefaultProject, setDefaultProject, testAssertions, testAssertionsHtml, toString, writeAssertions, writeAssertions, writeAssertionsCycL, writeAssertionsCycL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verbosity

public static int verbosity
Verbosity indicator 0 indicates quiet on a range of 0 ... 10

CycAssertionsFactory

protected CycAssertionsFactory CycAssertionsFactory
Cyc api support.

cycAssertionsDefintional

protected java.util.ArrayList cycAssertionsDefintional

cycAssertionsPredicateDefs

protected java.util.ArrayList cycAssertionsPredicateDefs

cycKifFileLoaderDefs

protected java.util.ArrayList cycKifFileLoaderDefs

cycAssertionsSpecialCollectionDefs

protected java.util.ArrayList cycAssertionsSpecialCollectionDefs

cycAssertionsSecondaryConstantDefs

protected java.util.ArrayList cycAssertionsSecondaryConstantDefs

cycAssertionsOfRest

protected java.util.ArrayList cycAssertionsOfRest

kifToCycLMap

protected java.util.ArrayList kifToCycLMap

cycUnOrderedAssertions

protected java.util.ArrayList cycUnOrderedAssertions

isSuoKif

public boolean isSuoKif

isOrderedLoad

public boolean isOrderedLoad

isAssertedDuringLoad

protected boolean isAssertedDuringLoad
Constructor Detail

KifFileLoader

public KifFileLoader(CycAssertionsFactory ca)
              throws java.lang.Exception
Constructs a new KifFileLoader.
Parameters:
ca - the CycAssertionsFactory for this KifFileLoader
Method Detail

addFile

public void addFile(java.io.Writer feedbackMl,
                    java.io.File file)
             throws java.lang.Exception
Adds the File to KB in defaultMt.
Parameters:
file - for sentences for this KifFileLoader

addFile

public void addFile(java.io.Writer feedbackMl,
                    java.io.File file,
                    java.lang.String mt)
             throws java.lang.Exception
Adds the File to KB into Mt.
Parameters:
file - for sentences
mt - for sentences

addFile

public void addFile(java.io.Writer feedbackMl,
                    java.io.File file,
                    CycFort mt)
             throws java.lang.Exception
Adds the File to KB into Mt.
Parameters:
file - for sentences
mt - for sentences

addFileEachLine

public void addFileEachLine(java.io.Writer feedbackMl,
                            java.io.File file,
                            java.lang.String mt)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Adds the File to KB into Mt.
Parameters:
file - for sentences
mt - for sentences

doLine

public void doLine(CycList sentence)
            throws java.lang.Exception

setGlobalFlag

public void setGlobalFlag(java.lang.String flag)

unsetGlobalFlag

public void unsetGlobalFlag(java.lang.String flag)

getGlobalFlag

public boolean getGlobalFlag(java.lang.String flag)

load

public void load(java.io.File file)
          throws java.lang.Exception
Adds the File to this AssertionCollection.
Parameters:
file - to load sentences for this KifFileLoader

load

public void load(java.io.InputStream is)
          throws java.lang.Exception
Adds the contents of the InputStream to this AssertionCollection.
Parameters:
is - for InputStream of sentences for this KifFileLoader

load

public void load(java.io.Reader r)
          throws java.lang.Exception
Adds the contents of the Reader to this AssertionCollection.
Parameters:
r - for Reader of sentences for this KifFileLoader

load

public void load(java.io.StreamTokenizer st)
          throws java.lang.Exception
Adds the contents of the StreamTokenizer to this AssertionCollection. If loading a KIF file be sure first to: st.commentChar(';'); st.quoteChar('"'); st.eolIsSignificant(false);
Parameters:
st - for sentences for this KifFileLoader

getKifCycLMap

public java.util.ArrayList getKifCycLMap()

setKifCycLMap

public void setKifCycLMap(java.util.ArrayList kifmap)

clearKifCycLMap

public void clearKifCycLMap()

addKifCycLMap

public void addKifCycLMap(java.lang.String kif,
                          java.lang.String cycl)

makeStdSUOKIFMap

public void makeStdSUOKIFMap()

addSentence

public boolean addSentence(java.lang.String sentence)
                    throws java.lang.Exception
Adds the sentence (String) to this AssertionCollection.
Parameters:
String - of the sentence for this KifFileLoader

orderAssertions

public void orderAssertions()
Adds the AssertionCollection to Mt
Parameters:
mt - for sentences for this KifFileLoader [08:09] All microtheory definitions [08:09] isa and other definitional assertions) second. [08:10] All predicate definitions (isa, arity, argIsa, and other definitional assertions) third. [08:11] All collection definitions, in descending order of type, fourth. [08:11] e.g. ThirdOrderCollections, then SecondOrderCollections (CollectionTypes), then Collections which genls Individual. [08:11] All other constant definitions fifth [08:11] Then all other assertions -- the non-definitional ones. (and (isa ?GAF CycLClosedAtomicSentence) (operatorSentences ?PRED ?GAF) (isa ?PRED OpenCycDefinitionalPredicate))

addOrder

public boolean addOrder(CycList sentence)
                 throws java.lang.Exception
Adds the sentence (CycList) to this AssertionCollection.
Parameters:
(CycList) - of the sentence for this KifFileLoader

addOrderGenlMt

public boolean addOrderGenlMt(CycList sentence)
Adds the MetaRelation based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderMetaRelation

public boolean addOrderMetaRelation(java.lang.String cycPredicate,
                                    CycList sentence)
                             throws java.lang.Exception
Adds the MetaRelation based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderNonFortPred

public boolean addOrderNonFortPred(CycList sentence)
Adds the gaf based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderGround

public boolean addOrderGround(CycList sentence)
                       throws java.lang.Exception
Adds the gaf based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderNonGround

public boolean addOrderNonGround(CycList sentence)
                          throws java.lang.Exception
Adds the non gaf based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderComment

public boolean addOrderComment(CycList sentence)
                        throws java.lang.Exception
Adds the comment based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addOrderGenls

public boolean addOrderGenls(CycList sentence)
                      throws java.lang.Exception
Adds the genls based sentence (CycList) to this AssertionCollection.
Parameters:
sentence - (CycList) to be added to this KifFileLoader

addCollection

public void addCollection(CycConstant collection)
                   throws java.lang.Exception

addPredicate

public void addPredicate(CycConstant predicate)
                  throws java.lang.Exception

addIsa

public void addIsa(CycConstant term,
                   java.lang.String type)
            throws java.lang.Exception

addOrderIsa

public boolean addOrderIsa(CycList sentence)
                    throws java.lang.Exception
Adds the isa based sentence (CycList) to this AssertionCollection.
Parameters:
(CycList) - of the sentence for this KifFileLoader

concatArrayList

public static void concatArrayList(java.util.ArrayList holder,
                                   java.util.ArrayList list)