|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.uzh.ifi.attempto.chartparser.Grammar
public class Grammar
This class represents a grammar that is needed to run the chart parser. A grammar can be created
either directly in Java or on the basis of a file in the Codeco notation. See the package
description of ch.uzh.ifi.attempto.codeco for more information about the Codeco notation.
| Constructor Summary | |
|---|---|
Grammar()
Creates an empty grammar. |
|
| Method Summary | |
|---|---|
void |
addGrammarRule(GrammarRule rule)
Adds a grammar rule. |
void |
addLexicalRule(LexicalRule lexRule)
Adds a lexical rule. |
boolean |
containsFeatureName(java.lang.String featureName)
Returns whether the given feature name is used in this grammar. |
boolean |
containsNonterminalSymbol(java.lang.String nonterminalSymbol)
Returns whether the given nonterminal symbol is used in this grammar. |
boolean |
containsPreterminalSymbol(java.lang.String preterminalSymbol)
Returns whether the given preterminal symbol is used in this grammar. |
boolean |
containsTerminalSymbol(java.lang.String terminalSymbol)
Returns whether the given terminal symbol is used in this grammar. |
java.util.Set<java.lang.String> |
getFeatureNames()
Returns a set of all names of features used in feature structures of categories contained in this grammar. |
java.util.List<LexicalRule> |
getLexicalRulesByCategory(java.lang.String categoryName)
Returns the list of lexical rules with a pre-terminal category of the specified name. |
java.util.List<LexicalRule> |
getLexicalRulesByWord(java.lang.String word)
Returns the list of lexical rules for the specified word. |
java.util.Set<java.lang.String> |
getNonterminalSymbols()
Returns a set of all nonterminal symbols used in this grammar. |
java.util.Set<java.lang.String> |
getPreterminalSymbols()
Returns a set of all preterminal symbols used in this grammar. |
java.util.List<GrammarRule> |
getRulesByHeadName(java.lang.String name)
Returns the grammar rules with a head category of the specified name. |
protected static StringRef |
getStringRef(int varID,
java.util.HashMap<java.lang.Integer,StringRef> featureHash)
This is an auxiliary method for grammar classes that are automatically generated out of a Codeco representation. |
java.util.Set<java.lang.String> |
getTerminalSymbols()
Returns a set of all terminal symbols used in this grammar. |
protected static void |
setFeature(FeatureMap fm,
java.lang.String featureName,
int varID,
java.util.HashMap<java.lang.Integer,StringRef> featureHash)
This is an auxiliary method for grammar classes that are automatically generated out of a Codeco representation. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Grammar()
| Method Detail |
|---|
public void addGrammarRule(GrammarRule rule)
rule - The grammar rule to be added.public void addLexicalRule(LexicalRule lexRule)
lexRule - The lexical rule to be added.public java.util.List<GrammarRule> getRulesByHeadName(java.lang.String name)
name - The name of the head category.
public java.util.List<LexicalRule> getLexicalRulesByCategory(java.lang.String categoryName)
categoryName - The name of the pre-terminal category.
public java.util.List<LexicalRule> getLexicalRulesByWord(java.lang.String word)
word - The word.
public java.util.Set<java.lang.String> getFeatureNames()
public boolean containsFeatureName(java.lang.String featureName)
featureName - The feature name.
public java.util.Set<java.lang.String> getTerminalSymbols()
public boolean containsTerminalSymbol(java.lang.String terminalSymbol)
terminalSymbol - The terminal symbol.
public java.util.Set<java.lang.String> getPreterminalSymbols()
public boolean containsPreterminalSymbol(java.lang.String preterminalSymbol)
preterminalSymbol - The preterminal symbol.
public java.util.Set<java.lang.String> getNonterminalSymbols()
public boolean containsNonterminalSymbol(java.lang.String nonterminalSymbol)
nonterminalSymbol - The nonterminal symbol.
protected static void setFeature(FeatureMap fm,
java.lang.String featureName,
int varID,
java.util.HashMap<java.lang.Integer,StringRef> featureHash)
fm - The feature map for which a feature should be set.featureName - The name of the feature to be set.varID - The identifier of the unbound variable to which the feature should be set.featureHash - A hash map with variable identiers as keys and the string reference
objects that represent the respective variables as values.
protected static StringRef getStringRef(int varID,
java.util.HashMap<java.lang.Integer,StringRef> featureHash)
varID - The identifier of the unbound variable for which a string reference object
should be returned.featureHash - A hash map with variable identiers as keys and the string reference
objects that represent the respective variables as values.
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||