public class ASDDecider extends java.lang.Object implements ASDSemantics
Modifier and Type | Field and Description |
---|---|
java.lang.String |
ANYTHING
The string used to match anything at all in a given phrase
or decision structure.
|
java.lang.String |
CLOSEQUOTE
The lexical token which is to be recognized as ending a
quoted string.
|
java.lang.String |
DUMMYWORD
The string recognized as representing a dummy node/instance
in a grammar.
|
java.lang.String |
NO
Abbreviation for NOADVANCE
|
java.lang.String |
NOADVANCE
A possible value returned by the advance() method.
|
java.lang.String |
NUMBER
The string used to stand in for numeric values in
a grammar lexicon.
|
java.lang.String |
OPENQUOTE
The lexical token which is to be recognized as beginning a
quoted string.
|
java.lang.String |
QUIT
A possible value returned by the advance() method.
|
java.lang.String |
SPACECHARS
Whitespace characters which are to be recognized as delimiters
for lexical tokens but not as lexical tokens themselves.
|
java.lang.String |
SPECIALCHARS
Characters which are to be recognized as individual lexical
tokens by the segment method.
|
java.lang.String |
STRING
The string used to stand in for quoted strings in
a grammar lexicon.
|
java.lang.String |
SUCCEED
A possible value returned by the advance() method.
|
static java.lang.String |
UNKNOWN
The string used to stand in for lexical tokens which are not
found in a given grammar lexicon.
|
Constructor and Description |
---|
ASDDecider()
Initializes an ASDDecider with no semantics or application.
|
ASDDecider(java.lang.Object app)
Initializes an instance with the ASDDecider itself to
interpret semantic actions and semantic values in the grammar,
and with application-specific messages to be sent to the
specified application, if desired.
|
ASDDecider(java.lang.Object app,
ASDSemantics semanticsInstance)
Initializes an ASDDecider instance with a reference to a given
application to which application-specific messages are to be sent,
and a given instance of a class that implements the ASDSemantics
interface.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
advance()
Attempts to advance the search state one step.
|
boolean |
backup()
Attempts to backtrack the search state to the most recent
place where a local ambiguity occurred -- that is, where
there was more than one choice for advancing.
|
java.lang.String |
bracketPhrase()
Returns a string showing the current utterance string with
parentheses around each subphrase of more than one non-dummy word.
|
java.lang.String |
bracketPhrase(ASDPhraseNode p)
Returns a string with parentheses around each subphrase of
p with length > 1.
|
java.util.HashSet<java.lang.String> |
createDecisionSet(java.lang.String aString)
Creates a decision set of tokens from the given String.
|
ASDPhraseNode |
currentNode()
Returns the current Node at the top level in the decision structure.
|
ASDPhraseNode |
decisionStructure()
Returns the header node of the current decision structure.
|
boolean |
done()
Tests whether or not a search has been completed successfully.
|
java.util.ArrayList<java.lang.String> |
expectedTypes()
Returns the decider's current list of expected phrase types for
the top level of a search.
|
java.util.HashMap<java.lang.String,java.lang.Object> |
features()
Returns the feature-value pairs for the current top level
of the decision structure.
|
java.lang.Object |
get(java.lang.String featureName)
Returns the value of 'feature' with specified name.
|
void |
initialize(java.lang.String aString,
java.util.ArrayList<java.lang.String> expected)
Initialize the ASDDecider instance for searching a given
string of decision values as one of a list of expected
decision types.
|
ASDGrammar |
lexicon()
Returns the ASDGrammar (decision network) which is currently
being used by the decider.
|
boolean |
parse()
Attempts to find next search of current decision structure.
|
int |
parse(int maxSteps)
Attempts to find next search of current decision structure
in a specified maximum number of advance steps.
|
int |
parseStepNumber()
Returns the number of the current step in a search.
|
void |
raiseFeatures()
Copies the feature-value pairs from the current node value
(which must be a Map) to the current top level of the phrase
structure being searched.
|
java.lang.String |
raiseFeaturesChecking()
Copies the feature-value pairs from the current node value
(which must be a Map) to the current top level of the phrase
structure being searched, provided they are compatible with feature
values already assigned.
|
java.lang.String |
semanticAction(java.lang.String action)
Evaluates a string from a "semantic action" field in an
ASDGrammar, by invoking the corresponding method of the
application object.
|
java.lang.Object |
semanticValue(java.lang.String value)
Evaluates a string from a "semantic value" field in an
ASDGrammar, as a long integer number, a quoted string, or
by invoking the method of the application object which
is named by the semantic value field.
|
void |
set(java.lang.String featureName,
java.lang.Object value)
Sets contents of a 'feature' with the specified name
to the specified value.
|
void |
setANYTHING(java.lang.String newValue)
Resets the string which is used to match anything at all
in a given phrase or decision structure.
|
void |
setCLOSEQUOTE(java.lang.String newValue)
Resets the lexical token which is to be recognized as ending
a quoted string.
|
void |
setDUMMYWORD(java.lang.String newValue)
Resets the string which is recognized by the ASDDecider as representing
a "dummy" word in the grammar -- used in the labels on dummy nodes.
|
void |
setNOADVANCE(java.lang.String newValue)
Sets the NOADVANCE (== NO) value which may be returned by the
advance method to a new value preferred by the client.
|
void |
setNUMBER(java.lang.String newValue)
Resets the string used to stand in for numeric values in
a grammar lexicon.
|
void |
setOPENQUOTE(java.lang.String newValue)
Resets the lexical token which is to be recognized as beginning
a quoted string.
|
void |
setQUIT(java.lang.String newValue)
Sets the QUIT value which may be returned by the advance method
to a new value preferred by the client.
|
void |
setSPACECHARS(java.lang.String newValue)
Resets the string of characters which are to be recognized as
delimiters for lexical tokens but not as lexical tokens themselves.
|
void |
setSPECIALCHARS(java.lang.String newValue)
Resets the string of characters which are to be recognized as
individual lexical tokens by the segment method.
|
void |
setSTRING(java.lang.String newValue)
Resets the string used to stand in for quoted strings
in a grammar lexicon.
|
void |
setSUCCEED(java.lang.String newValue)
Sets the SUCCEED value which may be returned by the advance method
to a new value preferred by the client.
|
void |
setUNKNOWN(java.lang.String newValue)
Resets the string used to stand in for words which are
not found in a given grammar lexicon.
|
void |
showTree()
Displays the current parse tree to the console, with a
-> pointer to the current node at the top level
|
void |
stepParse(int maxSteps)
Attempts to find next search of current decision structure
in a specified maximum number of advance steps;
displays the decision structure to System.out after each step.
|
boolean |
useNetwork(ASDGrammar network)
Sets the ASDDecider instance to use a given decision network,
in the form of an ASDGrammar.
|
boolean |
useNetwork(java.lang.String fileName)
Sets the ASDDecider instance to use an ASDGrammar loaded from
a specified file.
|
java.lang.Object |
valueOf(java.lang.String featureName)
Returns the value of 'feature' with specified name.
|
public java.lang.String ANYTHING
public java.lang.String CLOSEQUOTE
public java.lang.String DUMMYWORD
public java.lang.String NOADVANCE
public java.lang.String NO
public java.lang.String NUMBER
public java.lang.String OPENQUOTE
public java.lang.String QUIT
public java.lang.String SPACECHARS
public java.lang.String SPECIALCHARS
public java.lang.String STRING
public java.lang.String SUCCEED
public static java.lang.String UNKNOWN
public ASDDecider()
public ASDDecider(java.lang.Object app)
app
- the target for application-specific messagespublic ASDDecider(java.lang.Object app, ASDSemantics semanticsInstance)
app
- the target for application-specific messagessemanticsInstance
- instance of a class that implements
ASDSemantics (null if none)public ASDPhraseNode currentNode()
public java.util.ArrayList<java.lang.String> expectedTypes()
public java.util.HashMap<java.lang.String,java.lang.Object> features()
public java.lang.Object get(java.lang.String featureName)
featureName
- the feature whose value is to be obtainedpublic ASDGrammar lexicon()
public ASDPhraseNode decisionStructure()
public int parseStepNumber()
public void set(java.lang.String featureName, java.lang.Object value)
featureName
- the feature whose value is to be setvalue
- the value to be assigned to featureNamepublic java.lang.Object valueOf(java.lang.String featureName)
featureName
- the feature whose value is to be obtainedpublic void initialize(java.lang.String aString, java.util.ArrayList<java.lang.String> expected)
aString
- the string to be searchedexpected
- an ArrayList of strings, each the name
of one of the expected decision types.public java.lang.String advance()
public boolean backup()
public java.lang.String bracketPhrase()
public java.lang.String bracketPhrase(ASDPhraseNode p)
p
- an ASDPhraseNode in a decision structurepublic java.util.HashSet<java.lang.String> createDecisionSet(java.lang.String aString)
aString
- a string to be searchedpublic boolean done()
public boolean parse()
public int parse(int maxSteps)
maxSteps
- the maximum number of steps permittedpublic void raiseFeatures()
public java.lang.String raiseFeaturesChecking()
public java.lang.String semanticAction(java.lang.String action)
semanticAction
in interface ASDSemantics
action
- the semantic action string to be evaluated;
the name of a public method in the application class,
one with no parameters that returns a String.public java.lang.Object semanticValue(java.lang.String value)
semanticValue
in interface ASDSemantics
value
- the semantic value string to be evaluated,
an integer, a string surrounded by double quotes, or
the name of a public method in the application class,
one with no parameters that returns a String.public void setANYTHING(java.lang.String newValue)
public void setCLOSEQUOTE(java.lang.String newValue)
public void setNOADVANCE(java.lang.String newValue)
public void setDUMMYWORD(java.lang.String newValue)
public void setNUMBER(java.lang.String newValue)
public void setOPENQUOTE(java.lang.String newValue)
public void setQUIT(java.lang.String newValue)
public void setSPACECHARS(java.lang.String newValue)
public void setSPECIALCHARS(java.lang.String newValue)
public void setSTRING(java.lang.String newValue)
public void setSUCCEED(java.lang.String newValue)
public void setUNKNOWN(java.lang.String newValue)
public void showTree()
public void stepParse(int maxSteps)
maxSteps
- the maximum number of steps permitted
negative number of steps performed if unsuccessfulpublic boolean useNetwork(ASDGrammar network)
network
- the network to be used.public boolean useNetwork(java.lang.String fileName)
fileName
- the name of the file containing the network.