|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectup.Grammar
public class Grammar
A probabilistic context-free grammar.
When a rule is added to the grammar, the rule itself as well as all
terminal and nonterminal symbols occurring in the rule are assigned a
code, a unique, non-negative integer. Two rules or symbols will
receive the same code if and only if they are equal with respect to the
method equals
.
Constructor Summary | |
---|---|
Grammar()
Constructs a new grammar. |
Method Summary | |
---|---|
BinaryRule |
addBinaryRule(java.lang.String lhs,
java.lang.String rhs1,
java.lang.String rhs2)
Adds the specified binary rule to this grammar. |
PreterminalRule |
addPreterminalRule(java.lang.String lhs,
java.lang.String rhs)
Adds the specified preterminal rule to this grammar. |
UnaryRule |
addUnaryRule(java.lang.String lhs,
java.lang.String rhs)
Adds the specified unary rule to this grammar. |
java.util.List<BinaryRule> |
getBinaryRules()
Returns the binary rules of this grammar. |
java.util.List<BinaryRule> |
getBinaryRulesWithLHS(int lhs)
Returns the binary rules of this grammar with the specified left-hand side. |
java.util.List<BinaryRule> |
getBinaryRulesWithRHS1(int rhs1)
Returns the binary rules of this grammar with the specified right-hand side. |
java.util.List<BinaryRule> |
getBinaryRulesWithRHS2(int rhs2)
Returns the binary rules of this grammar with the specified right-hand side. |
java.lang.String |
getCategory(int code)
Returns the category of this grammar with the specified code. |
int |
getCodeCategory(java.lang.String category)
Returns the code of the specified syntactic category. |
int |
getCodeWord(java.lang.String word)
Returns the code of the specified word. |
int |
getNBinaryRules()
Returns the number of binary rules of this grammar. |
int |
getNCategories()
Returns the number of categories of this grammar. |
int |
getNPreterminalRules()
Returns the number of preterminal rules of this grammar. |
int |
getNRules()
Returns the number of rules of this grammar. |
int |
getNUnaryRules()
Returns the number of unary rules of this grammar. |
int |
getNWords()
Returns the number of words of this grammar. |
java.util.List<PreterminalRule> |
getPreterminalRules()
Returns the preterminal rules of this grammar. |
java.util.List<PreterminalRule> |
getPreterminalRulesWithLHS(int lhs)
Returns the preterminal rules of this grammar with the specified left-hand side. |
java.util.List<PreterminalRule> |
getPreterminalRulesWithRHS(int rhs)
Returns the preterminal rules of this grammar with the specified right-hand side. |
int |
getRootCode()
Returns the code of the root category of this grammar. |
java.util.List<UnaryRule> |
getUnaryRules()
Returns the unary rules of this grammar. |
java.util.List<UnaryRule> |
getUnaryRulesWithLHS(int lhs)
Returns the unary rules of this grammar with the specified left-hand side. |
java.util.List<UnaryRule> |
getUnaryRulesWithRHS(int rhs)
Returns the unary rules of this grammar with the specified right-hand side. |
int |
getUnknownCode()
Returns the code of the unknown word. |
java.lang.String |
getWord(int code)
Returns the word with the specified code. |
void |
seal()
Seals the grammar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Grammar()
Method Detail |
---|
public int getNCategories()
public int getNWords()
public int getCodeCategory(java.lang.String category)
category
- the syntactic category whose code to return
-1
in case
the specified category is not a category of this grammarpublic int getRootCode()
public java.lang.String getCategory(int code)
code
- the code whose corresponding category to return
null
in case this grammar does not have a category with
the specified codepublic int getCodeWord(java.lang.String word)
word
- the word whose code to return
-1
in case the
specified word is not a word of this grammarpublic int getUnknownCode()
public java.lang.String getWord(int code)
code
- the code whose corresponding word to return
null
in case this grammar does not have a word with the
specified codepublic PreterminalRule addPreterminalRule(java.lang.String lhs, java.lang.String rhs)
lhs
- the left-hand side category (POS tag) of the rulerhs
- the right-hand side (word) of the rule
public UnaryRule addUnaryRule(java.lang.String lhs, java.lang.String rhs)
lhs
- the left-hand side category of the rulerhs
- the right-hand side category of the rule
public BinaryRule addBinaryRule(java.lang.String lhs, java.lang.String rhs1, java.lang.String rhs2)
lhs
- the left-hand side category of the rulerhs1
- the first category on the right-hand side of the rulerhs2
- the second category on the right-hand side of the rule
public void seal()
public int getNRules()
public java.util.List<PreterminalRule> getPreterminalRules()
public int getNPreterminalRules()
public java.util.List<PreterminalRule> getPreterminalRulesWithLHS(int lhs)
lhs
- the code of the left-hand side (category)
public java.util.List<PreterminalRule> getPreterminalRulesWithRHS(int rhs)
rhs
- the code of the right-hand side (word)
public java.util.List<UnaryRule> getUnaryRules()
public int getNUnaryRules()
public java.util.List<UnaryRule> getUnaryRulesWithLHS(int lhs)
lhs
- the code of the left-hand side
public java.util.List<UnaryRule> getUnaryRulesWithRHS(int rhs)
rhs
- the code of the right-hand side
public java.util.List<BinaryRule> getBinaryRules()
public int getNBinaryRules()
public java.util.List<BinaryRule> getBinaryRulesWithLHS(int lhs)
lhs
- the left-hand side
public java.util.List<BinaryRule> getBinaryRulesWithRHS1(int rhs1)
rhs1
- the first category on the right-hand side
public java.util.List<BinaryRule> getBinaryRulesWithRHS2(int rhs2)
rhs2
- the second category on the right-hand side
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |