|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.umn.cs.nlp.parser.PCNFGrammar
public class PCNFGrammar
Probabilistic grammar capable of parsing using the CKY parsing algorithm. Performs Viterbi traceback to find the most likely parse.
Rules in this grammar are required to be in Chomsky Normal Form (CNF).
| Constructor Summary | |
|---|---|
PCNFGrammar()
Constructs a new probabilistic grammar, the rules of which are required to be in Chomsky Normal Form (CNF). |
|
| Method Summary | |
|---|---|
void |
addLexicalRule(String lhs,
String rhs,
double logProb)
Add a new unary rule to the grammar. |
void |
addRule(String lhs,
String rhs1,
String rhs2,
double logProb)
Add a new binary rule to the grammar. |
static void |
main(String[] args)
Example usage of this class with a small sample grammar and test sentences. |
ParseTree |
parse(String... token)
Attempts to parse the given series of tokens using this grammar. |
ParseTree |
parse(String sentence)
Attempts to parse the given sentence using this grammar. |
Collection<ParseTree> |
parseAll(String... sentences)
Attempts to parse each of the given sentences using parse(String sentence). |
boolean |
parses(String... token)
Determines if the given series of tokens can be successfully parsed by this grammar. |
boolean |
parses(String sentence)
Determines if the given sentence can be successfully parsed by this grammar. |
void |
setLocale(Locale locale)
Sets the locale. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PCNFGrammar()
| Method Detail |
|---|
public void addRule(String lhs,
String rhs1,
String rhs2,
double logProb)
lhs - The left-hand-side of the rule. Must be a non-terminal.rhs1 - The left child of the rule. Must be a non-terminal.rhs2 - The right child of the rule. Must be a non-terminal.logProb - The log probability of the given rule.
public void addLexicalRule(String lhs,
String rhs,
double logProb)
lhs - The left-hand-side of the rule. Must be a non-terminal.rhs - The child of the rule. Must be a terminal.logProb - The log probability of the given rule.public boolean parses(String sentence)
parses in interface GrammarInterfacesentence - The sentence to be parsed. Will be lowercased using the default locale and then tokenized prior to parsing.
true if this grammar can parse the given sentence;
false otherwise.setLocale(Locale)public boolean parses(String... token)
parses in interface GrammarInterfacetoken - Array of tokens specifying the sentence to be parsed. No lowercasing will be performed by this method.
true if this grammar can parse the given sentence;
false otherwise.public ParseTree parse(String sentence)
parse in interface GrammarInterfacesentence - The sentence to be parsed. Will be lowercased using the default locale and then tokenized prior to parsing.
ParseTree.NULL_PARSE otherwise.setLocale(Locale)public ParseTree parse(String... token)
parse in interface GrammarInterfacetoken - Array of tokens specifying the sentence to be parsed. No lowercasing will be performed by this method.
ParseTree.NULL_PARSE otherwise.public Collection<ParseTree> parseAll(String... sentences)
parse(String sentence).
parseAll in interface GrammarInterfacesentences - the sentences to be parsed.
ParseTree per sentencepublic void setLocale(Locale locale)
parse(String sentence)
and by parses(String sentence) when lowercasing the sentence.
locale - the locale to use when performing lowercasingString.toLowerCase(Locale)public static void main(String[] args)
args - arguments are ignored
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||