NGramFeatureGenerator (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.doccat, class: NGramFeatureGenerator

# Class NGramFeatureGenerator

java.lang.Object
opennlp.tools.doccat.NGramFeatureGenerator

All Implemented Interfaces:
  `FeatureGenerator`

public class NGramFeatureGenerator extends Object implements FeatureGenerator
Generates ngram features for a document.

See Also:
  - `FeatureGenerator`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NGramFeatureGenerator()`
  Instantiates an `NGramFeatureGenerator` instance with a Bi grams config.
  `NGramFeatureGenerator(int minGram, int maxGram)`
  Instantiates an `NGramFeatureGenerator` instance with configurable ngram parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Collection<String>`
  `extractFeatures(String[] text, Map<String,Object> extraInfo)`
  Extracts features from given `text` fragments.

  ### Methods inherited from class Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### NGramFeatureGenerator

    public NGramFeatureGenerator(int minGram, int maxGram) throws InvalidFormatException
    Instantiates an `NGramFeatureGenerator` instance with configurable ngram parameters.
    Parameters:
      `minGram` - The minimum words in ngram features.
      `maxGram` - The maximum words in ngram features.
    Throws:
      `InvalidFormatException` - Thrown if parameter values are invalid or inconsistent.

  - ### NGramFeatureGenerator

    public NGramFeatureGenerator() throws InvalidFormatException
    Instantiates an `NGramFeatureGenerator` instance with a Bi grams config.
    Throws:
      `InvalidFormatException` - Thrown if parameter values are invalid or inconsistent.

- ## Method Details

  - ### extractFeatures

    public Collection<String> extractFeatures(String[] text, Map<String,Object> extraInfo)
    Description copied from interface: `FeatureGenerator`
    Extracts features from given `text` fragments.
    Specified by:
      `extractFeatures` in interface `FeatureGenerator`
    Parameters:
      `text` - The text fragments to extract features from
      `extraInfo` - Optional extra information to be used by the `FeatureGenerator`.
    Returns:
      A collection of features.