|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.parser.lexparser.AbstractDependencyGrammar
public abstract class AbstractDependencyGrammar
An abstract base class for dependency grammars. The only thing you have to implement in a subclass is scoreTB (score a "tag binned" dependency in the tagProjection space). A subclass also has to either call super() in its constructor, or otherwise initialize the tagBin array. The call to initTagBins() (in the constructor) must be made after all keys have been entered into tagIndex.
Field Summary | |
---|---|
protected int[] |
coarseDistanceBins
|
protected boolean |
directional
|
protected Map<IntDependency,IntDependency> |
expandDependencyMap
|
protected Interner<IntTaggedWord> |
itwInterner
|
protected Lexicon |
lex
|
protected int |
numTagBins
|
protected Options |
op
|
protected int[] |
regDistanceBins
|
protected IntTaggedWord |
stopTW
|
protected int[] |
tagBin
|
protected Index<String> |
tagIndex
|
protected TagProjection |
tagProjection
|
protected TreebankLanguagePack |
tlp
|
protected boolean |
useCoarseDistance
|
protected boolean |
useDistance
|
protected IntTaggedWord |
wildTW
|
protected Index<String> |
wordIndex
|
Constructor Summary | |
---|---|
AbstractDependencyGrammar(TreebankLanguagePack tlp,
TagProjection tagProjection,
boolean directional,
boolean useDistance,
boolean useCoarseDistance,
Options op,
Index<String> wordIndex,
Index<String> tagIndex)
|
Method Summary | |
---|---|
short |
coarseDistanceBin(int distance)
|
short |
distanceBin(int distance)
|
protected void |
initTagBins()
|
protected IntDependency |
intern(IntTaggedWord headTW,
IntTaggedWord argTW,
boolean leftHeaded,
short dist)
This is a custom interner that simultaneously creates and interns an IntDependency. |
int |
numDistBins()
|
int |
numTagBins()
|
void |
readData(BufferedReader in)
Default is to throw exception. |
short |
regDistanceBin(int distance)
|
boolean |
rootTW(IntTaggedWord rTW)
|
double |
score(IntDependency dependency)
Score a IntDependency according to the grammar. |
double |
score(int headWord,
int headTag,
int argWord,
int argTag,
boolean leftHeaded,
int dist)
Score a dependency according to the grammar, where the elements of the dependency are represented in separate paramters. |
double |
scoreTB(int headWord,
int headTag,
int argWord,
int argTag,
boolean leftHeaded,
int dist)
Score a dependency according to the grammar, where the elements of the dependency are represented in separate paramters. |
void |
setLexicon(Lexicon lexicon)
Set the Lexicon, which the DependencyGrammar may use in scoring P(w|t). |
int |
tagBin(int tag)
Converts a tag (coded as an integer via a Numberer) from its representation in the full tag space to the reduced (projected) tag space used in the DependencyGrammar. |
void |
tune(Collection<Tree> trees)
Default is no-op. |
protected short |
valenceBin(int distance)
|
void |
writeData(PrintWriter out)
Default is to throw exception. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface edu.stanford.nlp.parser.lexparser.DependencyGrammar |
---|
scoreTB |
Field Detail |
---|
protected TagProjection tagProjection
protected final Index<String> tagIndex
protected final Index<String> wordIndex
protected int numTagBins
protected int[] tagBin
protected TreebankLanguagePack tlp
protected boolean directional
protected boolean useDistance
protected boolean useCoarseDistance
protected Lexicon lex
protected final IntTaggedWord stopTW
protected final IntTaggedWord wildTW
protected transient Map<IntDependency,IntDependency> expandDependencyMap
protected int[] coarseDistanceBins
protected int[] regDistanceBins
protected final Options op
protected transient Interner<IntTaggedWord> itwInterner
Constructor Detail |
---|
public AbstractDependencyGrammar(TreebankLanguagePack tlp, TagProjection tagProjection, boolean directional, boolean useDistance, boolean useCoarseDistance, Options op, Index<String> wordIndex, Index<String> tagIndex)
Method Detail |
---|
public void setLexicon(Lexicon lexicon)
DependencyGrammar
setLexicon
in interface DependencyGrammar
public void tune(Collection<Tree> trees)
tune
in interface DependencyGrammar
trees
- A Collection of Trees for use as a tuning data setpublic int numTagBins()
numTagBins
in interface DependencyGrammar
public int tagBin(int tag)
DependencyGrammar
tagBin
in interface DependencyGrammar
tag
- An int encoding a tag (in the "tags" Numberer)
public boolean rootTW(IntTaggedWord rTW)
protected short valenceBin(int distance)
public int numDistBins()
numDistBins
in interface DependencyGrammar
public short distanceBin(int distance)
distanceBin
in interface DependencyGrammar
distance
- A distance in intervening words between head and arg
public short regDistanceBin(int distance)
public short coarseDistanceBin(int distance)
protected void initTagBins()
public double score(IntDependency dependency)
DependencyGrammar
score
in interface DependencyGrammar
dependency
- The dependency object to be scored, in normal form.
public double score(int headWord, int headTag, int argWord, int argTag, boolean leftHeaded, int dist)
DependencyGrammar
score
in interface DependencyGrammar
public double scoreTB(int headWord, int headTag, int argWord, int argTag, boolean leftHeaded, int dist)
DependencyGrammar
scoreTB
in interface DependencyGrammar
public void readData(BufferedReader in) throws IOException
readData
in interface DependencyGrammar
IOException
public void writeData(PrintWriter out) throws IOException
writeData
in interface DependencyGrammar
IOException
protected IntDependency intern(IntTaggedWord headTW, IntTaggedWord argTW, boolean leftHeaded, short dist)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |