# kuromoji

> JavaScript implementation of Japanese morphological analyzer

Latest version **0.1.2** (published 2018-03-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install kuromoji
pnpm add kuromoji
yarn add kuromoji
bun add kuromoji
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-03-19 |
| First published | 2014-12-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/kuromoji) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 39.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1003 |
| Author | Takuya Asano |
| Maintainers | takuyaa |
| Keywords | japanese, morphological analyzer, nlp, pos, pos tagger, tokenizer |

## Links

- npm: https://www.npmjs.com/package/kuromoji
- Repository: https://github.com/takuyaa/kuromoji.js
- Issues: https://github.com/takuyaa/kuromoji.js/issues
- npm.io page: https://npm.io/package/kuromoji

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^2.0.1
- [zlibjs](https://npm.io/package/zlibjs.md) ^0.3.1
- [doublearray](https://npm.io/package/doublearray.md) 0.0.2

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2018-03-19
- 0.1.1 — 2016-08-07
- 0.1.0 — 2016-08-06
- 0.0.5 — 2015-11-18
- 0.0.4 — 2015-09-06
- 0.0.3 — 2015-09-06
- 0.0.2 — 2014-12-04

## README

kuromoji.js
===========

[![Build Status](https://travis-ci.org/takuyaa/kuromoji.js.svg?branch=master)](https://travis-ci.org/takuyaa/kuromoji.js)
[![Coverage Status](https://coveralls.io/repos/github/takuyaa/kuromoji.js/badge.svg?branch=master)](https://coveralls.io/github/takuyaa/kuromoji.js?branch=master)
[![npm version](https://badge.fury.io/js/kuromoji.svg)](http://badge.fury.io/js/kuromoji)
[![Bower version](https://badge.fury.io/bo/kuromoji.svg)](http://badge.fury.io/bo/kuromoji)
[![dependencies](https://david-dm.org/takuyaa/kuromoji.js.svg)](https://david-dm.org/takuyaa/kuromoji.js)
[![Code Climate](https://codeclimate.com/github/takuyaa/kuromoji.js/badges/gpa.svg)](https://codeclimate.com/github/takuyaa/kuromoji.js)
[![Downloads](https://img.shields.io/npm/dm/kuromoji.svg)](https://www.npmjs.com/package/kuromoji)

JavaScript implementation of Japanese morphological analyzer.
This is a pure JavaScript porting of [Kuromoji](http://www.atilika.com/ja/products/kuromoji.html).

You can see how kuromoji.js works in [demo site](http://takuyaa.github.io/kuromoji.js/demo/tokenize.html).


Directory
---------

Directory tree is as follows:

    build/
      kuromoji.js -- JavaScript file for browser (Browserified)
    demo/         -- Demo
    dict/         -- Dictionaries for tokenizer (gzipped)
    example/      -- Examples to use in Node.js
    src/          -- JavaScript source
    test/         -- Unit test


Usage
-----

You can tokenize sentences with only 5 lines of code.
If you need working examples, you can see the files under the demo or example directory.


### Node.js

Install with npm package manager:

    npm install kuromoji

Load this library as follows:

    var kuromoji = require("kuromoji");

You can prepare tokenizer like this:

    kuromoji.builder({ dicPath: "path/to/dictionary/dir/" }).build(function (err, tokenizer) {
        // tokenizer is ready
        var path = tokenizer.tokenize("すもももももももものうち");
        console.log(path);
    });



### Browser

You only need the build/kuromoji.js and dict/*.dat.gz files

Install with Bower package manager:

    bower install kuromoji

Or you can use the kuromoji.js file and dictionary files from the GitHub repository.

In your HTML:

    <script src="url/to/kuromoji.js"></script>

In your JavaScript:

    kuromoji.builder({ dicPath: "/url/to/dictionary/dir/" }).build(function (err, tokenizer) {
        // tokenizer is ready
        var path = tokenizer.tokenize("すもももももももものうち");
        console.log(path);
    });


API
---

The function tokenize() returns an JSON array like this:

    [ {
        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: 'クロモジ'  // 発音
      } ]

(This is defined in src/util/IpadicFormatter.js)

See also [JSDoc page](https://takuyaa.github.io/kuromoji.js/jsdoc/) in details.

---
_Source: https://npm.io/package/kuromoji · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
