Compromise: Add more LastNames

Created on 26 Feb 2018  路  2Comments  路  Source: spencermountain/compromise

Hi there,
I really love this repo but I was wondering, is there a way to 'import' a file like the one you have here
compromise/data/words/people/lastnames.js and add more lastnames, malenames and femalenames?

I now that I can add more using lexicon https://runkit.com/583f2a3dc534df0014136221/58d5d0e469bd5800151ed584 but what if I want to add like 1000 new names or something like that?

Can I just import a js file?

Thank's in advance

Most helpful comment

@scagood Thank you so much good sir. 馃

All 2 comments

You could use a compromise's awesome plugin system (See: https://github.com/nlp-compromise/compromise-plugin).

Basic usage would be as follows:

Lets say your index.js files looked like so:

const path = require('path');
const nlp = require('compromise');

nlp.plugin(require(path.resolve(__dirname, 'names.json')));

const tags = nlp('Has anyone seen Reid?').out('tags');

console.log(JSON.stringify(tags, null, 4));

Your names.json file could look like so:

{
    "name": "Additional Names",
    "words": {
        "Reid": "FemaleName",
        ...More_names...
    }
}

The output when run would look something like so:

[
    {
        "text": "Has",
        "normal": "has",
        "tags": [
            "TitleCase",
            "Verb",
            "VerbPhrase"
        ]
    },
    {
        "text": "anyone",
        "normal": "anyone",
        "tags": [
            "Possessive",
            "Noun"
        ]
    },
    {
        "text": "seen",
        "normal": "seen",
        "tags": [
            "Noun"
        ]
    },
    {
        "text": "Reid?",
        "normal": "reid",
        "tags": [
            "FemaleName",
            "FirstName",
            "Person",
            "Singular",
            "Noun"
        ]
    }
]

Edit:
Alternatively, you could add the names you think are missing to compromise For example in the /data/words/people directory.

@scagood Thank you so much good sir. 馃

Was this page helpful?
0 / 5 - 0 ratings