Class AbstractContextGenerator

java.lang.Object
opennlp.tools.parser.AbstractContextGenerator
Direct Known Subclasses:
AttachContextGenerator, BuildContextGenerator, BuildContextGenerator, CheckContextGenerator, CheckContextGenerator

public abstract class AbstractContextGenerator extends Object
Abstract class containing many of the methods used to generate contexts for parsing.
  • Field Details

    • EOS

      protected static final String EOS
      See Also:
    • zeroBackOff

      protected boolean zeroBackOff
    • punctSet

      protected Set<String> punctSet
      Set of punctuation to be used in generating features.
    • useLabel

      protected boolean useLabel
  • Constructor Details

    • AbstractContextGenerator

      public AbstractContextGenerator()
  • Method Details

    • punct

      protected String punct(Parse punct, int i)
      Creates punctuation feature for the specified punctuation at the specified index i based on the punctuation mark.
      Parameters:
      punct - The punctuation which is in context.
      i - The index of the punctuation with relative to the parse.
      Returns:
      Punctuation feature for the parse and the punctuation at the specified index.
    • punctbo

      protected String punctbo(Parse punct, int i)
      Creates punctuation feature for the specified punctuation at the specified index i based on the punctuation's tag.
      Parameters:
      punct - The punctuation which is in context.
      i - The index of the punctuation relative to the parse.
      Returns:
      Punctuation feature for the parse and the punctuation at the specified index.
    • cons

      protected String cons(Parse p, int i)
    • consbo

      protected String consbo(Parse p, int i)
    • production

      protected String production(Parse p, boolean includePunctuation)
      Generates a string representing the grammar rule production that the specified parse is starting.

      The rule is of the form p.type -&gt; c.children[0..n].type.

      Parameters:
      p - The Parse which 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

      protected void cons2(List<String> features, Cons c0, Cons c1, Collection<Parse> punct1s, boolean bigram)
    • 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 first node.
      c1 - The second node.
      c2 - The third node.
      punct1s - The punctuation between c0 and c1.
      punct2s - The punctuation between c1 and c2.
      trigram - Specifies whether lexical tri-gram features between these nodes should be generated.
      bigram1 - Specifies whether lexical bi-gram features between c0 and c1 should be generated.
      bigram2 - Specifies whether lexical bi-gram features between c1 and c2 should 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 specified type.
      Parameters:
      node - A surrounding node.
      i - The index of the surrounding node with 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

      protected void checkcons(Parse child, String i, String type, List<String> features)
      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 - The node to 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

      protected void checkcons(Parse p1, Parse p2, String type, List<String> features)
    • getFrontierNodes

      protected void getFrontierNodes(List<Parse> rf, Parse[] nodes)
      Populates specified nodes array with left-most right frontier node with a unique head. If the right frontier doesn't contain enough nodes, then nulls are placed in the array elements.
      Parameters:
      rf - The current right frontier.
      nodes - The array to be populated.