Parsing Engine

danbikel.parser.util
Class DebugChart

java.lang.Object
  extended by danbikel.parser.util.DebugChart

public class DebugChart
extends Object

A class to print to System.err the constituents of a gold-standard parse tree that were found by the parser, according to its output chart file.


Field Summary
static Filter allPass
           
static Filter onlyStopped
           
 
Method Summary
static Set collectBest(CKYItem topRanked)
           
static void downcaseWords(HeadTreeNode tree)
           
static void downcaseWords(Sexp tree)
           
static void findConstituents(boolean downcaseWords, Chart chart, CKYItem topRankedItem, SexpList sentence, Sexp goldTree)
          Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to the specified chart.
static void findConstituents(Chart chart, Set best, HeadTreeNode tree)
           
static void findConstituents(String prefix, boolean downcaseWords, Chart chart, CKYItem topRankedItem, SexpList sentence, Sexp goldTree)
          Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to the specified chart.
static void findConstituents(String prefix, Chart chart, Set best, HeadTreeNode tree)
           
static void findConstituents(String chartFilename, Sexp goldTree)
          Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to its output chart file.
static String headTreeNodeToString(HeadTreeNode node)
          Returns a string of the form [start,end,label<headWord>, <headChild>] where <headWord> is the head word and where <headChild> is either a string of the form [start,end,label] or null if the specified HeadTreeNode is a preterminal.
static String itemToString(CKYItem item)
           
static String itemToString(CKYItem item, Set best)
           
static void printBestDerivationStats(String prefix, Chart chart, int sentLen, Symbol topSym, double nonTopHighestLogProb, CKYItem bestDerivationItem)
           
static void printDerivation(CKYItem item)
          Prints the derivation rooted at the specified chart item to System.err.
static void printDerivation(CKYItem item, Filter filter)
           
static Sexp removeChildlessNodes(Sexp tree)
          Removes interior nodes of the specified tree that are not preterminals and that have no children.
static Sexp removePreterms(SexpList words, Sexp tree, int wordIdx)
          Removes preterminals from the specified tree that are not found in the specified list of words.
static void replaceWords(boolean downcaseWords, Sexp tree, SexpList sentence)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allPass

public static Filter allPass

onlyStopped

public static Filter onlyStopped
Method Detail

findConstituents

public static void findConstituents(String chartFilename,
                                    Sexp goldTree)
Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to its output chart file. The specified filename must point to a valid Java object file that contains two objects: a Chart object and a SexpList object (in that order), where the SexpList object is the list of the original words in the parsed sentence (which is the original sentence, but with potentially certain words removed after preprocessing). This method is intended to be used for off-line debugging (i.e., after a parsing run during which chart object files were created).

Parameters:
chartFilename - the filename of a parser chart file, which is a Java object file containing two serialized objects: a Chart object and a SexpList object
goldTree - the gold-standard parse tree, as found in the original combined file directory of the Penn Treebank, except with its outer parentheses removed

findConstituents

public static void findConstituents(boolean downcaseWords,
                                    Chart chart,
                                    CKYItem topRankedItem,
                                    SexpList sentence,
                                    Sexp goldTree)
Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to the specified chart. This method is intended to be used for on-line parser debugging (that is, debugging during a decoding run). The only functional difference between this method and findConstituents(String,Sexp) is that this method does not print out the original words of the sentence, as that can be separately accomplished during decoding by setting Decoder.debugInit to true.

Parameters:
chart - the chart of the parser, after processing the sentence to be analyzed
goldTree - the gold-standard parse tree, as found in the original combined directory of the Penn Treebank, except with its outer parentheses removed

findConstituents

public static void findConstituents(String prefix,
                                    boolean downcaseWords,
                                    Chart chart,
                                    CKYItem topRankedItem,
                                    SexpList sentence,
                                    Sexp goldTree)
Prints out to System.err which constituents of the specified gold-standard parse tree were found by the parser, according to the specified chart. This method is intended to be used for on-line parser debugging (that is, debugging during a decoding run). The only functional difference between this method and findConstituents(String,Sexp) is that this method does not print out the original words of the sentence, as that can be separately accomplished during decoding by setting Decoder.debugInit to true.

Parameters:
prefix - the prefix string to be output before other information on lines that don't begin with a tab character
chart - the chart of the parser, after processing the sentence to be analyzed
goldTree - the gold-standard parse tree, as found in the original combined directory of the Penn Treebank, except with its outer parentheses removed

replaceWords

public static void replaceWords(boolean downcaseWords,
                                Sexp tree,
                                SexpList sentence)

printBestDerivationStats

public static void printBestDerivationStats(String prefix,
                                            Chart chart,
                                            int sentLen,
                                            Symbol topSym,
                                            double nonTopHighestLogProb,
                                            CKYItem bestDerivationItem)

findConstituents

public static void findConstituents(Chart chart,
                                    Set best,
                                    HeadTreeNode tree)

findConstituents

public static void findConstituents(String prefix,
                                    Chart chart,
                                    Set best,
                                    HeadTreeNode tree)

collectBest

public static Set collectBest(CKYItem topRanked)

headTreeNodeToString

public static String headTreeNodeToString(HeadTreeNode node)
Returns a string of the form [start,end,label<headWord>, <headChild>] where <headWord> is the head word and where <headChild> is either a string of the form [start,end,label] or null if the specified HeadTreeNode is a preterminal.

Returns:
a string representation of the specified node

itemToString

public static String itemToString(CKYItem item,
                                  Set best)

itemToString

public static String itemToString(CKYItem item)

downcaseWords

public static void downcaseWords(Sexp tree)

downcaseWords

public static void downcaseWords(HeadTreeNode tree)

removePreterms

public static Sexp removePreterms(SexpList words,
                                  Sexp tree,
                                  int wordIdx)
Removes preterminals from the specified tree that are not found in the specified list of words.

Parameters:
words - the words of the sentence that was parsed (meaning that some of the words of the original sentence may have been pruned)
tree - the parse tree whose preterminals are to match words
wordIdx - the threaded word index; to be 0 for all non-recursive calls
Returns:
the modified tree

removeChildlessNodes

public static Sexp removeChildlessNodes(Sexp tree)
Removes interior nodes of the specified tree that are not preterminals and that have no children.

Parameters:
tree - the tree from which to remove childless interior nodes
Returns:
the modified tree

printDerivation

public static void printDerivation(CKYItem item)
Prints the derivation rooted at the specified chart item to System.err.


printDerivation

public static void printDerivation(CKYItem item,
                                   Filter filter)

Parsing Engine

Author: Dan Bikel.