edu.stanford.nlp.parser.lexparser
Class ExhaustivePCFGParser

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser
All Implemented Interfaces:
Scorer
Direct Known Subclasses:
IterativeCKYPCFGParser

public class ExhaustivePCFGParser
extends Object
implements Scorer

An exhaustive generalized CKY PCFG parser. Fairly carefully optimized to be fast.

Author:
Dan Klein

Field Summary
protected  int arraySize
           
protected  float bestScore
           
protected  BinaryGrammar bg
           
protected static boolean dumpTagging
           
protected  boolean floodTags
           
protected  String goalStr
           
protected  boolean[][] iPossibleByL
           
protected  boolean[][] iPossibleByR
           
protected  float[][][] iScore
           
protected  boolean[] isTag
           
protected  int length
           
protected  Lexicon lex
           
protected  LatticeReader lr
           
protected  int myMaxLength
           
protected  int[][] narrowLExtent
           
protected  int[][] narrowRExtent
           
protected  int numStates
           
protected  boolean[][] oFilteredEnd
           
protected  boolean[][] oFilteredStart
           
protected  Options op
           
protected  boolean[][] oPossibleByL
           
protected  boolean[][] oPossibleByR
           
protected  edu.stanford.nlp.parser.lexparser.OutsideRuleFilter orf
           
protected  float[][][] oScore
           
protected  List sentence
           
protected static boolean spillGuts
           
protected  Numberer stateNumberer
           
protected  String stateSpace
           
protected  Numberer tagNumberer
           
protected  boolean[][] tags
           
protected  TreeFactory tf
           
protected  TreebankLanguagePack tlp
           
protected  UnaryGrammar ug
           
protected  int[][] wideLExtent
           
protected  int[][] wideRExtent
           
protected  Numberer wordNumberer
           
protected  int[] words
           
protected  int[][][] wordsInSpan
           
 
Constructor Summary
ExhaustivePCFGParser(BinaryGrammar bg, UnaryGrammar ug, Lexicon lex, Options op)
           
 
Method Summary
protected  void buildOFilter()
           
protected  void createArrays(int length)
           
protected  Tree extractBestParse(int goal, int start, int end)
           
protected  List<Tree> extractBestParses(int goal, int start, int end)
          Return all best parses (except no ties allowed on POS tags?).
 Tree getBestParse()
           
 List<Tree> getBestParses()
          Return the set of trees that are tied best parses for a sentences.
 double getLogScore()
           
 boolean hasParse()
           
 boolean iPossible(edu.stanford.nlp.parser.lexparser.Hook hook)
           
 boolean iPossibleL(int state, int start)
           
 boolean iPossibleR(int state, int end)
           
 double iScore(Edge edge)
           
protected static boolean matches(double x, double y)
           
 void nudgeDownArraySize()
           
 boolean oPossible(edu.stanford.nlp.parser.lexparser.Hook hook)
           
 boolean oPossibleL(int state, int start)
           
 boolean oPossibleR(int state, int end)
           
 double oScore(Edge edge)
           
 boolean parse(LatticeReader lr)
           
 boolean parse(List sentence)
           
protected  void restoreUnaries(Tree t)
           
 double scoreBinarizedTree(Tree tree, int start)
           
 Tree scoreNonBinarizedTree(Tree tree)
           
 void setGoalString(String goalStr)
           
protected static void tick(String str)
           
 double validateBinarizedTree(Tree tree, int start)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

goalStr

protected String goalStr

stateSpace

protected String stateSpace

stateNumberer

protected Numberer stateNumberer

wordNumberer

protected Numberer wordNumberer

tagNumberer

protected Numberer tagNumberer

tf

protected TreeFactory tf

bg

protected BinaryGrammar bg

ug

protected UnaryGrammar ug

lex

protected Lexicon lex

op

protected Options op

tlp

protected TreebankLanguagePack tlp

orf

protected edu.stanford.nlp.parser.lexparser.OutsideRuleFilter orf

iScore

protected float[][][] iScore

oScore

protected float[][][] oScore

bestScore

protected float bestScore

wordsInSpan

protected int[][][] wordsInSpan

oFilteredStart

protected boolean[][] oFilteredStart

oFilteredEnd

protected boolean[][] oFilteredEnd

iPossibleByL

protected boolean[][] iPossibleByL

iPossibleByR

protected boolean[][] iPossibleByR

oPossibleByL

protected boolean[][] oPossibleByL

oPossibleByR

protected boolean[][] oPossibleByR

words

protected int[] words

length

protected int length

tags

protected boolean[][] tags

myMaxLength

protected int myMaxLength

numStates

protected int numStates

arraySize

protected int arraySize

spillGuts

protected static final boolean spillGuts
See Also:
Constant Field Values

dumpTagging

protected static final boolean dumpTagging
See Also:
Constant Field Values

floodTags

protected boolean floodTags

sentence

protected List sentence

lr

protected LatticeReader lr

narrowLExtent

protected int[][] narrowLExtent

wideLExtent

protected int[][] wideLExtent

narrowRExtent

protected int[][] narrowRExtent

wideRExtent

protected int[][] wideRExtent

isTag

protected boolean[] isTag
Constructor Detail

ExhaustivePCFGParser

public ExhaustivePCFGParser(BinaryGrammar bg,
                            UnaryGrammar ug,
                            Lexicon lex,
                            Options op)
Method Detail

setGoalString

public void setGoalString(String goalStr)

oScore

public double oScore(Edge edge)
Specified by:
oScore in interface Scorer

iScore

public double iScore(Edge edge)
Specified by:
iScore in interface Scorer

oPossible

public boolean oPossible(edu.stanford.nlp.parser.lexparser.Hook hook)
Specified by:
oPossible in interface Scorer

iPossible

public boolean iPossible(edu.stanford.nlp.parser.lexparser.Hook hook)
Specified by:
iPossible in interface Scorer

oPossibleL

public boolean oPossibleL(int state,
                          int start)

oPossibleR

public boolean oPossibleR(int state,
                          int end)

iPossibleL

public boolean iPossibleL(int state,
                          int start)

iPossibleR

public boolean iPossibleR(int state,
                          int end)

buildOFilter

protected void buildOFilter()

validateBinarizedTree

public double validateBinarizedTree(Tree tree,
                                    int start)

scoreNonBinarizedTree

public Tree scoreNonBinarizedTree(Tree tree)

scoreBinarizedTree

public double scoreBinarizedTree(Tree tree,
                                 int start)

tick

protected static void tick(String str)

parse

public boolean parse(List sentence)
Specified by:
parse in interface Scorer

parse

public boolean parse(LatticeReader lr)

hasParse

public boolean hasParse()

getLogScore

public double getLogScore()

matches

protected static boolean matches(double x,
                                 double y)

extractBestParse

protected Tree extractBestParse(int goal,
                                int start,
                                int end)

restoreUnaries

protected void restoreUnaries(Tree t)

getBestParse

public Tree getBestParse()

extractBestParses

protected List<Tree> extractBestParses(int goal,
                                       int start,
                                       int end)
Return all best parses (except no ties allowed on POS tags?). Note that the returned tree may be missing intermediate nodes in a unary chain because it parses with a unary-closed grammar.


getBestParses

public List<Tree> getBestParses()
Return the set of trees that are tied best parses for a sentences.


nudgeDownArraySize

public void nudgeDownArraySize()

createArrays

protected void createArrays(int length)


Stanford NLP Group