Package edu.tufts.hrilab.vision.util
Class PredicateHelper
java.lang.Object
edu.tufts.hrilab.vision.util.PredicateHelper
Helper methods to deal with Predicates in VisionComponent.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToVisionForm
(Symbol symbol) convertToVisionForm
(List<? extends Symbol> symbols) static Predicate
Wrapper around Factory.createPredicate that sets all variables to varType (e.g., "object").static Predicate
createPredicate
(String s, String type) Wrapper around Util.createPredicate that sets all variables to varType (e.g., type).static String
getNativeStringRepresentation
(Symbol symbol) Basically a customized toString method for the Symbol class hierarchy.static String
getRepresentativeString
(Term term) Get the representative string from a Predicate.static boolean
isObjectRef
(Symbol descriptor) Check if a single descriptor is a POWER object ref that matches "[kbName]_[number]" (e.g., object_3).static boolean
isObjectRef
(List<? extends Symbol> descriptors) Check if a list a descriptors is specifying a POWER object ref.orderVariableLists
(Set<List<Variable>> unorderedVars) Order the set of variable lists using relations (i.e., list with 2 variables) as the ordering constraints where the second variable of a relation needs to come first in the ordering.orderVariables
(List<? extends Term> terms) Order the variables contained in the list of terms using the relation terms (i.e., Term with 2 variables) as the ordering constraints where the second variable of a relation needs to come first in the ordering.static void
removeDuplicates
(List<? extends Symbol> symbols) static Predicate
Replace all occurences of argOld with argNew in term and return a new Predicate with the specified replacements.static void
setVariableType
(Symbol symbol, String type) Sets the 'type' field of every Variable contained in the symbol.splitIntoEntities
(List<? extends Term> predicates)
-
Field Details
-
varType
- See Also:
-
-
Constructor Details
-
PredicateHelper
public PredicateHelper()
-
-
Method Details
-
getRepresentativeString
Get the representative string from a Predicate. This is pretty much a hack in order to pass the appropriate string to the native side and to look up the associated VisionProcess via the hashmaps they are stored in. This can hopefully be made more general and non-hacky once Predicates have been standardized in DIARC, and if Predicates can be handled directly on the native side. Vision assumes all predicates have descriptor as functor name. Examples: red(X) -> red, near(A,B) -> near- Parameters:
term
-- Returns:
-
getNativeStringRepresentation
Basically a customized toString method for the Symbol class hierarchy. Does not retain Variable type, and also converts bound Variables to their bound value, disregarding the Variable name and type (e.g., name/binding = A/red(X) --> red(X)).- Parameters:
symbol
-- Returns:
-
splitIntoEntities
-
convertToVisionForm
-
convertToVisionForm
-
removeDuplicates
-
orderVariables
Order the variables contained in the list of terms using the relation terms (i.e., Term with 2 variables) as the ordering constraints where the second variable of a relation needs to come first in the ordering. For example, handle(Y), on(Y,X), mug(X), would produce the ordering X -> Y.- Parameters:
terms
-- Returns:
-
orderVariableLists
Order the set of variable lists using relations (i.e., list with 2 variables) as the ordering constraints where the second variable of a relation needs to come first in the ordering. For example,handle(Y) & on(Y,X) & mug(X)
, which produces the following lists of variables [Y],[Y,X],[X] would produce the ordering X -> Y -> X,Y.- Parameters:
unorderedVars
-- Returns:
-
replace
Replace all occurences of argOld with argNew in term and return a new Predicate with the specified replacements.- Parameters:
term
-argOld
-argNew
-- Returns:
-
setVariableType
Sets the 'type' field of every Variable contained in the symbol.- Parameters:
symbol
-type
-
-
createPredicate
Wrapper around Factory.createPredicate that sets all variables to varType (e.g., "object").- Parameters:
s
-- Returns:
-
createPredicate
Wrapper around Util.createPredicate that sets all variables to varType (e.g., type).- Parameters:
s
-- Returns:
-
isObjectRef
Check if a list a descriptors is specifying a POWER object ref. Basically, that there's a single descriptor that matches "[kbName]_[number]" (e.g., object_3).- Parameters:
descriptors
-- Returns:
-
isObjectRef
Check if a single descriptor is a POWER object ref that matches "[kbName]_[number]" (e.g., object_3).- Parameters:
descriptor
-- Returns:
-