Class POSTaggerNameFeatureGenerator

java.lang.Object
opennlp.tools.util.featuregen.POSTaggerNameFeatureGenerator
All Implemented Interfaces:
opennlp.tools.util.featuregen.AdaptiveFeatureGenerator

@ThreadSafe public class POSTaggerNameFeatureGenerator extends Object implements opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
Adds the token POS tag as feature. Requires a POSTagger at runtime.

The "is this still the same sentence?" cache (a String[] of POS tags reused across the tokens of one sentence) is held per-thread via ThreadLocal, so a single instance is safe to share across multiple threads — for example when the enclosing NameFinderME is shared. Cache identity uses Arrays.equals(Object[], Object[]) (content equality), preserving the original single-threaded semantics.

See Also:
  • AdaptiveFeatureGenerator
  • POSTagger
  • POSModel
  • Constructor Details

    • POSTaggerNameFeatureGenerator

      public POSTaggerNameFeatureGenerator(opennlp.tools.postag.POSTagger aPosTagger)
      Initializes a POSTaggerNameFeatureGenerator with the specified POSTagger.
      Parameters:
      aPosTagger - A POSTagger instance to be used.
    • POSTaggerNameFeatureGenerator

      public POSTaggerNameFeatureGenerator(POSModel aPosModel)
      Initializes a POSTaggerNameFeatureGenerator with the specified POSModel.
      Parameters:
      aPosModel - A POSModel to be used for the internal POSTagger.
  • Method Details

    • createFeatures

      public void createFeatures(List<String> feats, String[] toks, int index, String[] preds)
      Specified by:
      createFeatures in interface opennlp.tools.util.featuregen.AdaptiveFeatureGenerator