Class TLDLParserComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.slug.parsing.tldl.TLDLParserComponent

public class TLDLParserComponent extends DiarcComponent
  • Field Details

    • log

      protected final org.slf4j.Logger log
  • Constructor Details

    • TLDLParserComponent

      public TLDLParserComponent()
  • Method Details

    • init

      protected void init()
      Description copied from class: DiarcComponent
      Perform 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:
      init in class DiarcComponent
    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      Override this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • parseArgs

      protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine)
      Description copied from class: DiarcComponent
      Override 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:
      parseArgs in class DiarcComponent
    • parseUtterance

      public Utterance parseUtterance(Utterance input)
      Main entry point for non-incremental parsing. The chart parser is reset before parsing.
      Parameters:
      input -
      Returns:
    • parsePartialUtterance

      public Utterance 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). 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

      public Utterance buildPartialUtterance(Utterance input, List<Node> finalParses)
      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

      public void addDictionary(String newDict)
    • 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

      protected Dictionary getDictionary()
      Used by the component test
      Returns:
      dictionary so that things like generateLocationRules can be tested in the parser test
    • injectDictionaryEntry

      public void injectDictionaryEntry(String morpheme, String type, String semantics, String cognitiveStatus)
    • addHomophone

      public void addHomophone(String base, String homophone)
    • addHomophone

      public void addHomophone(String base, String homophone, boolean writeToFile)
      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: DiarcComponent
      Any component that needs particular shutdown logic needs to override this method and
      Overrides:
      shutdownComponent in class DiarcComponent
    • deregisterDictionary

      public void deregisterDictionary()