public class ExhaustivePCFGParser extends Object implements Scorer, KBestViterbiParser
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
ExhaustivePCFGParser(BinaryGrammar bg,
UnaryGrammar ug,
Lexicon lex,
Options op,
Index<String> stateIndex,
Index<String> wordIndex,
Index<String> tagIndex) |
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
initializePossibles()
These arrays are used by the factored parser (only) during edge combination.
|
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) |
protected final String goalStr
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 final 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
public ExhaustivePCFGParser(BinaryGrammar bg, UnaryGrammar ug, Lexicon lex, Options op, Index<String> stateIndex, Index<String> wordIndex, Index<String> tagIndex)
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 double scoreBinarizedTree(Tree tree, int start)
protected void tick(String str)
public boolean parse(List<? extends HasWord> sentence)
Parser
S
).public boolean parse(HTKLatticeReader lr)
public boolean parse(Lattice lr)
protected void initializePossibles()
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 returnpublic List<ScoredObject<Tree>> getKSampledParses(int k)
getKSampledParses
in interface KBestViterbiParser
k
- The number of sampled parses to returnpublic List<ScoredObject<Tree>> getKBestParses(int k)
getKBestParses
in interface KBestViterbiParser
k
- The number of best parses to returnpublic List<ScoredObject<Tree>> getBestParses()
getBestParses
in interface KBestViterbiParser
protected List<ParserConstraint> getConstraints()
public void nudgeDownArraySize()
protected void createArrays(int length)