Klasse RegexNameFinder

java.lang.Object
opennlp.tools.namefind.RegexNameFinder
Alle implementierten Schnittstellen:
TokenNameFinder

public final class RegexNameFinder extends Object implements TokenNameFinder
A TokenNameFinder implementation based on a series of regular expressions.
  • Konstruktordetails

    • RegexNameFinder

      public RegexNameFinder(Map<String,Pattern[]> regexMap)
      Initializes a RegexNameFinder instance.
      Parameter:
      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.
      Parameter:
      patterns - The patterns to use. Must not be null and not be empty.
      type - The type to use.
      Löst aus:
      IllegalArgumentException - Thrown if patterns were null or empty.
  • Methodendetails

    • find

      public Span[] find(String[] tokens)
      Beschreibung aus Schnittstelle kopiert: TokenNameFinder
      Generates name tags for the given sequence, typically a sentence, returning token spans for any identified names.
      Angegeben von:
      find in Schnittstelle TokenNameFinder
      Parameter:
      tokens - An array of the tokens or words of the sequence, typically a sentence.
      Gibt zurück:
      An array of spans for each of the names identified.
    • find

      public Span[] find(String text)
      Finds spans with character indices, rather than word.
      Parameter:
      text - The text to use.
      Gibt zurück:
      A Span representing the annotations.
    • clearAdaptiveData

      public void clearAdaptiveData()
      Beschreibung aus Schnittstelle kopiert: TokenNameFinder
      Forgets all adaptive data which was collected during previous calls to one of the find methods.

      Note: This method should typically be called at the end of the processing of a document.

      Angegeben von:
      clearAdaptiveData in Schnittstelle TokenNameFinder
    • getMatchingPatterns

      public Pattern[] getMatchingPatterns()
      Gibt zurück:
      Retrieves the matching patterns used.
    • setMatchingPatterns

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

      public String getSpanType()
      Gibt zurück:
      Retrieves the Span type used.
    • setSpanType

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