public abstract class AbstractDependencyGrammar extends java.lang.Object implements DependencyGrammar
Modifier and Type | Field and Description |
---|---|
protected int[] |
coarseDistanceBins |
protected boolean |
directional |
protected java.util.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<java.lang.String> |
tagIndex |
protected TagProjection |
tagProjection |
protected TreebankLanguagePack |
tlp |
protected boolean |
useCoarseDistance |
protected boolean |
useDistance |
protected IntTaggedWord |
wildTW |
protected Index<java.lang.String> |
wordIndex |
Constructor and Description |
---|
AbstractDependencyGrammar(TreebankLanguagePack tlp,
TagProjection tagProjection,
boolean directional,
boolean useDistance,
boolean useCoarseDistance,
Options op,
Index<java.lang.String> wordIndex,
Index<java.lang.String> tagIndex) |
Modifier and Type | Method and Description |
---|---|
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.
|
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(java.util.Collection<Tree> trees)
Default is no-op.
|
protected short |
valenceBin(int distance) |
void |
writeData(java.io.PrintWriter out)
Default is to throw exception.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
scoreTB
protected TagProjection tagProjection
protected final Index<java.lang.String> tagIndex
protected final Index<java.lang.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 java.util.Map<IntDependency,IntDependency> expandDependencyMap
protected int[] coarseDistanceBins
protected int[] regDistanceBins
protected final Options op
protected transient Interner<IntTaggedWord> itwInterner
public AbstractDependencyGrammar(TreebankLanguagePack tlp, TagProjection tagProjection, boolean directional, boolean useDistance, boolean useCoarseDistance, Options op, Index<java.lang.String> wordIndex, Index<java.lang.String> tagIndex)
public void setLexicon(Lexicon lexicon)
DependencyGrammar
setLexicon
in interface DependencyGrammar
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 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 argpublic 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(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)