Skip to main content
Deno 2 is finally here 🎉️
Learn more

deno-mecab

Test Check code Test Coverage Maintainability license

English | 日本語

deno-mecab is an asynchronous Japanese morphological analysis module using MeCab.

Getting Started

Currently, this module does not work on Windows. Please wait for resolution.

Dependencies

Example

For a quick example, run this:

deno run --allow-run https://deno.land/x/deno_mecab/example.ts

A simple example:

import { MeCab } from "https://deno.land/x/deno_mecab/mod.ts";

const mecab = new MeCab(["mecab"]);

const text = "JavaScriptはとても楽しいです。";

// Parse (形態素解析)
console.log(await mecab.parse(text));
// [["JavaScript","名詞","固有名詞","組織","*","*","*","*"],["は","助詞","係助詞","*","*","*","*","は","ハ","ワ"],["とても","副詞","助詞類接続","*","*","*","*","とても","トテモ","トテモ"] ...

// Dump (ダンプ出力)
console.log(await mecab.dump(text));
// [["0","BOS",["BOS/EOS","*","*","*","*","*","*","*","*"],"0","0","0","0","0","0","2","1","0.000000","0.000000","0.000000","0"],["3","JavaScript",["名詞","固有名詞","組織","*","*","*","*"],"0","10","1292" ...

// Chasen (Chasen互換)
console.log(await mecab.chasen(text));
// [["JavaScript","JavaScript","JavaScript","名詞-固有名詞-組織","",""],["は","ハ","は","助詞-係助詞","",""],["とても","トテモ","とても","副詞-助詞類接続","",""] ...

// Simple (品詞のみ出力)
console.log(await mecab.simple(text));
// [["は","助詞-係助詞"],["とても","副詞-助詞類接続"],["楽しい","形容詞-自立"],["です","助動詞"],["。","記号-句点"]];

// Wakati (わかち書き)
console.log(await mecab.wakati("JavaScriptはとても楽しいです。"));
// [ "JavaScript", "は", "とても", "楽しい", "です", "。" ]

// Yomi (読み付与)
console.log(await mecab.yomi("日本語"));
// ニホンゴ

Maintainer

@sera1mu

License

MIT © 2021 Seraimu