Class KnowledgeBaseUtils
KnowledgeBase instances.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidConsults theProjogProperties.getBootstrapScript()for theKnowledgeBase.static KnowledgeBaseConstructs a newKnowledgeBaseobject usingProjogDefaultPropertiesstatic KnowledgeBasecreateKnowledgeBase(ProjogProperties projogProperties) Constructs a newKnowledgeBaseobject using the specifiedProjogPropertiesstatic List<PredicateKey> getPredicateKeysByName(KnowledgeBase kb, String predicateName) Returns list of all user defined predicates with the specified name.static <T> Tinstantiate(KnowledgeBase kb, String input) Returns a new object created using reflection.static booleanstatic booleanstatic booleanisSingleAnswer(KnowledgeBase kb, Term term) Returnstrueif the predicate represented by the specifiedTermnever succeeds on re-evaluation.static ObjectnewInstance(KnowledgeBase kb, Class<?> c) Returns a new instance of the specified class.static Term[]
-
Field Details
-
CONJUNCTION_PREDICATE_NAME
The functor of structures representing conjunctions (,).- See Also:
-
IMPLICATION_PREDICATE_NAME
The functor of structures representing implications (:-).- See Also:
-
QUESTION_PREDICATE_NAME
The functor of structures representing questions (i.e. queries) (?-).- See Also:
-
-
Method Details
-
createKnowledgeBase
Constructs a newKnowledgeBaseobject usingProjogDefaultProperties -
createKnowledgeBase
Constructs a newKnowledgeBaseobject using the specifiedProjogProperties -
bootstrap
Consults theProjogProperties.getBootstrapScript()for theKnowledgeBase.This is a way to configure a new
KnowledgeBase(i.e. plugging inArithmeticOperatorandPredicateFactoryinstances).When using
ProjogDefaultPropertiesthe resource parsed will beprojog-bootstrap.pl(contained inprojog-core.jar).- See Also:
-
getPredicateKeysByName
Returns list of all user defined predicates with the specified name. -
isQuestionOrDirectiveFunctionCall
Returnstrueif the specifiedTermrepresents a question or directive, elsefalse.A
Termis judged to represent a question if it is a structure a single argument and with a functorQUESTION_PREDICATE_NAMEorIMPLICATION_PREDICATE_NAME. -
isSingleAnswer
Returnstrueif the predicate represented by the specifiedTermnever succeeds on re-evaluation. -
toArrayOfConjunctions
-
isConjunction
Returnstrueif the specifiedTermrepresent a conjunction, elsefalse.A
Termis judged to represent a conjunction if is a structure with a functor ofCONJUNCTION_PREDICATE_NAMEand exactly two arguments. -
instantiate
Returns a new object created using reflection.The
inputparameter can be in one of two formats:- The class name - e.g.
java.lang.String- this will cause an attempt to create a new instance of the specified class using its no argument constructor. - The class name and a method name (separated by a
/) - e.g.java.util.Calendar/getInstance- this will cause an attempt to create a new instance of the class by invoking the specified method (as a no argument static method) of the specified class.
- Throws:
ReflectiveOperationException
- The class name - e.g.
-
newInstance
Returns a new instance of the specified class.If the class has a constructor that takes a KnowledgeBase as its single argument then an attempt is made to use that to construct the new instance - else an attempt is made to construct a new instance using the no-arg constructor.
- Throws:
ReflectiveOperationException
-