0.0.17 • Published 5 years ago

scoped-natural-language-processor v0.0.17

Weekly downloads
8
License
CC-BY-NC-4.0
Repository
github
Last release
5 years ago

Scoped Natural Language Processor

An input/output natural language interpreter written in TypeScript. It takes a configuration and a sentence, then it return a tree of concepts and values.

Installation

npm i scoped-natural-language-processor --save 

Use

Basic use example with TypeScript:

import {
  process, Concept, Inferred, ProcessError,
} from 'scoped-natural-language-processor';

const sentences: Concept[] = [
  {
    key: 'sentence',
    is: [
      ['*subject', '*linkingVerb', '*adjective'],
      ['*article', '*subject', '*linkingVerb', '*adjective'],
    ],
  },
  {
    key: 'article',
    is: ['this', 'the', 'a'],
  },
  {
    key: 'subject',
    is: ['cat', 'sky', 'grandma'],
  },
  {
    key: 'linkingVerb',
    is: ['is', 'seems', 'becomes'],
  },
  {
    key: 'adjective',
    is: ['gray', 'threatening'],
  },
];
const [error, result]: [ProcessError, Inferred] = process(sentences, 'this cat seems threatening');
if (!error) {
  console.log(result);
}
/*
{
  article: 'this',
  subject: 'cat',
  linkingVerb: 'seems',
  adjective: 'threatening',
}
*/

Basic use example with JavaScript:

const { process } = require('scoped-natural-language-processor');

const sentences = [
  {
    key: 'sentence',
    is: [
      ['*subject', '*linkingVerb', '*adjective'],
      ['*article', '*subject', '*linkingVerb', '*adjective'],
    ],
  },
  {
    key: 'article',
    is: ['this', 'the', 'a'],
  },
  {
    key: 'subject',
    is: ['cat', 'sky', 'grandma'],
  },
  {
    key: 'linkingVerb',
    is: ['is', 'seems', 'becomes'],
  },
  {
    key: 'adjective',
    is: ['gray', 'threatening'],
  },
];
const [error, result] = process(sentences, 'this cat seems threatening');
if (!error) {
  console.log(result);
}

/*
{
  article: 'this',
  subject: 'cat',
  linkingVerb: 'seems',
  adjective: 'threatening',
}
*/

Licences

CC-BY-NC-4.0: you can use/copy/modify any code but only without commercial intentions.

0.0.17

5 years ago

0.0.10

6 years ago

0.0.11

6 years ago

0.0.12

6 years ago

0.0.13

6 years ago

0.0.14

6 years ago

0.0.15

6 years ago

0.0.9

6 years ago

0.0.16

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago