Class AbstractBottomUpParser
java.lang.Object
opennlp.tools.parser.AbstractBottomUpParser
- All Implemented Interfaces:
Parser
Abstract class which contains code to tag and chunk parses for bottom up parsing and
leaves implementation of advancing parses and completing parses to extend class.
Note:
The nodes within the returned parses are shared with other parses
and therefore their parent node references will not be consistent with their child
node reference. setParents can be used to make the parents consistent
with a particular parse, but subsequent calls to setParents can invalidate
the results of earlier calls.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChunkerThe chunker that the parser uses to chunk non-recursive structures.static final StringOutcome used when a constituent is complete.static final StringPrefix for outcomes continuing a constituent.protected booleanSpecifies whether a derivation string should be created during parsing.static final doubleThe default amount of probability mass required of advanced outcomes.static final intThe default beam size used if no beam size is given.protected HeadRulesThe head rules for the parser.static final StringThe label for the top if an incomplete node.static final StringOutcome used when a constituent is incomplete.protected intThe maximum number of parses to advance from a single preceding parse.private static final org.slf4j.Loggerprotected intThe maximum number of parses advanced from all preceding parses at each derivation step.static final StringOutcome for token which is not contained in a basal constituent.The set strings which are considered punctuation for the parser.protected doubleThe minimum total probability mass of advanced outcomes.protected booleanSpecifies whether failed parses should be reported to standard error.static final StringPrefix for outcomes starting a constituent.protected POSTaggerThe pos-tagger that the parser uses.static final StringThe label for a token node.static final StringThe label for the top node. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBottomUpParser(POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) -
Method Summary
Modifier and TypeMethodDescriptionprotected Parse[]advanceChunks(Parse p, double minChunkScore) Returns the top chunk sequences for the specifiedParse.protected abstract Parse[]advanceParses(Parse p, double probMass) Advances the specifiedParseand returns the an array advanced parses whose probability accounts for more than the specified amount of probability mass.protected Parse[]advanceTags(Parse p) Advances theParseby assigning it POS tags and returns multiple tag sequences.protected abstract voidadvanceTop(Parse p) Adds theTOP_NODEto the specified parse.static DictionarybuildDictionary(ObjectStream<Parse> data, HeadRules rules, int cutoff) Creates a n-gramDictionaryfrom the specified data stream usingHeadRulesand specified cut-off.static DictionarybuildDictionary(ObjectStream<Parse> data, HeadRules rules, TrainingParameters params) Creates a n-gramDictionaryfrom the specified data stream using the specified head rule and specified cut-off.static Parse[]collapsePunctuation(Parse[] chunks, Set<String> punctSet) Removes the punctuation from the specified set ofchunks, adds it to the parses adjacent to the punctuation is specified, and returns a new array of parses with the punctuation removed.private static booleanprotected intmapParseIndex(int index, Parse[] nonPunctParses, Parse[] parses) Parse[]Returns the specified number of parses or fewer for the specified tokens.voidsetErrorReporting(boolean errorReporting) Specifies whether the parser should report when it was unable to find a parse for a particular sentence.static voidsetParents(Parse p) Assigns parent references for the specified parse so that they are consistent with the children references.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
M
protected int MThe maximum number of parses advanced from all preceding parses at each derivation step. -
K
protected int KThe maximum number of parses to advance from a single preceding parse. -
Q
protected double QThe minimum total probability mass of advanced outcomes. -
defaultBeamSize
public static final int defaultBeamSizeThe default beam size used if no beam size is given.- See Also:
-
defaultAdvancePercentage
public static final double defaultAdvancePercentageThe default amount of probability mass required of advanced outcomes.- See Also:
-
completeParses
-
odh
-
ndh
-
headRules
The head rules for the parser. -
punctSet
-
TOP_NODE
-
INC_NODE
-
TOK_NODE
-
START
-
CONT
-
OTHER
Outcome for token which is not contained in a basal constituent.- See Also:
-
COMPLETE
-
INCOMPLETE
-
tagger
The pos-tagger that the parser uses. -
chunker
The chunker that the parser uses to chunk non-recursive structures. -
reportFailedParse
protected boolean reportFailedParseSpecifies whether failed parses should be reported to standard error. -
createDerivationString
protected boolean createDerivationStringSpecifies whether a derivation string should be created during parsing. This is useful for debugging.
-
-
Constructor Details
-
AbstractBottomUpParser
-
-
Method Details
-
setErrorReporting
public void setErrorReporting(boolean errorReporting) Specifies whether the parser should report when it was unable to find a parse for a particular sentence.- Parameters:
errorReporting-trueif un-parsed sentences should be reported,falseotherwise.
-
setParents
-
collapsePunctuation
Removes the punctuation from the specified set ofchunks, adds it to the parses adjacent to the punctuation is specified, and returns a new array of parses with the punctuation removed. -
advanceParses
-
advanceTop
-
parse
Description copied from interface:ParserReturns the specified number of parses or fewer for the specified tokens.Note: The nodes within the returned parses are shared with other parses and therefore their parent node references will not be consistent with their child node reference.
Parse.setParent(Parse)can be used to make the parents consistent with a particular parse, but subsequent calls tosetParentscan invalidate the results of earlier calls. -
parse
Description copied from interface:Parser -
advanceChunks
-
advanceTags
-
mapParseIndex
-
lastChild
-
buildDictionary
public static Dictionary buildDictionary(ObjectStream<Parse> data, HeadRules rules, TrainingParameters params) throws IOException Creates a n-gramDictionaryfrom the specified data stream using the specified head rule and specified cut-off.- Parameters:
data- The data stream ofparses.rules- TheHeadRulesfor the parses.params- TheTrainingParameterswhich can contain acutoff, the minimum number of entries required for the n-gram to be saved as part of theDictionary.- Returns:
- A
Dictionaryinstance. - Throws:
IOException
-
buildDictionary
public static Dictionary buildDictionary(ObjectStream<Parse> data, HeadRules rules, int cutoff) throws IOException Creates a n-gramDictionaryfrom the specified data stream usingHeadRulesand specified cut-off.- Parameters:
data- The data stream ofparses.rules- TheHeadRulesfor theparses.cutoff- The minimum number of entries required for the n-gram to be saved as part of the dictionary.- Returns:
- A
Dictionaryinstance. - Throws:
IOException
-