Class FeatureGeneratorUtil

java.lang.Object
opennlp.tools.util.featuregen.FeatureGeneratorUtil

public class FeatureGeneratorUtil extends Object
This class provide common utilities for feature generation.
  • Field Details

  • Constructor Details

    • FeatureGeneratorUtil

      public FeatureGeneratorUtil()
  • Method Details

    • tokenFeature

      public static String tokenFeature(String token)
      Generates a class name for the specified token. The classes are as follows where the first matching class is used:
      • jah - Japanese Hiragana
      • jak - Japanese Katakana
      • lc - lowercase alphabetic
      • 2d - two digits
      • 4d - four digits
      • an - alpha-numeric
      • dd - digits and dashes
      • ds - digits and slashes
      • dc - digits and commas
      • dp - digits and periods
      • num - digits
      • sc - single capital letter
      • ac - all capital letters
      • cp - a single capital letter followed by a period
      • ic - initial capital letter
      • other - other
      Parameters:
      token - A token or word.
      Returns:
      The class name that the specified token belongs in.
    • isCapPeriod

      private static boolean isCapPeriod(String token)
      Tests for one uppercase code point followed by a period, and nothing else. Any script counts, including the supplementary planes. Under CompatibilityMode.LEGACY the pre-3.0.0 shape applies instead, see isLegacyCapPeriod(String).
      Parameters:
      token - The token.
      Returns:
      true for exactly that shape.
    • isLegacyCapPeriod

      private static boolean isLegacyCapPeriod(String token)
      The pre-3.0.0 shape, kept for CompatibilityMode.LEGACY: an ASCII capital or one of Ä, Ö, Ü, then a period, then the end of the token or one line terminator, which the $ of the pattern ^[A-ZÄÖÜ]\\.$ accepted.
      Parameters:
      token - The token.
      Returns:
      true for exactly that shape.