0.0.17 • Published 4 years ago

scoped-natural-language-processor v0.0.17

Weekly downloads
8
License
CC-BY-NC-4.0
Repository
github
Last release
4 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

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.9

4 years ago

0.0.16

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago