Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "keyworder", | ||
"version": "0.0.1", | ||
"description": "Machine learning tool for word processing", | ||
"main": "index.js", | ||
"version": "0.1.0", | ||
"description": "Intent recognition for prg-chatbot", | ||
"main": "src/main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"doc": "node ./bin/makeApiDoc.js", | ||
"test": "npm run test:lint && npm run test:coverage && npm run test:coverage:threshold", | ||
"test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- --opts ./mocha.opts ./test", | ||
"test:coverage:threshold": "istanbul check --branches 80 --functions 80 --statements 80 --lines 80 ./coverage/coverage.json", | ||
"test:backend": "mocha --opts ./mocha.opts ./test ./src", | ||
"test:lint": "eslint --ext .js src test *.js" | ||
}, | ||
@@ -14,11 +19,9 @@ "repository": { | ||
"keywords": [ | ||
"Machine", | ||
"learning", | ||
"tool", | ||
"for", | ||
"natural", | ||
"language", | ||
"and", | ||
"word", | ||
"processing" | ||
"Machine Learning", | ||
"Intent Prediction", | ||
"Chatbot", | ||
"Fast Text", | ||
"NLP", | ||
"Natural language", | ||
"Pragonauts" | ||
], | ||
@@ -30,3 +33,21 @@ "author": "Pragonauts", | ||
}, | ||
"homepage": "https://github.com/pragonauts/keyworder#readme" | ||
"homepage": "https://github.com/pragonauts/keyworder#readme", | ||
"devDependencies": { | ||
"eslint": "^3.19.0", | ||
"eslint-config-airbnb": "^15.0.1", | ||
"eslint-mocha": "^0.2.2", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-jsdoc": "^3.1.0", | ||
"eslint-plugin-jsx-a11y": "^5.0.3", | ||
"eslint-plugin-mocha": "^4.9.0", | ||
"eslint-plugin-react": "^7.0.1", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"mocha": "^3.4.2", | ||
"mocha-istanbul": "^0.3.0", | ||
"mongoose": "^4.10.5", | ||
"sinon": "^2.3.2" | ||
}, | ||
"dependencies": { | ||
"fast-text": "^0.0.2" | ||
} | ||
} |
131
README.md
@@ -1,51 +0,120 @@ | ||
# Keyworder | ||
# Keyworder - Intent prediction form PrgChatbot | ||
Machine learning tool for word processing. | ||
Predict user intents with cool machine learning tool, Facebook FastText. | ||
## Usage | ||
## Preparing the model | ||
1. Install Facebook [FastText](https://github.com/facebookresearch/fastText) | ||
2. Follow [instructions](https://github.com/facebookresearch/fastText/blob/master/tutorials/supervised-learning.md) | ||
## Using with Prg-Chatbot | ||
Usage | ||
```javascript | ||
const { Router } = require('prg-chatbot'); | ||
const keyworder = require('keyworder'); | ||
const path = require('path'); | ||
const input = 'Ano'; | ||
keyworder.matches('ano', input); | ||
keyworder.setResolver({ | ||
model: path.join(process.cwd(), 'models', 'model.bin') | ||
}); | ||
const app = new Router(); | ||
app.use(keyworder('hello'), (req, res, postBack, next) => { | ||
res.text('Hello too!'); | ||
}); | ||
``` | ||
## Neural networks | ||
----------------- | ||
Usage | ||
# API | ||
## Functions | ||
```javascript | ||
const { | ||
Network, | ||
Runner, | ||
activations | ||
} = require('keyworder'); | ||
<dl> | ||
<dt><a href="#keyworder">keyworder(tag, [threshold], [namespace])</a> ⇒ <code>function</code></dt> | ||
<dd><p>Create resolver middleware for PrgChatbot</p> | ||
</dd> | ||
<dt><a href="#setResolver">setResolver(configuration, [namespace])</a></dt> | ||
<dd></dd> | ||
<dt><a href="#resolve">resolve(text, [threshold], [namespace])</a> ⇒ <code>Promise.<{tag:string, score:number}></code></dt> | ||
<dd><p>Resolve single text</p> | ||
</dd> | ||
</dl> | ||
const network = new Network([4, 3, 2], activations.SIGMOID, activations.SIGMOID); | ||
const runner = new Runner(network); | ||
runner.limit = 50000; | ||
## Typedefs | ||
const set = [ | ||
{ input: [12, 16, 12, 16], output: [1, 0] }, | ||
{ input: [10, 20, 10, 20], output: [1, 0] }, | ||
// and many more | ||
<dl> | ||
<dt><a href="#Configuration">Configuration</a> : <code>Object</code></dt> | ||
<dd></dd> | ||
</dl> | ||
{ input: [0, 1, 0, 1], output: [0, 1] }, | ||
{ input: [1, 0, 1, 0], output: [0, 1] }, | ||
// and many more | ||
]; | ||
<a name="keyworder"></a> | ||
const successRate = runner.learn(set, 0.03); | ||
## keyworder(tag, [threshold], [namespace]) ⇒ <code>function</code> | ||
Create resolver middleware for PrgChatbot | ||
assert.ok(successRate < 0.0001, 1); | ||
**Kind**: global function | ||
assert.deepEqual(runner.output([11, 11, 11, 11]), [0, 1]); | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| tag | <code>string</code> | tag for matching | | ||
| [threshold] | <code>number</code> | override success threshold | | ||
| [namespace] | <code>string</code> | resolver namespace | | ||
**Example** | ||
```javascript | ||
const keyworder = require('keyworder'); | ||
router.use(keyworder('hello-intent'), (req, res) => { | ||
res.text('Welcome too!'); | ||
}); | ||
``` | ||
<a name="setResolver"></a> | ||
## Vision | ||
## setResolver(configuration, [namespace]) | ||
**Kind**: global function | ||
Handle process of machine learning, groupping and maintaining keyword database for word processing. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| configuration | [<code>Configuration</code>](#Configuration) | the resolver configuration | | ||
| [namespace] | <code>string</code> | set resolver for diferent namespace | | ||
- language processing using neural networks | ||
- process of building large databases | ||
**Example** | ||
```javascript | ||
const keyworder = require('keyworder'); | ||
const path = require('path'); | ||
keyworder.setResolver({ | ||
model: path.join(__dirname, 'model.bin') | ||
}); | ||
``` | ||
<a name="resolve"></a> | ||
## resolve(text, [threshold], [namespace]) ⇒ <code>Promise.<{tag:string, score:number}></code> | ||
Resolve single text | ||
**Kind**: global function | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| text | <code>string</code> | query text | | ||
| [threshold] | <code>number</code> | override the threshold | | ||
| [namespace] | <code>string</code> | use other than default resolver | | ||
<a name="Configuration"></a> | ||
## Configuration : <code>Object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| model | <code>string</code> | path to trained fast text model | | ||
| threshold | <code>number</code> | prediction threshold (0.95 recommended) | | ||
| cacheSize | <code>number</code> | keep this amount of results cached | | ||
| filter | <code>function</code> | text preprocessor | | ||
| logger | <code>function</code> | resolver logger function | | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
1
121
14582
1
13
9
235
1
+ Addedfast-text@^0.0.2
+ Addedbindings@1.5.0(transitive)
+ Addedfast-text@0.0.2(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addednan@2.22.0(transitive)