Class Parser
java.lang.Object
opennlp.tools.parser.AbstractBottomUpParser
opennlp.tools.parser.treeinsert.Parser
- All Implemented Interfaces:
Parser
A built-attach
Parser implementation.
Nodes are built when their left-most child is encountered. Subsequent children are attached as daughters. Attachment is based on node in the right-frontier of the tree. After each attachment or building, nodes are assessed as either complete or incomplete. Complete nodes are no longer eligible for daughter attachment.
Complex modifiers which produce additional node levels of the same type are attached with sister-adjunction. Attachment can not take place higher in the right-frontier than an incomplete node.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]static final StringOutcome used when a node should be attached as a daughter to another node.static final StringOutcome used when a node should be attached as a sister to another node.private final AttachContextGeneratorprivate final int[]private final MaxentModelprivate final double[]private final BuildContextGeneratorprivate final MaxentModelstatic final StringLabel used to distinguish build nodes from non-built nodes.(package private) static booleanprivate final CheckContextGeneratorprivate final MaxentModelprivate final intprivate double[]private final intstatic final StringOutcome used when a constituent needs an no additional parent node/building.private final intprivate static final org.slf4j.Loggerstatic final StringOutcome used when a node should not be attached to another node.private final intprivate 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 attachModel, 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[]advanceChunks(Parse p, double minChunkScore) Returns the top chunk sequences for the specifiedParse.protected 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.getRightFrontier(Parse root, Set<String> punctSet) Returns the right frontier of the specifiedtreewith nodes ordered from deepest to shallowest.private booleanprivate booleanisComplete(Parse p) private voidprivate voidsetComplete(Parse p) private voidstatic ParserModeltrain(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, int iterations, int cutoff) Starts a training of aParserModel.static ParserModeltrain(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, TrainingParameters mlParams) Starts a training of aParserModel.Methods inherited from class AbstractBottomUpParser
advanceTags, buildDictionary, buildDictionary, collapsePunctuation, mapParseIndex, parse, parse, setErrorReporting, setParents
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
DONE
Outcome used when a constituent needs an no additional parent node/building.- See Also:
-
ATTACH_SISTER
Outcome used when a node should be attached as a sister to another node.- See Also:
-
ATTACH_DAUGHTER
Outcome used when a node should be attached as a daughter to another node.- See Also:
-
NON_ATTACH
Outcome used when a node should not be attached to another node.- See Also:
-
BUILT
Label used to distinguish build nodes from non-built nodes.- See Also:
-
buildModel
-
attachModel
-
checkModel
-
checkComplete
static boolean checkComplete -
buildContextGenerator
-
attachContextGenerator
-
checkContextGenerator
-
bprobs
private final double[] bprobs -
aprobs
private final double[] aprobs -
cprobs
private double[] cprobs -
doneIndex
private final int doneIndex -
sisterAttachIndex
private final int sisterAttachIndex -
daughterAttachIndex
private final int daughterAttachIndex -
nonAttachIndex
private final int nonAttachIndex -
completeIndex
private final int completeIndex -
attachments
private final int[] attachments
-
-
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 attachModel, 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
-
getRightFrontier
-
setBuilt
-
setComplete
-
setIncomplete
-
isBuilt
-
isComplete
-
advanceChunks
Description copied from class:AbstractBottomUpParserReturns the top chunk sequences for the specifiedParse.- Overrides:
advanceChunksin classAbstractBottomUpParser- Parameters:
p- A pos-tag assignedParse.minChunkScore- A minimum score below which chunks should not be advanced.- Returns:
- The top chunk assignments to the specified
Parse.
-
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.
-
advanceTop
Description copied from class:AbstractBottomUpParserAdds theAbstractBottomUpParser.TOP_NODEto the specified parse.- Specified by:
advanceTopin classAbstractBottomUpParser- Parameters:
p- The completeParse.
-
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.
-
train
public static ParserModel train(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, int iterations, int cutoff) throws IOException Starts a training of aParserModel.- Parameters:
languageCode- An ISO conform language code.parseSamples- Thesamplesas input.rules- TheHeadRulesto use.iterations- The number of iterations to be conducted.cutoff- The cut-off parameter to be used.- Returns:
- A valid
ParserModel. - Throws:
IOException- Thrown if IO errors occurred during training.
-