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

opennlp.tools.namefind

## Class RegexNameFinder

- java.lang.Object
- - opennlp.tools.namefind.RegexNameFinder

- All Implemented Interfaces:
    TokenNameFinder

      public final class RegexNameFinder
      extends Object
      implements TokenNameFinder

  Name finder based on a series of regular expressions.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegexNameFinder(Map<String,Pattern[]> regexMap)`
    `RegexNameFinder(Pattern[] patterns)` Deprecated.
    `RegexNameFinder(Pattern[] patterns, String type)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearAdaptiveData()` Forgets all adaptive data which was collected during previous calls to one of the find methods.
    `Span[]` | `find(String text)` NEW.
    `Span[]` | `find(String[] tokens)` Generates name tags for the given sequence, typically a sentence, returning token spans for any identified names.
    `Pattern[]` | `getmPatterns()`
    `String` | `getsType()`
    `void` | `setmPatterns(Pattern[] mPatterns)`
    `void` | `setsType(String sType)`

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

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

- - ### Constructor Detail

    - #### RegexNameFinder

          public RegexNameFinder(Map<String,Pattern[]> regexMap)

    - #### RegexNameFinder

          public RegexNameFinder(Pattern[] patterns,
                                 String type)

    - #### RegexNameFinder

          @Deprecated
          public RegexNameFinder(Pattern[] patterns)

      Deprecated.
      use constructor `RegexNameFinder(Pattern[], String)` for single types, and/or constructor `RegexNameFinder(Map)`

  - ### Method Detail

    - #### find

          public Span[] find(String[] tokens)

      Description copied from interface: `TokenNameFinder`
      Generates name tags for the given sequence, typically a sentence, returning token spans for any identified names.
      Specified by:
        `find` in interface `TokenNameFinder`
      Parameters:
        `tokens` - an array of the tokens or words of the sequence, typically a sentence.
      Returns:
        an array of spans for each of the names identified.

    - #### find

          public Span[] find(String text)

      NEW. This method removes the need for tokenization, but returns the Span with character indices, rather than word.
      Parameters:
        `text` -
      Returns:

    - #### clearAdaptiveData

          public void clearAdaptiveData()

      Description copied from interface: `TokenNameFinder`
      Forgets all adaptive data which was collected during previous calls to one of the find methods. This method is typical called at the end of a document.
      Specified by:
        `clearAdaptiveData` in interface `TokenNameFinder`

    - #### getmPatterns

          public Pattern[] getmPatterns()

    - #### setmPatterns

          public void setmPatterns(Pattern[] mPatterns)

    - #### getsType

          public String getsType()

    - #### setsType

          public void setsType(String sType)

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