Package opennlp.tools.parser.chunking
Class Parser
java.lang.Object
opennlp.tools.parser.AbstractBottomUpParser
opennlp.tools.parser.chunking.Parser
- All Implemented Interfaces:
Parser
A shift reduce style
Parser implementation
based on Adwait Ratnaparkhi's 1998 thesis.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]private final BuildContextGeneratorprivate final MaxentModelprivate final CheckContextGeneratorprivate final MaxentModelprivate final intprivate final double[]private final intprivate static final org.slf4j.Loggerprivate static final Stringprivate final intFields inherited from class opennlp.tools.parser.AbstractBottomUpParser
chunker, COMPLETE, CONT, createDerivationString, defaultAdvancePercentage, defaultBeamSize, headRules, INCOMPLETE, K, M, OTHER, punctSet, Q, reportFailedParse, START, tagger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateParser(MaxentModel buildModel, MaxentModel checkModel, POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) Instantiates aParservia a givenmodeland other configuration parameters.Parser(ParserModel model) Instantiates aParservia a givenmodel.Parser(ParserModel model, int beamSize, double advancePercentage) Instantiates aParservia a givenmodeland other configuration parameters.Parser(ParserModel model, POSTagger tagger, Chunker chunker, int beamSize, double advancePercentage) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 voidadvanceTop(Parse p) Adds theParser.TOP_NODEto the specified parse.static voidstatic ParserModeltrain(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, TrainingParameters mlParams) Starts a training of aParserModel.Methods inherited from class opennlp.tools.parser.AbstractBottomUpParser
advanceChunks, advanceTags, buildDictionary, buildDictionary, collapsePunctuation, mapParseIndex, parse, parse, setErrorReporting, setParents
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
buildModel
-
checkModel
-
buildContextGenerator
-
checkContextGenerator
-
bprobs
private final double[] bprobs -
cprobs
private final double[] cprobs -
TOP_START
- See Also:
-
topStartIndex
private final int topStartIndex -
startTypeMap
-
contTypeMap
-
completeIndex
private final int completeIndex -
incompleteIndex
private final int incompleteIndex
-
-
Constructor Details
-
Parser
Instantiates aParservia a givenmodeland other configuration parameters. Uses the default implementations ofPOSTaggerMEandChunkerME.- Parameters:
model- TheParserModelto use.beamSize- The number of different parses kept during parsing. Must be at least1.advancePercentage- The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the topadvancePercentagewill be explored. Must be greater than0and at most1.- Throws:
IllegalArgumentException- Thrown ifmodelisnullor a parameter is out of range.- See Also:
-
Parser
public Parser(ParserModel model, POSTagger tagger, Chunker chunker, int beamSize, double advancePercentage) Instantiates aParservia a givenmodeland a caller-suppliedPOSTaggerandChunker. The build and check models and the head rules are taken frommodel; its tagger and chunker models are not used.- Parameters:
model- TheParserModelto use. Must not benull.tagger- ThePOSTaggerused to tag. Must not benull.chunker- TheChunkerused to chunk. Must not benull.beamSize- The number of different parses kept during parsing. Must be at least1.advancePercentage- The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the topadvancePercentagewill be explored. Must be greater than0and at most1.- Throws:
IllegalArgumentException- Thrown if a parameter isnullor out of range.- Since:
- 3.0.0
- See Also:
-
Parser
Instantiates aParservia a givenmodel. Uses the default implementations ofPOSTaggerMEandChunkerMEand default values forbeamSizeandadvancePercentage.- Parameters:
model- TheParserModelto use. Must not benull.- Throws:
IllegalArgumentException- Thrown ifmodelisnull.- See Also:
-
Parser
private Parser(MaxentModel buildModel, MaxentModel checkModel, POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) Instantiates aParservia a givenmodeland other configuration parameters.- Parameters:
buildModel- A validMaxentModelused to build.checkModel- A validMaxentModelused to check.tagger- A validPOSModelused to tag.chunker- A validChunkerModelused to chunk.headRules- TheHeadRulesfor head word percolation.beamSize- The number of different parses kept during parsing.advancePercentage- The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the topadvancePercentagewill be explored.- See Also:
-
-
Method Details
-
advanceTop
Description copied from class:AbstractBottomUpParserAdds theParser.TOP_NODEto the specified parse.- Specified by:
advanceTopin classAbstractBottomUpParser- Parameters:
p- The completeParse.
-
advanceParses
Description copied from class:AbstractBottomUpParserAdvances the specifiedParseand returns the an array advanced parses whose probability accounts for more than the specified amount of probability mass.- Specified by:
advanceParsesin classAbstractBottomUpParser- Parameters:
p- TheParseto advance.probMass- The amount of probability mass that should be accounted for by the advanced parses.
-
mergeReportIntoManifest
-
train
public static ParserModel train(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, TrainingParameters mlParams) throws IOException Starts a training of aParserModel.- Parameters:
languageCode- An ISO conform language code.parseSamples- Thesamplesas input.rules- TheHeadRulesto use.mlParams- Theparametersfor training.- Returns:
- A valid
ParserModel. - Throws:
IOException- Thrown if IO errors occurred during training.
-