Code Monkey home page Code Monkey logo

humanparser's Introduction

humanparser

NPM

Parse a human name string into salutation, first name, middle name, last name, suffix.

Install

npm install humanparser

Usage

const human = require('humanparser');

parse human name

const fullName = 'Mr. William R. Hearst, III';
const attrs = human.parseName(fullName);

console.log(attrs);

//produces the following output

{ 
    salutation: 'Mr.',
    firstName: 'William',
    suffix: 'III',
    lastName: 'Hearst',
    middleName: 'R.',
    fullName: 'Mr. William R. Hearst, III'
}

get fullest name in string

const name = 'John & Peggy Sue';
const fullName = human.getFullestName(name);

//produces the following output
{
    fullName: 'Peggy Sue'
}

parse address

const address = '123 Happy Street, Honolulu, HI  65780';
const parsed = human.parseAddress(address);

//produces the following output    
{
    address: '123 Happy Street',
    city: 'Honolulu',
    state: 'HI',
    zip: '65780',
    fullAddress: '123 Happy Street, Honolulu, HI  65780'
}

humanparser's People

Contributors

5harf avatar anthonyettinger avatar barwin avatar bitdeli-chef avatar chovy avatar compwright avatar dependabot[bot] avatar gitter-badger avatar joelwatson avatar matmar10 avatar poster983 avatar ralyodio avatar retorquere avatar sajinshrestha avatar skeggse avatar zoellner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

humanparser's Issues

Support for Name + Address

Hi!

Thanks for everything you did so far!
I think it would be great if someone can just copy and paste name + address (eg. Clipboard).
Right now it doesn't work and you need to copy paste twice or do some extra separation work outside the plugin.

Thanks!

Parse name from email

Do you consider valuable and meaningful feature for parsing name out of an email address? E.g. [email protected] => Mila Votradovec.

I am willing to contribute, but want to discuss the idea first.

Salutation followed by one name return empty last name

When parseName for a salutation and last name only, it is returning first name:

var
  human = require("humanparser"),
  attrs = human.parseName("Ms. Smith")
;
console.log(attrs);

actual:

{ 
    saluation: 'Mr',
    firstName: 'Smith',
    lastName: '',
    fullName: 'Mr Smith'
}

expected:

{ 
    saluation: 'Mr',
    firstName: '',
    lastName: 'Smith',
    fullName: 'Mr Smith'
}

Last name prefix `van den` is not recognized

van den is not treated like van der

humanparser.parseName('Caroline van den Brul')
{ firstName: 'Caroline',
  lastName: 'Brul',
  middleName: 'van den',
  fullName: 'Caroline van den Brul' }

humanparser.parseName('Caroline van der Brul')
{ firstName: 'Caroline',
  lastName: 'van der Brul',
  fullName: 'Caroline van der Brul' }

Breaks in IE11

Hi,
It seems IE11 does not support the includes, entries method.

Working on a PR

Multiple middle names get reversed

P/R coming soon, I discovered this issue earlier when I was trying to parse a name that had multiple middle names.

So a name like Tommy A B Lee would come back with a middleName: 'B A' when it should have had middleName: 'A B'

p.s. Thanks for a very helpful module.

Does not parse suffixes when in the format "Hearst Jr., William Randolf"

Returns "lastname": ""Hearst Jr."

This format of writing names is not in the tests, and unfortunately breaks the parsing ability. This is the format of names for one of the databases I inherited recently.

I tried to split the last name based off of spaces, but of course that then breaks multiple word last names like "Van De Car"

Missing letter T in README.md

//produces the following output

{
salu T ation: 'Mr.',
firstName: 'William',
suffix: 'III',
lastName: 'Hearst',
middleName: 'R.',
fullName: 'Mr. William R. Hearst, III'
}

'LatName, FirstName' not parsing correctly

"Doe, John" is not parsing correctly
parses to:
{ firstName: 'Doe,', lastName: 'John', fullName: 'Doe, John' }
should parse to:
{ firstName: 'John', lastName: 'Doe', fullName: 'John Doe' }

Does not support nicknames

If a nickname is present, it is read as part of the middle name.

humanparser.parseName('George Herman “Babe” Ruth')

{ firstName: 'George',
  lastName: 'Ruth',
  middleName: 'Herman “Babe”',
  fullName: 'George Herman “Babe” Ruth' }

error: argument name is invalid

Since v1.8.0 there is a bug that completely breaks my feathersjs app. Just adding the following anywhere makes all request to the app throw the error.

const human = require('humanparser');
error: argument name is invalid

Missing Tests

This is a pretty good parser but it needs some more exhaustive tests:

{
    name: 'Mr. Hearst',
    result: {
        salutation: 'Mr.',
        firstName: '',
        middleName: '',
        lastName: 'Hearst',
        suffix: '',
        fullName: 'Mr. Hearst'
    }
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.