Class KnowledgeBaseUtils
java.lang.Object
org.projog.core.kb.KnowledgeBaseUtils
Helper methods for performing common tasks on
KnowledgeBase instances.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor as all methods are static. -
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.private static <T> Tinstantiate(String input) static <T> Tinstantiate(KnowledgeBase knowledgeBase, 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 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:
-
-
Constructor Details
-
KnowledgeBaseUtils
private KnowledgeBaseUtils()Private constructor as all methods are static.
-
-
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
public static <T> T instantiate(KnowledgeBase knowledgeBase, String input) throws ReflectiveOperationException 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.
-
instantiate
- Throws:
ReflectiveOperationException
-