kuromojin
Provide a high level wrapper for kuromoji.js.
Features
- Promise based API
- Cache Layer
Installation
npm install kuromojin
Usage
Export two API.
getTokenizer()
return Promise
that is resolved with kuromoji.js's tokenizer
instance.kuromojin as default
return Promise
that is resolved with analyzed text.
import {tokenize, getTokenizer} from "kuromojin";
getTokenizer().then(tokenizer => {
});
tokenize(text).then(results => {
console.log(results)
});
For browser/global options
If window.kuromojin.dicPath
is defined, kuromojin use it as default dict path.
import {tokenize} from "kuromojin";
window.kuromojin = {
dicPath: "https://example.com/kuromoji/dict"
};
getTokenizer();
getTokenizer({dicPath: "https://example.com/kuromoji/dict"})
Note: backward compatibility for <= 1.1.0
kuromojin v1.1.0 export tokenize
as default function
import kuromojin from "kuromojin";
Recommended use import {tokenize} from "kuromojin"
instead of it
import {tokenize} from "kuromojin";
Tests
npm test
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT