All Projects → azu → kuromojin

azu / kuromojin

Licence: MIT license
Provide a high-level wrapper for kuromoji.js. Cache/Promise API

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to kuromojin

conquerant
lightweight async/await for Clojure
Stars: ✭ 31 (-51.56%)
Mutual labels:  promise
wxapp-socket
用于微信小程序socket通信的封装
Stars: ✭ 17 (-73.44%)
Mutual labels:  promise
hermes-js
Universal action dispatcher for JavaScript apps
Stars: ✭ 15 (-76.56%)
Mutual labels:  promise
emacs-promise
Promises/A+ for Emacs
Stars: ✭ 56 (-12.5%)
Mutual labels:  promise
microteam
小团队管理 是一款开源的微信小程序,主要用于日常的团队管理
Stars: ✭ 40 (-37.5%)
Mutual labels:  promise
react-nested-loader
The easiest way to manage loaders/errors inside a button. NOT an UI lib.
Stars: ✭ 62 (-3.12%)
Mutual labels:  promise
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+45.31%)
Mutual labels:  promise
imooc-promise-sample
📝 幕课网Promise入门视频源码(https://www.imooc.com/learn/949)
Stars: ✭ 87 (+35.94%)
Mutual labels:  promise
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-68.75%)
Mutual labels:  promise
Forbind
Functional chaining and promises in Swift
Stars: ✭ 44 (-31.25%)
Mutual labels:  promise
make-cancellable-promise
Make any Promise cancellable.
Stars: ✭ 17 (-73.44%)
Mutual labels:  promise
ADM-treeView
Pure AngularJs TreeView
Stars: ✭ 30 (-53.12%)
Mutual labels:  promise
io-ts-promise
io-ts for developers who like Promises
Stars: ✭ 69 (+7.81%)
Mutual labels:  promise
parcel-plugin-goodie-bag
provides the Promise and fetch goodies needed for IE(11) support w/ parcel bundle loading
Stars: ✭ 15 (-76.56%)
Mutual labels:  promise
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-67.19%)
Mutual labels:  promise
iworker
Promise-based wrapper for worker_threads
Stars: ✭ 18 (-71.87%)
Mutual labels:  promise
of
🍬 Promise wrapper with sugar 🍬
Stars: ✭ 13 (-79.69%)
Mutual labels:  promise
apns2
Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens
Stars: ✭ 66 (+3.13%)
Mutual labels:  promise
dataloader
Dataloader is a generic utility for batch data loading with caching, works great with GraphQL
Stars: ✭ 114 (+78.13%)
Mutual labels:  promise
buzy
Async queue manager for node and browser
Stars: ✭ 23 (-64.06%)
Mutual labels:  promise

kuromojin Actions Status: test

Provide a high level wrapper for kuromoji.js.

Features

  • Promise based API
  • Cache Layer
    • Fetch the dictionary at once
    • Return same tokens for same text

Installation

npm install kuromojin

Usage

Export two API.

  • getTokenizer() return Promise that is resolved with kuromoji.js's tokenizer instance.
  • tokenize() return Promise that is resolved with analyzed tokens.
import {tokenize, getTokenizer} from "kuromojin";

getTokenizer().then(tokenizer => {
    // kuromoji.js's `tokenizer` instance
});

tokenize(text).then(tokens => {
    console.log(tokens)
    /*
    [ {
        word_id: 509800,          // 辞書内での単語ID
        word_type: 'KNOWN',       // 単語タイプ(辞書に登録されている単語ならKNOWN, 未知語ならUNKNOWN)
        word_position: 1,         // 単語の開始位置
        surface_form: '黒文字',    // 表層形
        pos: '名詞',               // 品詞
        pos_detail_1: '一般',      // 品詞細分類1
        pos_detail_2: '*',        // 品詞細分類2
        pos_detail_3: '*',        // 品詞細分類3
        conjugated_type: '*',     // 活用型
        conjugated_form: '*',     // 活用形
        basic_form: '黒文字',      // 基本形
        reading: 'クロモジ',       // 読み
        pronunciation: 'クロモジ'  // 発音
      } ]
    */
});

For browser/global options

If window.kuromojin.dicPath is defined, kuromojin use it as default dict path.

import {getTokenizer} from "kuromojin";
// Affect all module that are used kuromojin.
window.kuromojin = {
    dicPath: "https://cdn.jsdelivr.net/npm/[email protected]/dict"
};
// this `getTokenizer` function use "https://kuromojin.netlify.com/dict" 
getTokenizer();
// === 
getTokenizer({dicPath: "https://cdn.jsdelivr.net/npm/[email protected]/dict"})

📝 Test dictionary URL

Note: backward compatibility for <= 1.1.0

kuromojin v1.1.0 export tokenize as default function.

kuromojin v2.0.0 remove the default function.

import kuromojin from "kuromojin";
// kuromojin === tokenize

Recommended: use import {tokenize} from "kuromojin" instead of it

import {tokenize} from "kuromojin";

Note: kuromoji version is pinned

kuromojin pin kuromoji's version.

It aim to dedupe kuromoji's dictionary. The dictionary is large and avoid to duplicated dictionary.

Tests

npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].