|
|||||||||
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 Numberer.getGlobalNumberer("tags").
Field Summary | |
---|---|
protected static int[] |
coarseDistanceBins
|
protected boolean |
directional
|
protected java.util.Map<IntDependency,IntDependency> |
expandDependencyMap
|
protected Lexicon |
lex
|
protected int |
numTagBins
|
protected static int[] |
regDistanceBins
|
protected static IntTaggedWord |
stopTW
|
protected int[] |
tagBin
|
protected TagProjection |
tagProjection
|
protected TreebankLanguagePack |
tlp
|
protected boolean |
useCoarseDistance
|
protected boolean |
useDistance
|
protected static IntTaggedWord |
wildTW
|
Constructor Summary | |
---|---|
AbstractDependencyGrammar(TreebankLanguagePack tlp,
TagProjection tagProjection,
boolean directional,
boolean useDistance,
boolean useCoarseDistance)
|
Method Summary | |
---|---|
static 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(java.io.BufferedReader in)
Default is to throw exception. |
static short |
regDistanceBin(int distance)
|
static 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. |
protected static Numberer |
tagNumberer()
|
void |
tune(java.util.Collection<Tree> trees)
Default is no-op. |
protected short |
valenceBin(int distance)
|
protected static Numberer |
wordNumberer()
|
void |
writeData(java.io.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 int numTagBins
protected int[] tagBin
protected TreebankLanguagePack tlp
protected boolean directional
protected boolean useDistance
protected boolean useCoarseDistance
protected Lexicon lex
protected static final IntTaggedWord stopTW
protected static final IntTaggedWord wildTW
protected transient java.util.Map<IntDependency,IntDependency> expandDependencyMap
protected static int[] coarseDistanceBins
protected static int[] regDistanceBins
Constructor Detail |
---|
public AbstractDependencyGrammar(TreebankLanguagePack tlp, TagProjection tagProjection, boolean directional, boolean useDistance, boolean useCoarseDistance)
Method Detail |
---|
public void setLexicon(Lexicon lexicon)
DependencyGrammar
setLexicon
in interface DependencyGrammar
protected static Numberer tagNumberer()
protected static Numberer wordNumberer()
public void tune(java.util.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 static 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 static short regDistanceBin(int distance)
public static 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(java.io.BufferedReader in) throws java.io.IOException
readData
in interface DependencyGrammar
java.io.IOException
public void writeData(java.io.PrintWriter out) throws java.io.IOException
writeData
in interface DependencyGrammar
java.io.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 |