📜 Train Natural (Node.js NLP) classifiers with local text files
Easily train classifiers from text files on your computer. Works with classifiers available in Natural, a Node.js natural language facility library.
npm install train-natural
import { train } from "train-natural";
import { BayesClassifier } from "natural";
import { join } from "path";
const documents = join(__dirname, "training-data");
const classifier = new BayesClassifier();
await train(classifier, documents);
console.log(classifier.classify("example string"));
In the above example, a directory named training-data
contains several folders, one for each label, in which each text file is used to train the classifier.