Skip to content

HumanNameParser.java, a Java port of HumanNameParser.php. Parser for human names in Java, all credit goes to @jasonpriem

License

Notifications You must be signed in to change notification settings

dswitzer/HumanNameParser.java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HumanNameParse.java

Java port Author: Bruno P. Kinoshita

Contributors: Dan G. Switzer, II

Original library Author: Jason Priem [email protected] (credits go to him) Original library Author Website: http://jasonpriem.com/human-name-parse

License: MIT

Description

Takes human names of arbitrary complexity and various wacky formats like:

  • J. Walter Weatherman
  • de la Cruz, Ana M.
  • James C. ('Jimmy') O'Dell, Jr.

and parses out the:

  • title (Like "Mrs." in "Jane Doe")
  • leading initial (Like "J." in "J. Walter Weatherman")
  • first name (or first initial in a name like 'R. Crumb')
  • nicknames (like "Jimmy" in "James C. ('Jimmy') O'Dell, Jr.")
  • middle names
  • last name (including compound ones like "van der Sar' and "Ortega y Gasset"), and
  • suffix (like 'Jr.', 'III')

Usage

<dependencies>
  <dependency>
    <groupId>com.tupilabs</groupId>
    <artifactId>human-name-parser</artifactId>
  </dependency>
</dependencies>
-- Method 1 - Using the Name object
Name object = new Name("Dr. J. Björn (\"JB\") Charles O'Malley y Muñoz, Jr.");
HumanNameParserParser parser = new HumanNameParserParser(object);

-- Method 2 - Pass a String to the parser
HumanNameParserParser parser = new HumanNameParserParser("Dr. J. Björn (\"JB\") Charles O'Malley y Muñoz, Jr.");

-- parser methods
String title = parser.getTitle();                  // Dr.
String leadingInit = parser.getLeadingInit();      // J.
String first = parser.getFirst();                  // Björn
String fullFirst = parser.getFullFirst();          // J. Björn
String nicknames = parser.getNicknames();          // JB
String middle = parser.getMiddle();                // Charles
String last = parser.getLast();                    // O'Malley y Muñoz
String suffix = parser.getSuffix();                // Jr.
String fullLast = parser.getFullLast();            // O'Malley y Muñoz, Jr.

About

HumanNameParser.java, a Java port of HumanNameParser.php. Parser for human names in Java, all credit goes to @jasonpriem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%