Awesome
ve_dart
"離さないって決めたから" => ["離さない", "って", "決めた", "から"]
"そぞろに鼻を利かせては" => ["そぞろに", "鼻", "を", "利かせて", "は"]
"無作為に伸びてる雑草も" => ["無", "作為に", "伸びてる", "雑草", "も"]
"守りたいって言ったのさ" => ["守りたい", "って", "言った", "の", "さ"]
"何が起きようと変わらないままで" => ["何", "が", "起きよ", "う", "と", "変わらない", "まま", "で"]
<b>A Dart implementation of <a href="https://github.com/Kimtaro/ve">Ve</a>.</b> A linguistic framework that's easy to use. No degree required.
- Segments Japanese morphemes to words via the <b><a href="https://pub.dev/packages/mecab_dart">mecab_dart</b></a> package
- Based on the <a href="https://github.com/Kimtaro/ve/tree/master/java">Java port</a> of <b><a href="https://github.com/shirakaba/">Jamie Birch</a></b>, original <a href="https://github.com/Kimtaro/ve">Ruby implementation</a> by <b><a href="https://github.com/Kimtaro/">Kim Ahlström</b></a>
- Used in <b><a href="https://github.com/lrorpilla/jidoujisho">jidoujisho</b></a> as a text segmentation parser for tap to select subtitle functionality
🚨 Dependencies
This package requires use of the <b><a href="https://pub.dev/packages/mecab_dart">mecab_dart</b></a> package, which in turn makes use of ipadic dictionary files.
- Add the following dependencies in your
pubspec.yaml
file.
dependencies:
mecab_dart: 0.1.2
ve_dart: 0.2.1
-
Copy the ipadic dictionary files in the
mecab_dart
example'sassets/ipadic
to your ownassets
folder. -
Append the following to the
assets
section of yourpubspec.yaml
file
flutter:
assets:
- assets/ipadic/
- Add the following imports to your code.
import 'package:mecab_dart/mecab_dart.dart';
import 'package:ve_dart/ve_dart.dart';
When done, you're ready to use the example below.
📖 Example
// Initialise a mecab_dart tagger.
mecabTagger = Mecab();
await mecabTagger.init("assets/ipadic", true);
// Use parseVe with the initialised tagger and your unparsed term.
List<Word> words = parseVe(mecabTagger, "今未練なんかこれっぽっちも無い");
List<String> output = [];
for (var word in words) {
output.add(word.toString());
}
print(output); // ["今", "未練", "なんか", "これ", "っぽっ", "ち", "も", "無い"]