BagOfWordsFeatureGenerator (Apache OpenNLP Tools 1.9.5 API)
Date: 2026-06-18

opennlp.tools.doccat

## Class BagOfWordsFeatureGenerator

- java.lang.Object
- - opennlp.tools.doccat.BagOfWordsFeatureGenerator

- All Implemented Interfaces:
    FeatureGenerator

      public class BagOfWordsFeatureGenerator
      extends Object
      implements FeatureGenerator

  Generates a feature for each word in a document.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BagOfWordsFeatureGenerator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<String>` | `extractFeatures(String[] text, Map<String,Object> extraInformation)` Extract features from given text fragments

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### BagOfWordsFeatureGenerator

          public BagOfWordsFeatureGenerator()

  - ### Method Detail

    - #### extractFeatures

          public Collection<String> extractFeatures(String[] text,
                                                    Map<String,Object> extraInformation)

      Description copied from interface: `FeatureGenerator`
      Extract features from given text fragments
      Specified by:
        `extractFeatures` in interface `FeatureGenerator`
      Parameters:
        `text` - the text fragments to extract features from
        `extraInformation` - optional extra information to be used by the feature generator
      Returns:
        a collection of features

Copyright © 2026 The Apache Software Foundation. All rights reserved.