Package com.articulate.sigma
Class KBmanager
java.lang.Object
com.articulate.sigma.KBmanager
- All Implemented Interfaces:
Serializable
This is a class that manages a group of knowledge bases. It should only
have one instance, contained in its own static member variable.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreate a new empty KB with a name.voidGet the the complete list of languages available in all KBsstatic StringccheckResults(String kbName) static CCheckManager.CCheckStatusccheckStatus(String kbName) static voidCopies an XML configuration file to the File out location.static <T> Tdecoder()static voidstatic StringescapeFilename(String fname) Double the backslash in a filename so that it can be saved to a text file and read back properly.booleanReturns true if a KB with the given name exists.getError()Get the error string for file loading.Get the KB that has the given name.Get the Set of KB names in this manager.static KBmanagergetMgr()Get the one instance of KBmanager from its class variable.Get the preference corresponding to the given keybooleanbooleanCheck whether config file or any .kif constituent is newer than its corresponding TPTP/TFF/THF filebooleaninfFileOld(String lang) Check whether config file or any .kif constituent is newer than its corresponding TPTP/TFF/THF filevoidReads in the KBs and other parameters defined in the XML configuration file, or uses the default parameters.voidinitializeOnce(String configFileDir) Reads in the KBs and other parameters defined in the XML configuration file, or uses the default parameters.static CCheckManager.CCheckStatusinitiateCCheck(KB kb, String chosenEngine, String systemChosen, String location, String language, int timeout) booleanLoads the constituents of the KB from ~/.sigmakee/config.xmlvoidloadKBforInference(KB kb) static booleanLoad the most recently saved serialized version.static voidbooleanprefEquals(String key, String value) Safer than getPref().equals() since it can check for nullstatic voidvoidPrint all preferences to stdoutstatic voidCreate an server-based interface for Python to call the KB object.readConfiguration(String configDirPath) Reads an XML configuration file from the directory configDirPath, and tries to find a configuration file elsewhere if configDirPath is null.voidRemove the KB that has the given name.Remove a knowledge base.static voidsave serialized version.static booleanCheck whether sources are newer than serialized version.static booleanserializedOld(SimpleElement configuration) Check whether sources are newer than serialized version.voidsetConfiguration(SimpleElement configuration) Sets instance fields by reading the xml found in the configuration file.voidSet default attribute values if not in the configuration file.voidSet an error string for file loading.voidSet the preference to the given value.voidWrite the current configuration of the system.
-
Field Details
-
CONFIG_KEYS
Master key cache for the config -
FILE_KEYS
Master file key cache for the config -
CONFIG_FILE
- See Also:
-
KB_MANAGER_SER
- See Also:
-
prefOverride
-
initialized
public static boolean initialized -
initializing
public static boolean initializing -
debug
public static boolean debug -
prover
-
kbs
-
-
Constructor Details
-
KBmanager
public KBmanager()
-
-
Method Details
-
setError
Set an error string for file loading. -
getError
Get the error string for file loading. -
serializedExists
public static boolean serializedExists()Check whether sources are newer than serialized version. -
serializedOld
Check whether sources are newer than serialized version. -
infFileOld
Check whether config file or any .kif constituent is newer than its corresponding TPTP/TFF/THF file -
infBaseFileOldIgnoringUserAssertions
-
infFileOld
public boolean infFileOld()Check whether config file or any .kif constituent is newer than its corresponding TPTP/TFF/THF file -
loadSerialized
public static boolean loadSerialized()Load the most recently saved serialized version. -
encoder
-
decoder
public static <T> T decoder() -
serialize
public static void serialize()save serialized version. -
setDefaultAttributes
public void setDefaultAttributes()Set default attribute values if not in the configuration file. -
initiateCCheck
-
ccheckResults
-
ccheckStatus
-
loadKBforInference
-
loadKB
Loads the constituents of the KB from ~/.sigmakee/config.xml- Parameters:
kbName- the name of the KBconstituents- a list of constituents to load- Returns:
- true if the loading was successful
-
copyFile
Copies an XML configuration file to the File out location.- Parameters:
in- the file to copyout- the location to copy the in param to
-
readConfiguration
Reads an XML configuration file from the directory configDirPath, and tries to find a configuration file elsewhere if configDirPath is null. The method initializeOnce() sets the preferences based on the contents of the configuration file. This routine has the side effect of setting the variable called "configuration". It also creates the KBs directory and an empty configuration file if none exists. -
initializeOnce
public void initializeOnce()Reads in the KBs and other parameters defined in the XML configuration file, or uses the default parameters. Entry point for the web app (Prelude.jsp). -
initializeOnce
Reads in the KBs and other parameters defined in the XML configuration file, or uses the default parameters. If configFileDir is not null and a configuration file can be read from the directory, reinitialization is forced.- Parameters:
configFileDir- the directory where the config.xml resides, typically ~/.sigmakee/KBs
-
setConfiguration
Sets instance fields by reading the xml found in the configuration file.- Parameters:
configuration-
-
escapeFilename
Double the backslash in a filename so that it can be saved to a text file and read back properly. -
addKB
Create a new empty KB with a name.- Parameters:
name- - the name of the KB
-
addKB
-
removeKB
Remove a knowledge base.- Parameters:
name- - the name of the KB- Returns:
- indication of KB removal
-
writeConfiguration
Write the current configuration of the system. Call writeConfiguration() on each KB object to write its manifest.- Throws:
IOException
-
getKB
Get the KB that has the given name. -
existsKB
Returns true if a KB with the given name exists. -
remove
Remove the KB that has the given name. -
getMgr
Get the one instance of KBmanager from its class variable. -
getKBnames
Get the Set of KB names in this manager. -
allAvailableLanguages
Get the the complete list of languages available in all KBs -
printPrefs
public void printPrefs()Print all preferences to stdout -
getPref
Get the preference corresponding to the given key -
prefEquals
Safer than getPref().equals() since it can check for null -
setPref
Set the preference to the given value. -
pythonServer
public static void pythonServer()Create an server-based interface for Python to call the KB object. https://pypi.python.org from py4j.java_gateway import JavaGateway gateway = JavaGateway() # connect to the JVM sigma_app = gateway.entry_point # get the KB instance print(sigma_app.getTerms()) # call a method -
printHelp
public static void printHelp() -
main
-