|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectasd.ASDParser
public class ASDParser
Instances are parsers that can load an ASDGrammar from a specified file and use it to parse given utterances.
| Field Summary | |
|---|---|
java.lang.String |
ANYTHING
The string used to match anything at all in a given phrase or phrase 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 Summary | |
|---|---|
ASDParser()
Initializes an ASDParser with no semantics or application. |
|
ASDParser(java.lang.Object app)
Initializes an instance with the ASDParser itself to interpret semantic actions and semantic values in the grammar, and with application-specific messages to be sent to the specified application. |
|
ASDParser(java.lang.Object app,
ASDSemantics semanticsInstance)
Initializes an ASDParser 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. |
|
| Method Summary | |
|---|---|
java.lang.String |
advance()
Attempts to advance the parse state one step. |
boolean |
backup()
Attempts to backtrack the parse 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. |
ASDPhraseNode |
currentNode()
Returns the current Node at the top level in the phrase structure. |
boolean |
done()
Tests whether or not a parse has been completed successfully. |
java.util.ArrayList<java.lang.String> |
expectedTypes()
Returns the parser's current list of expected phrase types for the top level of a parse. |
java.util.HashMap<java.lang.String,java.lang.Object> |
features()
Returns the feature-value pairs for the current top level of the phrase 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 ASDParser instance for parsing a given string as one of a list of expected phrase types. |
ASDGrammar |
lexicon()
Returns the ASDGrammar which is currently being used by the parser. |
boolean |
parse()
Attempts to find next parse of current phrase structure. |
int |
parse(int maxSteps)
Attempts to find next parse of current phrase structure in a specified maximum number of advance steps. |
int |
parseStepNumber()
Returns the number of the current step in a parse. |
ASDPhraseNode |
phraseStructure()
Returns the header node of the current phrase structure. |
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 parsed. |
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 parsed, 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 phrase 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 ASDParser 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 |
setSaveUniquelyParsedSubphrases(boolean save)
Tells the ASDParser instance whether or not to retain uniquely-parsed subphrases when it backtracks. |
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 parse of current phrase structure in a specified maximum number of advance steps; displays the parse tree to System.out after each step. |
boolean |
useGrammar(ASDGrammar grammar)
Sets the ASDParser instance to use a given ASDGrammar. |
boolean |
useGrammar(java.lang.String fileName)
Sets the ASDParser 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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public ASDParser()
public ASDParser(java.lang.Object app)
app - the target for application-specific messages
public ASDParser(java.lang.Object app,
ASDSemantics semanticsInstance)
app - the target for application-specific messagessemanticsInstance - instance of a class that implements
ASDSemantics (null if none)| Method Detail |
|---|
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 obtained
public ASDGrammar lexicon()
public ASDPhraseNode phraseStructure()
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 obtained
public void initialize(java.lang.String aString,
java.util.ArrayList<java.lang.String> expected)
aString - the string to be parsedexpected - an ArrayList of strings, each the name
of one of the expected phrase 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 phrase structurepublic boolean done()
public boolean parse()
public int parse(int maxSteps)
maxSteps - the maximum number of steps permitted
public void raiseFeatures()
public java.lang.String raiseFeaturesChecking()
public java.lang.String semanticAction(java.lang.String action)
semanticAction in interface ASDSemanticsaction - 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 ASDSemanticsvalue - 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 setSaveUniquelyParsedSubphrases(boolean save)
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 useGrammar(ASDGrammar grammar)
grammar - the grammar to be used.
public boolean useGrammar(java.lang.String fileName)
fileName - the name of the file containing the grammar.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||