@chatopera/node-ner

1.0.2 • Public • Published

Intent

Sequence Labeler to train NER model with CRF++.

Usage

npm install @chatopera/node-ner
var intent = require("@chatopera/node-ner")

pos

Part of Speech

let tags = intent.pos(["i", "want", "a", "cab", "from", "kak", "to", "idap"]);
console.log("tokens ", tags);
tags = intent.pos("I want a cab from beijing to shanghai");
console.log("tokens ", tags);

tokenzie

Tokenizer

let tokens = intent.tokenzie("I want a cab from beijing to shanghai");
console.log("tokens ", tokens);

features

Extract features for sentence that can be used as input to train CRF model.

let input_xseq1 = intent.sen2features("I want a cab from beijing to shanghai");
console.log(input_xseq1)

train

Train models.

let curdir = __dirname;
let modelSavedPath = path.join(curdir, "tmp", "test.crf.book_cab.model");
let input_yseq1 = ["O", "O", "O", "O", "O", "B-from", "O", "B-destination"];
let samples = [
    [input_xseq1, input_yseq1],
    ... // add many as possible
];
let train = intent.train(samples, modelSavedPath);

predict

Predict entities in sentence with model.

let curdir = __dirname;
let modelSavedPath = path.join(curdir, "tmp", "test.crf.book_cab.model");
let sentence = "book a cab from York to DC."
let tags = intent.predict(featureExtractor.sen2features(sentence), modelSavedPath);
let tokens = intent.tokenzie(sentence);
let result = intent.extractEntities(tokens, tags);
console.log("extractEntities", result)
// extractEntities { from: 'york', destination: 'dc.' }

More examples: check out test/index.js.

Contribute

cd app/
npm install
DEBUG=intent* ava test/index.js

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @chatopera/node-ner

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mukaiu
  • samurais
  • chatopera