Package com.articulate.sigma
Class KButilities
java.lang.Object
com.articulate.sigma.KButilities
- All Implemented Interfaces:
EventListener,javax.servlet.ServletContextListener
@WebListener
public class KButilities
extends Object
implements javax.servlet.ServletContextListener
Contains utility methods for KBs
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanErrors found during processing formulasstatic final ExecutorServicestatic booleanWarnings found during processing formulasstatic final ThreadLocal<com.esotericsoftware.kryo.Kryo> A thread local pool for the Kryo serializerstatic final intstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidvoidcontextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) voidcontextInitialized(javax.servlet.ServletContextEvent servletContextEvent) countFormulaTypes(KB kb) Get count of all the different kinds of formulas as to their logical expressivitystatic voidcountProcesses(KB kb) static voidcountRelations(KB kb) static voidcountStringWords(KB kb) Count the number of words in all the strings in a knowledge basestatic StringeqNum2Text(int val) convert the numerical result of compare() to textstatic voidgenAllAlphaHTMLDoc(KB kb) Generate a HTML list of terms and their documentation strings from a file as upper and lowercase individual files so that each file isn't giganticstatic voidGenerate a textual list of all documentation strings and write to a file.static voidgenAllHTMLDoc(KB kb) Generate a HTML list of terms and their documentation strings from a file.static voidGenerate a textual list of terms and their documentation strings from a file.static StringgenerateAllNL(KB kb) Generate line pairs of formula and NL paraphrase of formulastatic StringFind all formulas in which the SUMO term is involved.static voidNote this simply assumes that initial lower case terms are relations.generateSemNetNeighbors(KB kb, boolean cached, boolean strings, boolean links, String term, int count) static voidstatic voidgenSpecificTermDoc(KB kb, String file, String lang) Generate a HTML list of terms and their documentation strings from a file.static voidgenSynLinks(String fname) Generate default synonymousExternalConcept statements for a .tsvgetAllFormulasOfTerm(KB kb, String term) Find all formulas in which the SUMO term is involved.static intstatic intgetCountTermFormats(KB kb, String lang) Get count of all the termFormat strings for the given languagestatic intgetCountUniqueTermFormats(KB kb, String lang) Get count of all the termFormat strings for unique SUMO terms for the given language.static StringgetDocumentation(KB kb, String term) static ExecutorServicestatic KButilitiesgetLabelsForTerm(KB kb, String term, String lang) Generate a HTML list of labels from termFormats TODO: Does this work? Only returning an empty ListgetLinkedTermsInDoc(KB kb, String term) static booleanhasCorrectTypes(KB kb, Formula f) Checks for consistent typing in the given formulastatic booleanFind all cases of where (instance A B) (instance B C) as well as all cases of where (instance A B) (instance B C) (instance C D).static booleanisAttribute(KB kb, String term) static booleanisCacheFile(String filename) static booleanstatic booleanisFunction(KB kb, String term) static booleanisInstance(KB kb, String term) static booleanisRelation(KB kb, String term) static booleanisValidFormula(KB kb, String form) Checks for overall validity of the given formulastatic booleanisVariableArity(KB kb, String term) static voidutility method to merge two HashMaps of String keys and a values of an HashSet of Strings.static voidForce a refresh of the ExecutorService - useful when switching contextssemnetAsJSON3(KB kb, boolean cached, boolean strings) static voidshowHelp()static voidMust be called whenever a *.tptp, *.tff or *.fof file is written to allow for clean shutdown of the JVM.static StringtermFormatIndex(KB kb) List all the terms and their termFormat expressions.termIntersection(KB kb, String term1, String term2) Get all formulas that contain both terms.static voidstatic voidwriteDisplayText(KB kb, String displayFormatPredicate, String displayTermPredicate, String language, String fname)
-
Field Details
-
EXECUTOR_SERVICE
-
kryoLocal
A thread local pool for the Kryo serializer -
SIGMA_HOME
-
ONE_K
public static final int ONE_K- See Also:
-
debug
public static boolean debug -
errors
Errors found during processing formulas -
insideWebContext
public static boolean insideWebContextWarnings found during processing formulas
-
-
Constructor Details
-
KButilities
public KButilities()
-
-
Method Details
-
getExecutorService
-
getInstance
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextDestroyedin interfacejavax.servlet.ServletContextListener
-
refreshExecutorService
public static void refreshExecutorService()Force a refresh of the ExecutorService - useful when switching contexts -
isRelation
-
isFunction
-
isAttribute
-
clearErrors
public static void clearErrors() -
hasCorrectTypes
Checks for consistent typing in the given formula- Parameters:
kb- the knowledge base to check typing againstf- the formula to check
-
isValidFormula
Checks for overall validity of the given formula- Parameters:
kb- the knowledge base to check typing againstform- the formula to check
-
isClass
-
isInstance
-
isVariableArity
-
getDocumentation
-
getCountTermFormats
Get count of all the termFormat strings for the given language -
getCountUniqueTermFormats
Get count of all the termFormat strings for unique SUMO terms for the given language. So if a term has more than one termFormat, only count one -
countFormulaTypes
Get count of all the different kinds of formulas as to their logical expressivity -
genSynLinks
Generate default synonymousExternalConcept statements for a .tsv -
eqNum2Text
convert the numerical result of compare() to text -
termIntersection
Get all formulas that contain both terms. -
countRelations
-
isCacheFile
-
countProcesses
-
checkURLs
-
validatePictureList
public static void validatePictureList() -
semnetAsJSON3
-
generateSemNetNeighbors
public Set<KButilities.GraphArc> generateSemNetNeighbors(KB kb, boolean cached, boolean strings, boolean links, String term, int count) -
generateAllNL
Generate line pairs of formula and NL paraphrase of formula -
instanceOfInstanceP
Find all cases of where (instance A B) (instance B C) as well as all cases of where (instance A B) (instance B C) (instance C D). Report true if any such cases are found, false otherwise. -
writeDisplayText
public static void writeDisplayText(KB kb, String displayFormatPredicate, String displayTermPredicate, String language, String fname) throws IOException - Throws:
IOException
-
generateTPTPTestAssertions
public static void generateTPTPTestAssertions() -
generateRelationList
public static void generateRelationList()Note this simply assumes that initial lower case terms are relations. -
getCountNonLinguisticAxioms
-
countStringWords
Count the number of words in all the strings in a knowledge base -
getAllFormulasOfTerm
Find all formulas in which the SUMO term is involved. -
generateFormulasAndDoc
Find all formulas in which the SUMO term is involved. -
termFormatIndex
List all the terms and their termFormat expressions. -
genAllDoc
Generate a textual list of all documentation strings and write to a file. -
genDoc
Generate a textual list of terms and their documentation strings from a file. -
getLabelsForTerm
Generate a HTML list of labels from termFormats TODO: Does this work? Only returning an empty List -
genAllAlphaHTMLDoc
Generate a HTML list of terms and their documentation strings from a file as upper and lowercase individual files so that each file isn't gigantic -
genAllHTMLDoc
Generate a HTML list of terms and their documentation strings from a file. -
getLinkedTermsInDoc
-
genSpecificTermDoc
Generate a HTML list of terms and their documentation strings from a file. -
mergeToMap
public static Map<String,Set<String>> mergeToMap(Map<String, Set<String>> map1, Map<String, Set<String>> map2, KB kb) utility method to merge two HashMaps of String keys and a values of an HashSet of Strings. Note that parent classes in the set of classes will be removed -
shutDownExecutorService
public static void shutDownExecutorService()Must be called whenever a *.tptp, *.tff or *.fof file is written to allow for clean shutdown of the JVM. Call this at the bottom of any main class where the executor is invoked. -
showHelp
public static void showHelp() -
main
-