Elixir bindings for MeCab, a Japanese morphological analyzer.
If available in Hex, the package can be installed as:
- Add
mecab
to your list of dependencies inmix.exs
:
def deps do
[{:mecab, "~> 1.0"}]
end
- Ensure
mecab
command is available for your environment:
# MacOS
brew install mecab mecab-ipadic
Further information is available at Hex Online Documentation
The way of parsing given string is as follows:
iex> Mecab.parse("今日は晴れです")
[%{"conjugation" => "",
"conjugation_form" => "",
"lexical_form" => "今日",
"part_of_speech" => "名詞",
"part_of_speech_subcategory1" => "副詞可能",
"part_of_speech_subcategory2" => "",
"part_of_speech_subcategory3" => "",
"pronunciation" => "キョー",
"surface_form" => "今日",
"yomi" => "キョウ"},
%{"conjugation" => "",
"conjugation_form" => "",
"lexical_form" => "は",
"part_of_speech" => "助詞",
"part_of_speech_subcategory1" => "係助詞",
"part_of_speech_subcategory2" => "",
"part_of_speech_subcategory3" => "",
"pronunciation" => "ワ",
"surface_form" => "は",
"yomi" => "ハ"},
%{"conjugation" => "",
"conjugation_form" => "",
"lexical_form" => "晴れ",
"part_of_speech" => "名詞",
"part_of_speech_subcategory1" => "一般",
"part_of_speech_subcategory2" => "",
"part_of_speech_subcategory3" => "",
"pronunciation" => "ハレ",
"surface_form" => "晴れ",
"yomi" => "ハレ"},
%{"conjugation" => "基本形",
"conjugation_form" => "特殊・デス",
"lexical_form" => "です",
"part_of_speech" => "助動詞",
"part_of_speech_subcategory1" => "",
"part_of_speech_subcategory2" => "",
"part_of_speech_subcategory3" => "",
"pronunciation" => "デス",
"surface_form" => "です",
"yomi" => "デス"},
%{"conjugation" => "",
"conjugation_form" => "",
"lexical_form" => "",
"part_of_speech" => "",
"part_of_speech_subcategory1" => "",
"part_of_speech_subcategory2" => "",
"part_of_speech_subcategory3" => "",
"pronunciation" => ""
"surface_form" => "EOS",
"yomi" => ""}]
The way of parsing given file is as follows:
iex> Mecab.read!("sentences.txt")
Each parser function returns a list of map. The map's keys meanings is as follows.
surface_form
: 表層形part_of_speech
: 品詞part_of_speech_subcategory1
: 品詞細分類1part_of_speech_subcategory2
: 品詞細分類2part_of_speech_subcategory3
: 品詞細分類3conjugation_form
: 活用形conjugation
: 活用型lexical_form
: 原形yomi
: 読みpronunciation
: 発音