An OCaml binding of MeCab, a part-of-speech and morphological analyzer.
MeCab is a open-sourced part-of-speech and morphological analyzer independent from languages, dictionaries, and corpuses, developed by a joint project team of Graduate School of Informatics in Kyoto University and NTT Communication Science Laboratories. MeCab is almost faster than ChaSen, Juman, and KAKASHI. The official documentation (written in Japanese) is published at MeCab: Yet Another Part-of-Speech and Morphological Analyzer, and English-translated version is at MeCab English Documentation.
Install the latest-released version by
opam install mecab
or the latest snapshot by opam pin add mecab .
.
You can parse a sentense as follows:
# #require "mecab" ;;
# let mecab = Mecab.Tagger.create [|""|];;
val mecab : Mecab.Tagger.t = <abstr>
# Mecab.Tagger.sparse_tostr mecab "すもももももももものうち" |> print_endline;;
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS
- : unit = ()
- API documentation: https://akabe.github.io/ocaml-mecab/api/