Class TLDLParserComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.slug.parsing.tldl.TLDLParserComponent
-
Field Summary
FieldsFields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDictionary(String newDict) voidaddHomophone(String base, String homophone) voidaddHomophone(String base, String homophone, boolean writeToFile) Given a base morpheme and homophone, create and add all duplicate entries with homophone as new morphemeprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.buildPartialUtterance(Utterance input, List<Node> finalParses) Constructs a partial Utterance by processing the input Utterance and a list of possible parses.createUtterances(Utterance input, Node finalNode, Symbol speaker, Symbol addressee) Constructs an Utterance object based on the provided finalNode's rules and given speaker and addressee symbols.voidprotected DictionaryUsed by the component testprotected voidinit()Perform any component initialization.voidinjectDictionaryEntry(String morpheme, String type, String semantics, String cognitiveStatus) protected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.parsePartialUtterance(Utterance input) Parses a (potentially partial) input Utterance and generates an Utterance containing the parsed semantics, error semantics, or return the input as is (when there are no words to parse).parseUtterance(Utterance input) Main entry point for non-incremental parsing.voidTemporary method to manually reset the chart parser if using the parsePartialUtterance method.protected voidsetUseAddressHistory(boolean val) Used in parser test to toggle updateAddressHistoryprotected voidAny component that needs particular shutdown logic needs to override this method andMethods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
attachShutdownHook, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, postRegistrationInit, shutdown
-
Field Details
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
TLDLParserComponent
public TLDLParserComponent()
-
-
Method Details
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
parseUtterance
Main entry point for non-incremental parsing. The chart parser is reset before parsing.- Parameters:
input-- Returns:
-
parsePartialUtterance
Parses a (potentially partial) input Utterance and generates an Utterance containing the parsed semantics, error semantics, or return the input as is (when there are no words to parse). This method does not reset the chart parser, and will add the incoming utterance to the previously processed Utterance. Use the parseUtterance method for full, independent parses. NOTE: this is experimental. There is currently no mechansim to automaticlly detect the end of an utternacee and reset the chart parser.- Parameters:
input- The input Utterance to be parsed. It should contain a list of words and other relevant metadata required for processing. If the input is null or contains no words, it will be returned as is.- Returns:
- An updated Utterance constructed from the results of the parsing process.
-
resetParser
public void resetParser()Temporary method to manually reset the chart parser if using the parsePartialUtterance method. -
buildPartialUtterance
Constructs a partial Utterance by processing the input Utterance and a list of possible parses. If a valid parse exists in the provided list, a new Utterance is created based on the top-ranked parse. Otherwise, it handles the case of empty or invalid parses by generating error semantics or returning the input as is.- Parameters:
input- The input Utterance to be processed.finalParses- A list of Node objects representing potential parses for the utterance. This can be empty or null if no valid parses are produced.- Returns:
- A new Utterance built from the best parse in the list, or an Utterance with error semantics if no valid parses are available. Returns the original input Utterance if no modifications are required.
-
addDictionary
-
createUtterances
public List<Utterance> createUtterances(Utterance input, Node finalNode, Symbol speaker, Symbol addressee) Constructs an Utterance object based on the provided finalNode's rules and given speaker and addressee symbols. The method processes semantic and syntactic information from the node's rules to generate a structured Utterance.- Parameters:
finalNode- The Node object containing the rules from which the utterance is generated.speaker- The Symbol representing the speaker of the input utterance.addressee- The Symbol representing the addressee of the input utterance (often unknown).- Returns:
- An Utterance object constructed based on the rules, semantics, and other properties of the node. Returns null if no valid Utterance could be created from the node's rules.
-
setUseAddressHistory
protected void setUseAddressHistory(boolean val) Used in parser test to toggle updateAddressHistory- Parameters:
val- new value
-
getDictionary
Used by the component test- Returns:
- dictionary so that things like generateLocationRules can be tested in the parser test
-
injectDictionaryEntry
-
addHomophone
-
addHomophone
Given a base morpheme and homophone, create and add all duplicate entries with homophone as new morpheme- Parameters:
base-homophone-writeToFile-
-
shutdownComponent
protected void shutdownComponent()Description copied from class:DiarcComponentAny component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponentin classDiarcComponent
-
deregisterDictionary
public void deregisterDictionary()
-