How to use the node-nlp.NluManager function in node-nlp

To help you get started, we’ve selected a few node-nlp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brian-ai / core / src / services / natural / index.js View on Github external
/* eslint-disable no-unused-expressions */
import { BayesClassifier } from 'natural'
import { NlpManager, NluManager } from 'node-nlp'
import logger from 'hoopa-logger'
import baseKnowledge from '../../brain/knowledge'

const LanguageProcessor = new NlpManager({ languages: 'en' })
const UnderstandingProcessor = new NluManager({ languages: 'en' })

const NLP = {
	Bayes: new BayesClassifier(),
	LanguageProcessor,
	UnderstandingProcessor,
	trainModel: (newKnowledge = null, bayes, manager) => {
		logger.info('Cognitive analysis (NLP & NLU), basic training...')
		const trainingContext = baseKnowledge.natural

		if (newKnowledge) {
			newKnowledge.map(token => trainingContext.push(token))
		}

		trainingContext.map(token => {
			UnderstandingProcessor.addDocument('en', token.input, token.class)
			manager.addDocument('en', token.input, token.class)

node-nlp

Library for NLU (Natural Language Understanding) done in Node.js

MIT
Latest version published 4 days ago

Package Health Score

74 / 100
Full package analysis