|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.trees.AbstractCollinsHeadFinder
public abstract class AbstractCollinsHeadFinder
A base class for a HeadFinder similar to the one described in Michael Collins' 1999 thesis. For a given constituent we perform operations like (this is for "left" or "right":
for categoryList in categoryLists for index = 1 to n [or n to 1 if R->L] for category in categoryList if category equals daughter[index] choose it.
with a final default that goes with the direction (L->R or R->L) For most constituents, there will be only one category in the list, the exception being, in Collins' original version, NP.
It is up to the overriding base class to initialize the map from constituent type to categoryLists, "nonTerminalInfo", in its constructor. Entries are presumed to be of type String[][]. Each String[] is a list of categories, except for the first entry, which specifies direction of traversal and must be one of the following:
Changes:
Field Summary | |
---|---|
protected java.lang.String[] |
defaultLeftRule
These are built automatically from categoriesToAvoid and used in a fairly different fashion from defaultRule (above). |
protected java.lang.String[] |
defaultRightRule
|
protected java.lang.String[] |
defaultRule
Default direction if no rule is found for category (the head/parent). |
protected java.util.Map<java.lang.String,java.lang.String[][]> |
nonTerminalInfo
|
protected TreebankLanguagePack |
tlp
|
Constructor Summary | |
---|---|
protected |
AbstractCollinsHeadFinder(TreebankLanguagePack tlp,
java.lang.String... categoriesToAvoid)
Construct a HeadFinder. |
Method Summary | |
---|---|
Tree |
determineHead(Tree t)
Determine which daughter of the current parse tree is the head. |
Tree |
determineHead(Tree t,
Tree parent)
Determine which daughter of the current parse tree is the head. |
protected Tree |
determineNonTrivialHead(Tree t,
Tree parent)
Called by determineHead and may be overridden in subclasses if special treatment is necessary for particular categories. |
protected Tree |
findMarkedHead(Tree t)
A way for subclasses for corpora with explicit head markings to return the explicitly marked head |
protected int |
postOperationFix(int headIdx,
Tree[] daughterTrees)
A way for subclasses to fix any heads under special conditions. |
protected Tree |
traverseLocate(Tree[] daughterTrees,
java.lang.String[] how,
boolean lastResort)
Attempt to locate head daughter tree from among daughters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final TreebankLanguagePack tlp
protected java.util.Map<java.lang.String,java.lang.String[][]> nonTerminalInfo
protected java.lang.String[] defaultRule
protected java.lang.String[] defaultLeftRule
protected java.lang.String[] defaultRightRule
Constructor Detail |
---|
protected AbstractCollinsHeadFinder(TreebankLanguagePack tlp, java.lang.String... categoriesToAvoid)
tlp
- TreebankLanguagePack used to determine basic categorycategoriesToAvoid
- Constituent types to avoid as headMethod Detail |
---|
protected Tree findMarkedHead(Tree t)
t
- a tree to find the head of
public Tree determineHead(Tree t)
determineHead
in interface HeadFinder
t
- The parse tree to examine the daughters of.
If this is a leaf, null
is returned
t
for a routine to call this and spread heads throughout a tree
public Tree determineHead(Tree t, Tree parent)
determineHead
in interface HeadFinder
t
- The parse tree to examine the daughters of.
If this is a leaf, null
is returnedparent
- The parent of t
t
.
Returns null for leaf nodes.for a routine to call this and spread heads throughout a tree
protected Tree determineNonTrivialHead(Tree t, Tree parent)
t
- The tre to determine the head daughter ofparent
- The parent of t (or may be null)
protected Tree traverseLocate(Tree[] daughterTrees, java.lang.String[] how, boolean lastResort)
null
.
protected int postOperationFix(int headIdx, Tree[] daughterTrees)
headIdx
- The index of the proposed headdaughterTrees
- The array of daughter trees
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |