Package com.articulate.sigma.nlg
Class LanguageFormatterStack
java.lang.Object
com.articulate.sigma.nlg.LanguageFormatterStack
The stack which LanguageFormatter uses in its recursive operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCurrProperties(String key, SumoProcessEntityProperty property) Add the given key - property pair to the properties of the current stack element.booleanAre 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.static booleanareFormulaArgsProcessed(StackElement stackElement) Have all the formula arguments for the given stack element been processed in some way?Generate natural language from the contents of the top element of the stack.Top-level method call for informal NLG after all the elements of the formula have been processed.Return the Mapinvalid input: '<'String, SumoProcessCollector> for the top element of the stack.Return the topmost stack elementFor the current stack element, iterate through the Listand collect their translations into a single list. static StackElement.FormulaArggetFormulaArg(List<StackElement.FormulaArg> formulaArgs, String theArg) Read the given list of FormulaArgs for a given argument.Getter and setter for polarity field.Return the stack element that is second from the topvoidinsertFormulaArgs(Formula formula) Insert the given formula arguments into the topmost element of the stack.booleanisEmpty()Is the stack empty?voidmarkFormulaArgAsProcessed(String theArg) Mark the given formula argument as having been processed.voidpop(StackElement inElement) Pop the top element of the stack if it is inElement.voidPush the current element's sumoProcessMap down into the previous element.voidIf 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.voidpushNew()Push a new element onto the stack.voidpushTranslationDownToNotLevel(String statement) Handle pushing the translation down into the stack for "not" clauses.voidIf 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.voidsetPolarity(VerbProperties.Polarity polarity) voidtranslateCurrProcessInstantiation(KB kb, Formula formula) If possible, translate the process instantiation and insert the translation into the topmost stack element.
-
Constructor Details
-
LanguageFormatterStack
public LanguageFormatterStack()
-
-
Method Details
-
getPolarity
Getter and setter for polarity field.- Returns:
-
setPolarity
-
pop
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
Return the topmost stack element- Returns:
- the topmost stack element; or null if the stack is empty
-
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
Return the Mapinvalid input: '<'String, SumoProcessCollector> for the top element of the stack.- Returns:
-
insertFormulaArgs
Insert the given formula arguments into the topmost element of the stack.- Parameters:
formula-
-
markFormulaArgAsProcessed
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
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
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
Top-level method call for informal NLG after all the elements of the formula have been processed. -
pushCurrTranslatedStateDown
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
For the current stack element, iterate through the Listand 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
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
Handle pushing the translation down into the stack for "not" clauses.- Parameters:
statement-
-
addToCurrProperties
Add the given key - property pair to the properties of the current stack element.- Parameters:
key-property-
-