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 AbstractBottomUpParser
chunker, COMPLETE, CONT, createDerivationString, defaultAdvancePercentage, defaultBeamSize, headRules, INC_NODE, INCOMPLETE, K, M, OTHER, punctSet, Q, reportFailedParse, START, tagger, TOK_NODE, TOP_NODE -
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. -
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 theAbstractBottomUpParser.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 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.advancePercentage- The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the topadvancePercentagewill be explored.- Throws:
IllegalStateException- Thrown if theParserTypeis not supported.- See Also:
-
Parser
Instantiates aParservia a givenmodel. Uses the default implementations ofPOSTaggerMEandChunkerMEand default values forbeamSizeandadvancePercentage.- Parameters:
model- TheParserModelto use.- Throws:
IllegalStateException- Thrown if theParserTypeis not supported.- 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 theAbstractBottomUpParser.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.
-