edu.northwestern.at.morphadorner.corpuslinguistics.namerecognizer

## Class Names

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.namerecognizer.Names

-     public class Names
      extends java.lang.Object

  Extract person and place names from text.

  Uses lists of first names, surnames, and geographic locations to extract person names and locations from text.

  Based in part on code written by Mark Watson.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.util.Set<java.lang.String>` | `connectorsSet` Name connectors set.
    `protected static java.lang.String` | `defaultResourcePath` Default name resource data files.
    `protected static java.util.Set<java.lang.String>` | `firstNameSet` First name set.
    `protected static java.util.Map<java.lang.String,java.lang.String>` | `placeNameMap` Place name map.
    `protected static java.util.Set<java.lang.String>` | `prefixSet` Prefix title set.
    `protected static java.util.Set<java.lang.String>` | `surnameSet` Surname set.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Names()` Create name extractor.
    `Names(java.lang.String resourcePath)` Create name extractor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `acceptName(Lexicon lexicon, java.lang.String name, boolean firstWord, int numWords)` Accept a name.
    `java.util.Set<java.lang.String>` | `getConnectors()` Return name connectors set.
    `java.util.Set<java.lang.String>` | `getFirstNames()` Return first name set.
    `java.lang.String` | `getPersonName(java.lang.String[] words, int startIndex, int numWords)` Get a person name from a list of words.
    `java.lang.String` | `getPlaceName(java.lang.String[] words, int startIndex, int numWords)` Get a place name from a list of words.
    `java.util.Map<java.lang.String,java.lang.String>` | `getPlaceNames()` Return place name set.
    `java.lang.String` | `getPlaceNameType(java.lang.String placeName)` Get place name type.
    `java.util.Set<java.lang.String>` | `getPrefixes()` Return prefix title set.
    `java.util.Set<java.lang.String>[]` | `getProperNames(java.util.List<java.lang.String> wordsList, Lexicon lexicon)` Extract all proper names for people and places from a sstring.
    `java.util.Set<java.lang.String>[]` | `getProperNames(java.lang.String[] words, Lexicon lexicon)` Extract all proper names for people and places from a list of words.
    `java.util.Set<java.lang.String>[]` | `getProperNames(java.lang.String s, Lexicon lexicon)` Extract all proper names for people and places from a sstring.
    `java.util.Set<java.lang.String>` | `getSurnames()` Return last name set.
    `boolean` | `isNameOrPlace(java.lang.String s)` See if string is a name or a place.
    `boolean` | `isNamePrefix(java.lang.String word)` Check if word is a name prefix (Mr., Mrs., etc.).
    `boolean` | `isPersonName(java.lang.String s)` Check if string is a person name.
    `boolean` | `isPersonName(java.lang.String[] words)` Check if list of words form a person's name.
    `boolean` | `isPlaceName(java.lang.String name)` Check if name is a place name.

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

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

- - ### Field Detail

    - #### defaultResourcePath

          protected static java.lang.String defaultResourcePath

      Default name resource data files.

    - #### surnameSet

          protected static java.util.Set<java.lang.String> surnameSet

      Surname set.

    - #### firstNameSet

          protected static java.util.Set<java.lang.String> firstNameSet

      First name set.

    - #### placeNameMap

          protected static java.util.Map<java.lang.String,java.lang.String> placeNameMap

      Place name map.

    - #### prefixSet

          protected static java.util.Set<java.lang.String> prefixSet

      Prefix title set.

    - #### connectorsSet

          protected static java.util.Set<java.lang.String> connectorsSet

      Name connectors set.

  - ### Constructor Detail

    - #### Names

          public Names()

      Create name extractor.

    - #### Names

          public Names(java.lang.String resourcePath)

      Create name extractor.
      Parameters:
        `resourcePath` - Path to resource files.

  - ### Method Detail

    - #### isNameOrPlace

          public boolean isNameOrPlace(java.lang.String s)

      See if string is a name or a place.
      Parameters:
        `s` - The string to check.
      Returns:
        true if the string is a name or a place.

    - #### acceptName

          protected boolean acceptName(Lexicon lexicon,
                           java.lang.String name,
                           boolean firstWord,
                           int numWords)

      Accept a name.
      Parameters:
        `lexicon` - Word lexicon.
        `name` - The text of the name.
        `firstWord` - True if the name starts with the first word in a sentence.
        `numWords` - The number of words in the name.
      Returns:
        true if the name should be accepted as such.

    - #### getProperNames

          public java.util.Set<java.lang.String>[] getProperNames(java.lang.String[] words,
                                                         Lexicon lexicon)

      Extract all proper names for people and places from a list of words.
      Parameters:
        `words` - String array of words to search for names. This should correspond to a single sentence.
        `lexicon` - Lexicon for filtering names.
      Returns:
        Two element array containing two sets. First set is a list of person names. Second set is a list of place names.

    - #### getProperNames

          public java.util.Set<java.lang.String>[] getProperNames(java.lang.String s,
                                                         Lexicon lexicon)

      Extract all proper names for people and places from a sstring.
      Parameters:
        `s` - String to search for names. This should correspond to a single sentence.
        `lexicon` - Lexicon for filtering names.
      Returns:
        Two element array containing two sets. First set is a list of person names. Second set is a list of place names.

    - #### getProperNames

          public java.util.Set<java.lang.String>[] getProperNames(java.util.List<java.lang.String> wordsList,
                                                         Lexicon lexicon)

      Extract all proper names for people and places from a sstring.
      Parameters:
        `wordsList` - List of words to search for names. This should correspond to a single sentence.
        `lexicon` - Lexicon for filtering names.
      Returns:
        Two element array containing two sets. First set is a list of person names. Second set is a list of place names.

    - #### getPlaceName

          public java.lang.String getPlaceName(java.lang.String[] words,
                                      int startIndex,
                                      int numWords)

      Get a place name from a list of words.
      Parameters:
        `words` - String array of words.
        `startIndex` - Start index in words array to check for a name.
        `numWords` - The number of words to check for a name.
      Returns:
        The place name, if found, or an empty string if not found.

    - #### getPlaceNameType

          public java.lang.String getPlaceNameType(java.lang.String placeName)

      Get place name type.
      Parameters:
        `placeName` - The place name.
      Returns:
        Place name type, or empty string if none.

    - #### isPlaceName

          public boolean isPlaceName(java.lang.String name)

      Check if name is a place name.
      Parameters:
        `name` - The name.
      Returns:
        true if it is a place name.

    - #### isNamePrefix

          public boolean isNamePrefix(java.lang.String word)

      Check if word is a name prefix (Mr., Mrs., etc.).
      Parameters:
        `word` - The word to check.
      Returns:
        true if it is a name prefix.

    - #### isPersonName

          public boolean isPersonName(java.lang.String s)

      Check if string is a person name.
      Parameters:
        `s` - The string.
      Returns:
        true if input string is a person name.

    - #### getPersonName

          public java.lang.String getPersonName(java.lang.String[] words,
                                       int startIndex,
                                       int numWords)

      Get a person name from a list of words.
      Parameters:
        `words` - String array of words.
        `startIndex` - Start index in words array to check for a name.
        `numWords` - The number of words to check for a name.
      Returns:
        The person name, if found, or an empty string if not found.

    - #### isPersonName

          public boolean isPersonName(java.lang.String[] words)

      Check if list of words form a person's name.
      Parameters:
        `words` - The words.
      Returns:
        true if words form a person's name.

    - #### getFirstNames

          public java.util.Set<java.lang.String> getFirstNames()

      Return first name set.
      Returns:
        First name set.

    - #### getSurnames

          public java.util.Set<java.lang.String> getSurnames()

      Return last name set.
      Returns:
        Last name set.

    - #### getPlaceNames

          public java.util.Map<java.lang.String,java.lang.String> getPlaceNames()

      Return place name set.
      Returns:
        Place name set.

    - #### getPrefixes

          public java.util.Set<java.lang.String> getPrefixes()

      Return prefix title set.
      Returns:
        Prefix title set.

    - #### getConnectors

          public java.util.Set<java.lang.String> getConnectors()

      Return name connectors set.
      Returns:
        Name connectors set.