opennlp.tools.parser
Class AbstractContextGenerator

java.lang.Object
  extended by 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 Summary
protected static String EOS
           
protected  Set<String> punctSet
          Set of punctuation to be used in generating features.
protected  boolean useLabel
           
protected  boolean zeroBackOff
           
 
Constructor Summary
AbstractContextGenerator()
           
 
Method Summary
protected  void checkcons(Parse p1, Parse p2, String type, List<String> features)
           
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 specfied list.
protected  String cons(Parse p, int i)
           
protected  void cons2(List<String> features, Cons c0, Cons c1, Collection<Parse> punct1s, boolean bigram)
           
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.
protected  String consbo(Parse p, int i)
           
protected  void getFrontierNodes(List<Parse> rf, Parse[] nodes)
          Populates specified nodes array with left-most right frontier node with a unique head.
protected  String production(Parse p, boolean includePunctuation)
          Generates a string representing the grammar rule production that the specified parse is starting.
protected  String punct(Parse punct, int i)
          Creates punctuation feature for the specified punctuation at the specified index based on the punctuation mark.
protected  String punctbo(Parse punct, int i)
          Creates punctuation feature for the specified punctuation at the specfied index based on the punctuation's tag.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOS

protected static final String EOS
See Also:
Constant Field Values

zeroBackOff

protected boolean zeroBackOff

punctSet

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


useLabel

protected boolean useLabel
Constructor Detail

AbstractContextGenerator

public AbstractContextGenerator()
Method Detail

punct

protected String punct(Parse punct,
                       int i)
Creates punctuation feature for the specified punctuation at the specified index 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 specified parse and the specified punctuation at the specfied index.

punctbo

protected String punctbo(Parse punct,
                         int i)
Creates punctuation feature for the specified punctuation at the specfied index 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 specified parse and the specified punctuation at the specfied 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 -> c.children[0..n].type.

Parameters:
p - The parse which stats teh 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 the first and second node.
punct2s - The punctuation between the second and third node.
trigram - Specifies whether lexical tri-gram features between these nodes should be generated.
bigram1 - Specifies whether lexical bi-gram features between the first and second node should be generated.
bigram2 - Specifies whether lexical bi-gram features between the second and third node 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 specfied list.

Parameters:
child - The parse 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.


Copyright © 2010. All Rights Reserved.