Skip to content

pyoif/NLP

Repository files navigation

NLP by Hiyurigi

A simple implementation of NLP in JS.

How to use

Installation

npm i @hiyurigi/nlp

Function

  • Text Correction

    Example:

    const NLP = require('@hiyurigi/nlp')("TextCorrection");
    let v = new NLP(["stats", "menu", "xzxz"]);
    let result = v.TextCorrection({Needle: "mqnts", Threshold: 0.4, NgramsLength: 1});
    console.log(result);

    Output:

    [
        { Key: 'menu', Text: [ 'm', 'e', 'n', 'u'], similarity: 1 },
        { Key: 'stats', Text: [ 'm', 'q', 'n', 't', 's' ], similarity: 0.4 }
    ]
    Parameter Description Type Default
    Needle Text you want to fix. String | Required None
    NgramsLength how many grams you want. integer | Optional 1
    Threshold Text correction threshold. float | Optional 0.3
    ThresholdOperator Threshold js comparison operator. String | Optional >=
    KeyRange Key distance on the keyboard. Integer | Optional 2
    Autofix Auto fix word (works only with NgramsLength = 1). Boolean | Optional true
    RemoveArray Remove array when output just 1. Boolean | Optional false
  • Text Completion

    Example:

    const NLP = require('@hiyurigi/nlp')("TextCompletion");
    let v = new NLP(["stats", "menu", "xzxz"]);
    let result = v.TextCompletion("m");
    console.log(result);

    Output:

    menu
    Parameter Description Type Default
    UncompleteText Uncompleted Text. String | Required None

Read More

Testing

npm test

TODO List

  • Create text correction
  • Create text completion

If you have a Idea feel free to suggest me

License

License - GNU GPLv3

About

A simple NLP implementation on JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published