Class RegexNameFinder

java.lang.Object
opennlp.tools.namefind.RegexNameFinder
All Implemented Interfaces:
opennlp.tools.namefind.TokenNameFinder

public final class RegexNameFinder extends Object implements opennlp.tools.namefind.TokenNameFinder
A TokenNameFinder implementation based on a series of regular expressions.
  • Constructor Details

    • RegexNameFinder

      public RegexNameFinder(Map<String, Pattern[]> regexMap)
      Initializes a RegexNameFinder instance.
      Parameters:
      regexMap - A Map where the key is a type, and the value is a Pattern. Must not be null.
    • RegexNameFinder

      public RegexNameFinder(Pattern[] patterns, String type)
      Initializes a RegexNameFinder instance.
      Parameters:
      patterns - The patterns to use. Must not be null and not be empty.
      type - The type to use.
      Throws:
      IllegalArgumentException - Thrown if patterns were null or empty.
  • Method Details

    • find

      public opennlp.tools.util.Span[] find(String[] tokens)
      Specified by:
      find in interface opennlp.tools.namefind.TokenNameFinder
    • find

      public opennlp.tools.util.Span[] find(String text)
      Finds spans with character indices, rather than word.
      Parameters:
      text - The text to use.
      Returns:
      A Span representing the annotations.
    • clearAdaptiveData

      public void clearAdaptiveData()
      Specified by:
      clearAdaptiveData in interface opennlp.tools.namefind.TokenNameFinder
    • getMatchingPatterns

      public Pattern[] getMatchingPatterns()
      Returns:
      Retrieves the matching patterns used.
    • setMatchingPatterns

      public void setMatchingPatterns(Pattern[] mPatterns)
      Parameters:
      mPatterns - The matching patterns to be set.
    • getSpanType

      public String getSpanType()
      Returns:
      Retrieves the Span type used.
    • setSpanType

      public void setSpanType(String sType)
      Parameters:
      sType - Sets a (different) Span type.