Class AbstractContextGenerator
java.lang.Object
opennlp.tools.parser.AbstractContextGenerator
- Direct Known Subclasses:
AttachContextGenerator, BuildContextGenerator, BuildContextGenerator, CheckContextGenerator, CheckContextGenerator
Abstract class containing many of the methods used to generate contexts for parsing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidProduces features to determine whether the specified child node is part of a complete constituent of the specified type and adds those features to the specified list.protected voidprotected Stringprotected voidprotected voidcons3(List<String> features, Cons c0, Cons c1, Cons c2, Collection<Parse> punct1s, Collection<Parse> punct2s, boolean trigram, boolean bigram1, boolean bigram2) Creates cons features involving the 3 specified nodes and adds them to the specified feature list.protected Stringprotected voidgetFrontierNodes(List<Parse> rf, Parse[] nodes) Populates specified nodes array with left-most right frontier node with a unique head.protected Stringproduction(Parse p, boolean includePunctuation) Generates a string representing the grammar rule production that the specified parse is starting.protected StringCreates punctuation feature for the specified punctuation at the specified indexibased on thepunctuationmark.protected StringCreates punctuation feature for the specified punctuation at the specified indexibased on thepunctuation's tag.protected voidGenerates features for nodes surrounding a completed node of the specifiedtype.
-
Field Details
-
EOS
- See Also:
-
zeroBackOff
protected boolean zeroBackOff -
punctSet
-
useLabel
protected boolean useLabel
-
-
Constructor Details
-
AbstractContextGenerator
public AbstractContextGenerator()
-
-
Method Details
-
punct
Creates punctuation feature for the specified punctuation at the specified indexibased on thepunctuationmark.- Parameters:
punct- The punctuation which is in context.i- The index of thepunctuationwith relative to the parse.- Returns:
- Punctuation feature for the parse and the punctuation at the specified index.
-
punctbo
Creates punctuation feature for the specified punctuation at the specified indexibased on thepunctuation's tag.- Parameters:
punct- The punctuation which is in context.i- The index of thepunctuationrelative to the parse.- Returns:
- Punctuation feature for the parse and the punctuation at the specified index.
-
cons
-
consbo
-
production
Generates a string representing the grammar rule production that the specified parse is starting.The rule is of the form
p.type -> c.children[0..n].type.- Parameters:
p- TheParsewhich stats the production.includePunctuation- Whether punctuation should be included in the production.- Returns:
- A string representing the grammar rule production that the specified parse is starting.
-
cons2
-
cons3
protected void cons3(List<String> features, Cons c0, Cons c1, Cons c2, Collection<Parse> punct1s, Collection<Parse> punct2s, boolean trigram, boolean bigram1, boolean bigram2) Creates cons features involving the 3 specified nodes and adds them to the specified feature list.- Parameters:
features- The list of features.c0- The firstnode.c1- The secondnode.c2- The thirdnode.punct1s- The punctuation betweenc0andc1.punct2s- The punctuation betweenc1andc2.trigram- Specifies whether lexical tri-gram features between these nodes should be generated.bigram1- Specifies whether lexical bi-gram features betweenc0andc1should be generated.bigram2- Specifies whether lexical bi-gram features betweenc1andc2should be generated.
-
surround
protected void surround(Parse node, int i, String type, Collection<Parse> punctuation, List<String> features) Generates features for nodes surrounding a completed node of the specifiedtype.- Parameters:
node- A surroundingnode.i- The index of the surroundingnodewith respect to the completed node.type- The type of the completed node.punctuation- The punctuation adjacent and between the specified surrounding node.features- A list to which features are added.
-
checkcons
Produces features to determine whether the specified child node is part of a complete constituent of the specified type and adds those features to the specified list.- Parameters:
child- Thenodeto consider.i- A string indicating the position of the child node.type- The type of constituent being built.features- List to add features to.
-
checkcons
-
getFrontierNodes
Populates specified nodes array with left-most right frontier node with a unique head. If the right frontier doesn't contain enough nodes, thennullsare placed in the array elements.- Parameters:
rf- The current right frontier.nodes- The array to be populated.
-