Package edu.tufts.hrilab.consultant
Class Consultant<T extends Reference>
java.lang.Object
edu.tufts.hrilab.consultant.Consultant<T>
- All Implemented Interfaces:
ConsultantInterface
- Direct Known Subclasses:
ABBAreaConsultant,ABBLocationConsultant,AITVisionConsultant,CognexConsultant,ContextConsultant,ItemConsultant,PoseConsultant,RWSPoseConsultant,SpotNavGraphLocationConsultant,TemiV3PoseConsultant,VisionConsultant
-
Field Summary
FieldsModifier and TypeFieldDescriptionThese properties implicitly apply to every reference in this consultant, even though they will not appear as explicit properties in the reference.protected StringKnowledge base name.protected org.slf4j.LoggerAll properties that can be handled by this consultant, excluding the defaultProperties.protected Constructor<T>Constructor for templated Reference class.protected intReference counter used to assign unique refIds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPropertiesHandled(List<Term> properties) Updates consultant and parser if any of the members of @properties are not already handled by the ConsultantvoidaddReference(T ref) Add new reference from some source (file or learning) to the consultantbooleanassertProperties(Symbol refId, List<Term> properties) Add properties to already existing object ref.booleanan attempt is made to bring the knowledge base in line with the provided bindings, list of properties, and probability value.final <U> UconvertToType(Symbol refId, Class<U> type) Convert refId to target class.final <U> UconvertToType(Symbol refId, Class<U> type, List<? extends Term> constraints) Convert refId to target class using the specified constraints for to filter the results.createReference(Variable var, List<Term> properties) A convenience method for creating references from with a DIARC component housing a Consultant instance.createReferences(List<Variable> vars) new representations are created for each free-variable and returned in the binding list.Get a list of currently highly salient entities that should be considered "activated."final Collection<T>Get all References.getAssertedProperties(Symbol refId) Get the list of properties that have been asserted for a given refId.getInitialDomain(List<Term> query) Returns a list of currently known refIds (it takes a seq of Properties, to optionally do some pre-processing to return a list of relevant candidates).Returns name of things handles by this consultant (e.g., "objects", "locations", etc).protected SymbolHelper method to generate next unique reference ID (e.g., object_3).Returns a list of Properties handled by this component.final TgetReference(Symbol refId) Get Reference based on reference ID.final StringGet string description of all known references.getReferencesWithAllProperties(List<Term> properties) Get all references that have all the given propertiesgetReferencesWithAnyProperties(List<Term> properties) Get all references that have any of the given propertiesprotected abstract <U> UlocalConvertToType(Symbol refId, Class<U> type) The local implementation of convertToType.protected abstract <U> UlocalConvertToType(Symbol refId, Class<U> type, List<? extends Term> constraints) The local implementation of convertToType.voidNotify all new property subscribers.Returns the probability that a property (aka constraint) holds for an entity (specified by a map of free-variable to refId bindings).voidregisterForNewPropertyNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Register to be notified when new properties are added to this consultant.removeReference(Symbol refId) Remove known reference from the consultant.booleanretractProperties(Symbol refId, List<Term> properties) stripQuotesFromMorpheme(String input) Remove quotes from input String.voidunregisterForNewPropertyNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Un-register from new property notifications
-
Field Details
-
log
protected org.slf4j.Logger log -
refNumber
protected int refNumberReference counter used to assign unique refIds. -
propertiesHandled
All properties that can be handled by this consultant, excluding the defaultProperties. -
defaultProperties
These properties implicitly apply to every reference in this consultant, even though they will not appear as explicit properties in the reference. -
kbName
Knowledge base name. -
refConstructor
Constructor for templated Reference class.
-
-
Constructor Details
-
Consultant
- Parameters:
refClass- - Reference class. Used to construct new instances of Reference.kbName- knowledge base name
-
Consultant
-
-
Method Details
-
getKBName
Description copied from interface:ConsultantInterfaceReturns name of things handles by this consultant (e.g., "objects", "locations", etc).- Specified by:
getKBNamein interfaceConsultantInterface- Returns:
- knowledge base name
-
getPropertiesHandled
Description copied from interface:ConsultantInterfaceReturns a list of Properties handled by this component.- Specified by:
getPropertiesHandledin interfaceConsultantInterface- Returns:
- list of Properties.
-
addPropertiesHandled
Updates consultant and parser if any of the members of @properties are not already handled by the Consultant- Parameters:
properties- list of candidate properties- Returns:
- true if propertiesHandled is modified
-
retractProperties
-
getInitialDomain
Description copied from interface:ConsultantInterfaceReturns a list of currently known refIds (it takes a seq of Properties, to optionally do some pre-processing to return a list of relevant candidates).- Specified by:
getInitialDomainin interfaceConsultantInterface- Parameters:
query- properties to optionally do some pre-processing- Returns:
- list of currently known ids
-
process
Description copied from interface:ConsultantInterfaceReturns the probability that a property (aka constraint) holds for an entity (specified by a map of free-variable to refId bindings).TODO: rename method to something more descriptive. how about getProbability or checkProperty?
- Specified by:
processin interfaceConsultantInterface- Parameters:
constraint- Property to checkbindings- Map of free variables to refIds- Returns:
- probability value [0.0. 1.0]
-
getActivatedEntities
Description copied from interface:ConsultantInterfaceGet a list of currently highly salient entities that should be considered "activated."- Specified by:
getActivatedEntitiesin interfaceConsultantInterface- Returns:
- list of refIds and probability pairs
-
getAssertedProperties
Description copied from interface:ConsultantInterfaceGet the list of properties that have been asserted for a given refId.- Specified by:
getAssertedPropertiesin interfaceConsultantInterface- Parameters:
refId- reference resolution id- Returns:
- list of Properties
-
createReference
A convenience method for creating references from with a DIARC component housing a Consultant instance.- Parameters:
var- Variable associated with new reference (only important if properties contain more than one Variable)properties- semantic properties of reference- Returns:
- reference of type T
-
createReferences
Description copied from interface:ConsultantInterfacenew representations are created for each free-variable and returned in the binding list.- Specified by:
createReferencesin interfaceConsultantInterface- Parameters:
vars- list of free-variables- Returns:
- list of bindings
-
assertProperties
Description copied from interface:ConsultantInterfacean attempt is made to bring the knowledge base in line with the provided bindings, list of properties, and probability value.- Specified by:
assertPropertiesin interfaceConsultantInterface- Parameters:
bindings- list of bindings in tuple form (free-variable and refId pair)prob- probability valueproperties- list of Properties- Returns:
- whether the updated was successful?
-
assertProperties
Description copied from interface:ConsultantInterfaceAdd properties to already existing object ref. Each property should contain a connection to the existing reference either by refId or refId's variable.- Specified by:
assertPropertiesin interfaceConsultantInterface- Parameters:
refId- referenceproperties- reference properties- Returns:
- if property was successfully added to reference refId
-
addReference
Add new reference from some source (file or learning) to the consultant- Parameters:
ref- new reference to add
-
removeReference
Remove known reference from the consultant.- Parameters:
refId- unique reference ID- Returns:
- removed Reference or null if it doesn't exist
-
getNextReferenceId
Helper method to generate next unique reference ID (e.g., object_3).- Returns:
- unique reference ID
-
getReferenceSummaries
Get string description of all known references. NOTE: to change output of this method, override Reference subclass toString method.- Returns:
- summary of current references
-
getReference
Get Reference based on reference ID. The reference ID can be typed or un-typed.- Parameters:
refId- unique reference ID- Returns:
- Reference of type T
-
getAllReferences
Get all References. This is the values of the internal references map.- Returns:
- all references
-
getReferencesWithAllProperties
Get all references that have all the given properties- Parameters:
properties- property to search for- Returns:
- list of references
-
getReferencesWithAnyProperties
Get all references that have any of the given properties- Parameters:
properties- property to search for- Returns:
- list of references
-
convertToType
Description copied from interface:ConsultantInterfaceConvert refId to target class. This is a way to map references onto Java-types. If it's not possible for a refId to be converted to the specified type, null is returned.- Specified by:
convertToTypein interfaceConsultantInterface- Type Parameters:
U- target Java class template type (any)- Parameters:
refId- - reference resolution ID (e.g.object_3)type- - target Java class type- Returns:
- instance of specified target Java class
-
convertToType
Description copied from interface:ConsultantInterfaceConvert refId to target class using the specified constraints for to filter the results. This is a way to map references onto Java-types. If it's not possible for a refId to be converted to the specified type, null is returned.- Specified by:
convertToTypein interfaceConsultantInterface- Type Parameters:
U- target Java class template type (any)- Parameters:
refId- - reference resolution ID (e.g.object_3)type- - target Java class typeconstraints- first-order-logic predicate constraints- Returns:
- instance of specified target Java class
-
localConvertToType
The local implementation of convertToType.- Type Parameters:
U- target Java class template type (any)- Parameters:
refId- reference resolution ID (e.g.object_3)type- target Java class type- Returns:
- instance of specified target Java class
-
localConvertToType
protected abstract <U> U localConvertToType(Symbol refId, Class<U> type, List<? extends Term> constraints) The local implementation of convertToType.- Type Parameters:
U- target Java class template type (any)- Parameters:
refId- reference resolution ID (e.g.object_3)type- target Java class typeconstraints- first-order-logic predicate constraints- Returns:
- instance of specified target Java class
-
registerForNewPropertyNotification
public void registerForNewPropertyNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Register to be notified when new properties are added to this consultant.- Specified by:
registerForNewPropertyNotificationin interfaceConsultantInterface- Parameters:
callback- TRADE service to be notified at.
-
unregisterForNewPropertyNotification
public void unregisterForNewPropertyNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Un-register from new property notifications- Specified by:
unregisterForNewPropertyNotificationin interfaceConsultantInterface- Parameters:
callback- TRADE service that was registered
-
notifyNewPropertySubscribers
public void notifyNewPropertySubscribers()Notify all new property subscribers.- Specified by:
notifyNewPropertySubscribersin interfaceConsultantInterface
-
stripQuotesFromMorpheme
Remove quotes from input String.TODO: move this method to utility class
- Parameters:
input- String with quotes- Returns:
- string without quotes
-