dinhvantiep / mecab_dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mecab_dart

MeCab(Japanese Morphological Analyzer) wrapper for Flutter on iOS/Android.

Usage

  1. Add this plug_in mecab_dart as a dependency in your pubspec.yaml file.
dependencies:   
   mecab_dart: 0.1.3
  1. Copy Mecab dictionary (ipadic) to your assets folder

  2. Try the following example.

Example

Init the tagger:

var tagger = new Mecab();
await tagger.init("assets/ipadic", true);

Set the boolean option in init function to true if you want to get the tokens including features, set it to false if you only want the token surfaces.

Use the tagger to parse text:

var tokens = tagger.parse('にわにわにわにわとりがいる。');
var text = '';

for(var token in tokens) {
  text += token.surface + "\t";
  for(var i = 0; i < token.features.length; i++) {
    text += token.features[i];
    if(i + 1 < token.features.length) {
       text += ",";
    }
  }
  text += "\n";
}

About

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C++ 99.7%Language:Dart 0.2%Language:Kotlin 0.1%Language:C 0.0%Language:Swift 0.0%Language:Ruby 0.0%Language:CMake 0.0%Language:Java 0.0%Language:Objective-C 0.0%