YAMeCab (YAMeCab v0.1.0)
Yet Another Elixir binding for MeCab.
YAMeCab is implemented in Port Drivers. So it is fast but possibly crashes Erlang VM.
installation
Installation
The package can be installed by adding yamecab
to your list of dependencies in mix.exs
:
def deps do
[
{:yamecab, "~> 0.1.0"}
]
end
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Parses a given sentence and returns nodes.
Starts a new YAMeCab process. One YAMeCab process creates one MeCab model instance internally, which is subsequently reused.
Link to this section Functions
Link to this function
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
parse(pid, sentence)
@spec parse(pid(), binary()) :: {:ok, [YAMeCab.Node.t()]} | {:error, YAMeCab.ParseError.t()}
Parses a given sentence and returns nodes.
examples
Examples
iex> {:ok, mecab} = YAMeCab.start_link([])
iex> {:ok, res} = YAMeCab.parse(mecab, "すもももももももものうち")
iex> Enum.map(res, fn n -> {n.surface, n.feature} end)
[
{"", "BOS/EOS,*,*,*,*,*,*,*,*"},
{"すもも", "名詞,一般,*,*,*,*,すもも,スモモ,スモモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"の", "助詞,連体化,*,*,*,*,の,ノ,ノ"},
{"うち", "名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ"},
{"", "BOS/EOS,*,*,*,*,*,*,*,*"}
]
Link to this function
start_link(options \\ [])
Starts a new YAMeCab process. One YAMeCab process creates one MeCab model instance internally, which is subsequently reused.