Class AbstractBottomUpParser
java.lang.Object
opennlp.tools.parser.AbstractBottomUpParser
- All Implemented Interfaces:
opennlp.tools.parser.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 TypeFieldDescriptionstatic final StringOutcome used when a constituent is complete.static final StringPrefix for outcomes continuing a constituent.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.static final StringOutcome used when a constituent is incomplete.static final StringOutcome for token which is not contained in a basal constituent.static final StringPrefix for outcomes starting a constituent.Fields inherited from interface opennlp.tools.parser.Parser
INC_NODE, TOK_NODE, TOP_NODE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBottomUpParser(opennlp.tools.postag.POSTagger tagger, opennlp.tools.chunker.Chunker chunker, opennlp.tools.parser.HeadRules headRules, int beamSize, double advancePercentage) -
Method Summary
Modifier and TypeMethodDescriptionstatic DictionarybuildDictionary(opennlp.tools.util.ObjectStream<opennlp.tools.parser.Parse> data, opennlp.tools.parser.HeadRules rules, int cutoff) Creates a n-gramDictionaryfrom the specified data stream usingHeadRulesand specified cut-off.static DictionarybuildDictionary(opennlp.tools.util.ObjectStream<opennlp.tools.parser.Parse> data, opennlp.tools.parser.HeadRules rules, opennlp.tools.util.TrainingParameters params) Creates a n-gramDictionaryfrom the specified data stream using the specified head rule and specified cut-off.static opennlp.tools.parser.Parse[]collapsePunctuation(opennlp.tools.parser.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.opennlp.tools.parser.Parseparse(opennlp.tools.parser.Parse tokens) opennlp.tools.parser.Parse[]parse(opennlp.tools.parser.Parse tokens, int numParses) voidsetErrorReporting(boolean errorReporting) Specifies whether the parser should report when it was unable to find a parse for a particular sentence.static voidsetParents(opennlp.tools.parser.Parse p) Assigns parent references for the specified parse so that they are consistent with the children references.
-
Field Details
-
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:
-
START
-
CONT
-
OTHER
Outcome for token which is not contained in a basal constituent.- See Also:
-
COMPLETE
-
INCOMPLETE
-
-
Constructor Details
-
AbstractBottomUpParser
public AbstractBottomUpParser(opennlp.tools.postag.POSTagger tagger, opennlp.tools.chunker.Chunker chunker, opennlp.tools.parser.HeadRules headRules, int beamSize, double advancePercentage)
-
-
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
public static void setParents(opennlp.tools.parser.Parse p) Assigns parent references for the specified parse so that they are consistent with the children references.- Parameters:
p- TheParsewhose parent references need to be assigned.
-
collapsePunctuation
public static opennlp.tools.parser.Parse[] collapsePunctuation(opennlp.tools.parser.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.- Parameters:
chunks- A set ofparses.punctSet- The set of punctuation to be removed.- Returns:
- Array of
parseswhich is a subset of chunks with punctuation removed.
-
parse
public opennlp.tools.parser.Parse[] parse(opennlp.tools.parser.Parse tokens, int numParses) - Specified by:
parsein interfaceopennlp.tools.parser.Parser
-
parse
public opennlp.tools.parser.Parse parse(opennlp.tools.parser.Parse tokens) - Specified by:
parsein interfaceopennlp.tools.parser.Parser
-
buildDictionary
public static Dictionary buildDictionary(opennlp.tools.util.ObjectStream<opennlp.tools.parser.Parse> data, opennlp.tools.parser.HeadRules rules, opennlp.tools.util.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(opennlp.tools.util.ObjectStream<opennlp.tools.parser.Parse> data, opennlp.tools.parser.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
-