public abstract class AbstractCollinsHeadFinder extends java.lang.Object implements HeadFinder, CopulaHeadFinder
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:
Modifier and Type | Field and Description |
---|---|
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 |
Modifier | Constructor and Description |
---|---|
protected |
AbstractCollinsHeadFinder(TreebankLanguagePack tlp,
java.lang.String... categoriesToAvoid)
Construct a HeadFinder.
|
Modifier and Type | Method and Description |
---|---|
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
|
boolean |
makesCopulaHead()
Generally will be false, except for SemanticHeadFinder
|
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.
|
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
protected AbstractCollinsHeadFinder(TreebankLanguagePack tlp, java.lang.String... categoriesToAvoid)
tlp
- TreebankLanguagePack used to determine basic categorycategoriesToAvoid
- Constituent types to avoid as headpublic boolean makesCopulaHead()
makesCopulaHead
in interface CopulaHeadFinder
protected Tree findMarkedHead(Tree t)
t
- a tree to find the head ofpublic Tree determineHead(Tree t)
determineHead
in interface HeadFinder
t
- The parse tree to examine the daughters of.
If this is a leaf, null
is returnedt
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 tt
.
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