Parsing Engine

danbikel.parser.english
Class BrokenHeadFinder

java.lang.Object
  extended by danbikel.parser.lang.AbstractHeadFinder
      extended by danbikel.parser.english.BrokenHeadFinder
All Implemented Interfaces:
HeadFinder, Serializable

public class BrokenHeadFinder
extends AbstractHeadFinder

Reads a series of heuristics to determine the distinguished head child of a context-free production (a parent and its ordered list of children in a syntax tree). Because a default head-finding rule is always supplied even if one is not specified, it is guaranteed that every tree in which head-finding is performed will have a unique head-lexicalization.

Important note: This class is similar to HeadFinder, except that it is “broken” in the sense that instead of doing the closest possible emulation of Collins’ parsing model, it only uses details found in Collins’ published papers. See Intricacies of Collins” Parsing Model for details.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class danbikel.parser.lang.AbstractHeadFinder
AbstractHeadFinder.HeadFindInstruction
 
Field Summary
 
Fields inherited from class danbikel.parser.lang.AbstractHeadFinder
defaultSym, fallbackDefaultHeadTableResource, headFindInstructions, headSuffix, LEFT, leftSym, postHeadSuffix, preHeadSuffix, probRandom, rand, RIGHT, rightSym, useRand, warnDefaultRule
 
Constructor Summary
BrokenHeadFinder()
          Constructs an English head-finding object, getting the name of the head table from the value of Settings.get(Settings.headTablePrefix + Language.getLanguage()).
BrokenHeadFinder(Sexp headTableSexp)
          Constructs an English head-finding object with the specified head table.
 
Method Summary
 int findHead(Sexp tree, Symbol lhs, SexpList rhs)
          Finds the head for the grammar production lhs -> rhs.
static void main(String[] args)
          A test driver for this class.
 
Methods inherited from class danbikel.parser.lang.AbstractHeadFinder
addHeadInformation, defaultFindHead, findHead, headSuffix, readHeadTable, scan, scanLeftToRight, scanRightToLeft, tagMatches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokenHeadFinder

public BrokenHeadFinder()
                 throws IOException,
                        FileNotFoundException
Constructs an English head-finding object, getting the name of the head table from the value of Settings.get(Settings.headTablePrefix + Language.getLanguage()). The named head table is searched for in the locations that are searched by the method Settings.getFileOrResourceAsStream(Class,String).

This constructor will be invoked upon the initialization of the Language class.

Important note: This class is similar to HeadFinder, except that it is “broken” in the sense that instead of doing the closest possible emulation of Collins’ parsing model, it only uses details found in Collins’ published papers. See Intricacies of Collins” Parsing Model.

Throws:
IOException
FileNotFoundException
See Also:
Settings.getFileOrResourceAsStream(Class, String)

BrokenHeadFinder

public BrokenHeadFinder(Sexp headTableSexp)
Constructs an English head-finding object with the specified head table.

Method Detail

findHead

public int findHead(Sexp tree,
                    Symbol lhs,
                    SexpList rhs)
Finds the head for the grammar production lhs -> rhs. This method destructively modifies rhs to contain only the canonical version of each of its symbols. This method then calls AbstractHeadFinder.defaultFindHead(Symbol,SexpList), using the canonical version of the lhs symbol for the first argument. If the default head index points to a nonterminal in a coordinating relationship, that is, if the default head index is greater than 2 and the previous nonterminal is a conjunction, then the index returned is the default head index minus 2.

Specified by:
findHead in interface HeadFinder
Specified by:
findHead in class AbstractHeadFinder
Parameters:
tree - the original subtree in which to find the head child, or null if the subtree is not available
lhs - the nonterminal label that is the left-hand side of a grammar production
rhs - a list of symbols that is the right-hand side of a grammar production
Returns:
the 1-based index of the head child in rhs
See Also:
Treebank.isConjunction(Symbol)

main

public static void main(String[] args)
A test driver for this class.


Parsing Engine

Author: Dan Bikel.