|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser
public class ExhaustivePCFGParser
An exhaustive generalized CKY PCFG parser.
Fairly carefully optimized to be fast.
If reusing this object for multiple parses, remember to correctly
set any options such as the constraints field.
Field Summary | |
---|---|
protected int |
arraySize
|
protected float |
bestScore
|
protected BinaryGrammar |
bg
|
protected List<ParserConstraint> |
constraints
When you want to force the parser to parse a particular subsequence into a particular state. |
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 Lattice |
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 OutsideRuleFilter |
orf
|
protected float[][][] |
oScore
|
protected List |
sentence
|
protected Index<String> |
stateIndex
|
protected Index<String> |
tagIndex
|
protected boolean[][] |
tags
|
protected TreeFactory |
tf
|
protected TreebankLanguagePack |
tlp
|
protected UnaryGrammar |
ug
|
protected int[][] |
wideLExtent
|
protected int[][] |
wideRExtent
|
protected Index<String> |
wordIndex
|
protected int[] |
words
|
protected int[][][] |
wordsInSpan
|
Constructor Summary | |
---|---|
ExhaustivePCFGParser(BinaryGrammar bg,
UnaryGrammar ug,
Lexicon lex,
Options op,
Index<String> stateIndex,
Index<String> wordIndex,
Index<String> tagIndex)
|
Method Summary | |
---|---|
protected void |
buildOFilter()
|
protected void |
createArrays(int length)
|
protected Tree |
extractBestParse(String goalStr,
int start,
int end)
Return the best parse of some category/state over a certain span. |
protected List<Tree> |
extractBestParses(int goal,
int start,
int end)
Return all best parses (except no ties allowed on POS tags?). |
Tree |
getBestParse()
Returns a best parse of the last sentence on which parse was
called, or null if none exists. |
List<ScoredObject<Tree>> |
getBestParses()
Get a complete set of the maximally scoring parses for a sentence, rather than one chosen at random. |
double |
getBestScore()
Gets the score (typically a log probability) of the best parse of a sentence. |
double |
getBestScore(String stateName)
|
protected List<ParserConstraint> |
getConstraints()
|
List<ScoredObject<Tree>> |
getKBestParses(int k)
Get the exact k best parses for the sentence. |
List<ScoredObject<Tree>> |
getKGoodParses(int k)
Get k good parses for the sentence. |
List<ScoredObject<Tree>> |
getKSampledParses(int k)
Get k parse samples for the sentence. |
boolean |
hasParse()
Does the sentence in the last call to parse() have a parse? In theory this method shouldn't be here, but it seemed a convenient place to put it for our more general parser interface. |
boolean |
iPossible(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(Hook hook)
|
boolean |
oPossibleL(int state,
int start)
|
boolean |
oPossibleR(int state,
int end)
|
double |
oScore(Edge edge)
|
boolean |
parse(HTKLatticeReader lr)
|
boolean |
parse(Lattice lr)
|
boolean |
parse(List<? extends HasWord> sentence)
Parses the given sentence. |
double |
scoreBinarizedTree(Tree tree,
int start)
|
Tree |
scoreNonBinarizedTree(Tree tree)
|
protected 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 |
---|
protected final String goalStr
protected final Index<String> stateIndex
protected final Index<String> wordIndex
protected final Index<String> tagIndex
protected final TreeFactory tf
protected final BinaryGrammar bg
protected final UnaryGrammar ug
protected final Lexicon lex
protected final Options op
protected final TreebankLanguagePack tlp
protected OutsideRuleFilter orf
protected float[][][] iScore
protected float[][][] oScore
protected float bestScore
protected int[][][] wordsInSpan
protected boolean[][] oFilteredStart
protected boolean[][] oFilteredEnd
protected boolean[][] iPossibleByL
protected boolean[][] iPossibleByR
protected boolean[][] oPossibleByL
protected boolean[][] oPossibleByR
protected int[] words
protected int length
protected boolean[][] tags
protected int myMaxLength
protected int numStates
protected int arraySize
protected List<ParserConstraint> constraints
protected boolean floodTags
protected List sentence
protected Lattice lr
protected int[][] narrowLExtent
protected int[][] wideLExtent
protected int[][] narrowRExtent
protected int[][] wideRExtent
protected final boolean[] isTag
Constructor Detail |
---|
public ExhaustivePCFGParser(BinaryGrammar bg, UnaryGrammar ug, Lexicon lex, Options op, Index<String> stateIndex, Index<String> wordIndex, Index<String> tagIndex)
Method Detail |
---|
public double oScore(Edge edge)
oScore
in interface Scorer
public double iScore(Edge edge)
iScore
in interface Scorer
public boolean oPossible(Hook hook)
oPossible
in interface Scorer
public boolean iPossible(Hook hook)
iPossible
in interface Scorer
public boolean oPossibleL(int state, int start)
public boolean oPossibleR(int state, int end)
public boolean iPossibleL(int state, int start)
public boolean iPossibleR(int state, int end)
protected void buildOFilter()
public double validateBinarizedTree(Tree tree, int start)
public Tree scoreNonBinarizedTree(Tree tree)
public double scoreBinarizedTree(Tree tree, int start)
protected void tick(String str)
public boolean parse(List<? extends HasWord> sentence)
Parser
S
).
parse
in interface Scorer
parse
in interface Parser
sentence
- A List<HasWord>
to be parsed
public boolean parse(HTKLatticeReader lr)
public boolean parse(Lattice lr)
public boolean hasParse()
KBestViterbiParser
hasParse
in interface KBestViterbiParser
protected static boolean matches(double x, double y)
public double getBestScore()
KBestViterbiParser
getBestScore
in interface KBestViterbiParser
public double getBestScore(String stateName)
public Tree getBestParse()
ViterbiParser
parse
was
called, or null if none exists.
getBestParse
in interface ViterbiParser
protected Tree extractBestParse(String goalStr, int start, int end)
protected List<Tree> extractBestParses(int goal, int start, int end)
public List<ScoredObject<Tree>> getKGoodParses(int k)
getKGoodParses
in interface KBestViterbiParser
k
- The number of good parses to return
public List<ScoredObject<Tree>> getKSampledParses(int k)
getKSampledParses
in interface KBestViterbiParser
k
- The number of sampled parses to return
public List<ScoredObject<Tree>> getKBestParses(int k)
getKBestParses
in interface KBestViterbiParser
k
- The number of best parses to return
public List<ScoredObject<Tree>> getBestParses()
getBestParses
in interface KBestViterbiParser
protected List<ParserConstraint> getConstraints()
public void nudgeDownArraySize()
protected void createArrays(int length)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |