-
Notifications
You must be signed in to change notification settings - Fork 1
/
exawabi.ex
70 lines (60 loc) · 2.63 KB
/
exawabi.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
defmodule ExAwabi do
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
use Rustler, otp_app: :exawabi, crate: "awabi_nif"
@doc """
Tokenize the string.
## Examples
iex> ExAwabi.tokenize("すもももももももものうち")
[
{"すもも", "名詞,一般,*,*,*,*,すもも,スモモ,スモモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"の", "助詞,連体化,*,*,*,*,の,ノ,ノ"},
{"うち", "名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ"}
]
"""
@spec tokenize(binary) :: [binary]
def tokenize(_s), do: error()
@doc """
Tokenize the string with `N` best matches.
## Examples
iex> ExAwabi.tokenize_n_best("すもももももももものうち", 3)
[
[
{"すもも", "名詞,一般,*,*,*,*,すもも,スモモ,スモモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"の", "助詞,連体化,*,*,*,*,の,ノ,ノ"},
{"うち", "名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ"}
],
[
{"すもも", "名詞,一般,*,*,*,*,すもも,スモモ,スモモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"の", "助詞,連体化,*,*,*,*,の,ノ,ノ"},
{"うち", "名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ"}
],
[
{"すもも", "名詞,一般,*,*,*,*,すもも,スモモ,スモモ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"もも", "名詞,一般,*,*,*,*,もも,モモ,モモ"},
{"も", "助詞,係助詞,*,*,*,*,も,モ,モ"},
{"の", "助詞,連体化,*,*,*,*,の,ノ,ノ"},
{"うち", "名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ"}
]
]
"""
@spec tokenize_n_best(binary, integer) :: [[binary]]
def tokenize_n_best(_s, _n), do: error()
defp error, do: :erlang.nif_error(:nif_not_loaded)
end