Class LanguageFormatterStack

java.lang.Object
com.articulate.sigma.nlg.LanguageFormatterStack

public class LanguageFormatterStack extends Object
The stack which LanguageFormatter uses in its recursive operations.
  • Constructor Details

    • LanguageFormatterStack

      public LanguageFormatterStack()
  • Method Details

    • getPolarity

      public VerbProperties.Polarity getPolarity()
      Getter and setter for polarity field.
      Returns:
    • setPolarity

      public void setPolarity(VerbProperties.Polarity polarity)
    • pop

      public void pop(StackElement inElement)
      Pop the top element of the stack if it is inElement.
      Parameters:
      inElement - throws IllegalStateException if the topmost element is not inElement, or if the stack cannot be popped
    • isEmpty

      public boolean isEmpty()
      Is the stack empty?
      Returns:
    • pushNew

      public void pushNew()
      Push a new element onto the stack.
    • getCurrStackElement

      public StackElement getCurrStackElement()
      Return the topmost stack element
      Returns:
      the topmost stack element; or null if the stack is empty
    • getPrevStackElement

      public StackElement getPrevStackElement()
      Return the stack element that is second from the top
      Returns:
      the 2nd from the top stack element; or null if the stack has fewer than 2 elements
    • getCurrProcessMap

      public Map<String,SumoProcessCollector> getCurrProcessMap()
      Return the Mapinvalid input: '<'String, SumoProcessCollector> for the top element of the stack.
      Returns:
    • insertFormulaArgs

      public void insertFormulaArgs(Formula formula)
      Insert the given formula arguments into the topmost element of the stack.
      Parameters:
      formula -
    • markFormulaArgAsProcessed

      public void markFormulaArgAsProcessed(String theArg)
      Mark the given formula argument as having been processed. Note that this method is called when the relevant args are not held at top of stack, but at top - 1.
      Parameters:
      theArg -
    • getFormulaArg

      public static StackElement.FormulaArg getFormulaArg(List<StackElement.FormulaArg> formulaArgs, String theArg)
      Read the given list of FormulaArgs for a given argument.
      Parameters:
      formulaArgs -
      theArg -
      Returns:
      the formula arg corresponding to the given argument; or null if not found
    • areFormulaArgsProcessed

      public boolean areFormulaArgsProcessed()
      Are all the formula arguments processed in some way? Note that this method is called when the relevant args are not held at top of stack, but at top - 1.
      Returns:
    • areFormulaArgsProcessed

      public static boolean areFormulaArgsProcessed(StackElement stackElement)
      Have all the formula arguments for the given stack element been processed in some way?
      Parameters:
      stackElement -
      Returns:
      return true if all the clause arguments have been marked as Processed; return false if they have not or no arguments exist
    • doProcessLevelNatlLanguageGeneration

      public String doProcessLevelNatlLanguageGeneration()
      Generate natural language from the contents of the top element of the stack. Returns empty string if the top element's formula arguments have not all been processed.
      Returns:
      the NLG if top element can be processed; else empty string
    • doStatementLevelNatlLanguageGeneration

      public String doStatementLevelNatlLanguageGeneration()
      Top-level method call for informal NLG after all the elements of the formula have been processed.
    • pushCurrTranslatedStateDown

      public void pushCurrTranslatedStateDown(String arg)
      If the top stack element has been translated, then find the given arg in the previous stack element and mark the corresponding formula argument as translated.
      Parameters:
      arg -
    • getCurrStackFormulaArgs

      public List<String> getCurrStackFormulaArgs()
      For the current stack element, iterate through the List and collect their translations into a single list.
      Returns:
      the curr element's formula args, or empty list if any formula arg has not been translated into informal NLG
    • setCurrTranslatedIfQuantified

      public void setCurrTranslatedIfQuantified()
      If the curr stack element has just two formula args--the first having a state of QUANTIFIED_VARS, the second having a state of TRANSLATED--mark the curr stack element as Translated.
    • translateCurrProcessInstantiation

      public void translateCurrProcessInstantiation(KB kb, Formula formula)
      If possible, translate the process instantiation and insert the translation into the topmost stack element.
      Parameters:
      kb -
      formula - a formula for the instantiation of a process, e.g. (instance ?event Classifying)
    • pushCurrSumoProcessDown

      public void pushCurrSumoProcessDown()
      Push the current element's sumoProcessMap down into the previous element. If the sumoProcessCollector already exists in the lower element of the stack, merge the current element's sumo process elements into the lower element's.
    • pushTranslationDownToNotLevel

      public void pushTranslationDownToNotLevel(String statement)
      Handle pushing the translation down into the stack for "not" clauses.
      Parameters:
      statement -
    • addToCurrProperties

      public void addToCurrProperties(String key, SumoProcessEntityProperty property)
      Add the given key - property pair to the properties of the current stack element.
      Parameters:
      key -
      property -