1 | ;;; |
---|
2 | ;;; Testing mecab binding |
---|
3 | ;;; |
---|
4 | ;;; 2009.3.13 by naoya_t |
---|
5 | ;;; |
---|
6 | |
---|
7 | (use gauche.test) |
---|
8 | |
---|
9 | (test-start "mecab") |
---|
10 | (use mecab) |
---|
11 | (test-module 'mecab) |
---|
12 | |
---|
13 | ;; |
---|
14 | ;; primitive things |
---|
15 | ;; |
---|
16 | (test-section "[gauche] write-object") |
---|
17 | (let1 mecab (mecab-new2 "") |
---|
18 | (test* "display" "#<mecab>" (with-output-to-string (lambda () (display mecab))))) |
---|
19 | |
---|
20 | (test-section "[gauche] reader-ctor") |
---|
21 | (let1 mecab #,(<mecab>) ;; with reader-ctor |
---|
22 | (test* "#,(<mecab>)" #t (mecab? mecab)) |
---|
23 | (mecab-destroy mecab)) |
---|
24 | (let1 mecab #,(<mecab> "-Ochasen") ;; with reader-ctor |
---|
25 | (test* "#,(<mecab> \"-Ochasen\")" #t (mecab? mecab)) |
---|
26 | (mecab-destroy mecab)) |
---|
27 | |
---|
28 | (let* ([mecab (mecab-new)] |
---|
29 | [node (mecab-sparse-tonode mecab "")] |
---|
30 | [dinfo (mecab-dictionary-info mecab)]) |
---|
31 | (test-section "[gauche] mecab?") |
---|
32 | (test* "<mecab>" #t (mecab? mecab)) |
---|
33 | (test* "<mecab-node>" #f (mecab? node)) |
---|
34 | (test* "<mecab-dictionary-info>" #f (mecab? dinfo)) |
---|
35 | (test* "#f" #f (mecab? #f)) |
---|
36 | |
---|
37 | (test-section "[gauche] mecab-node?") |
---|
38 | (test* "<mecab>" #f (mecab-node? mecab)) |
---|
39 | (test* "<mecab-node>" #t (mecab-node? node)) |
---|
40 | (test* "<mecab-dictionary-info>" #f (mecab-node? dinfo)) |
---|
41 | (test* "#f" #f (mecab-node? #f)) |
---|
42 | |
---|
43 | (test-section "[gauche] mecab-dictionary-info?") |
---|
44 | (test* "<mecab>" #f (mecab-dictionary-info? mecab)) |
---|
45 | (test* "<mecab-node>" #f (mecab-dictionary-info? node)) |
---|
46 | (test* "<mecab-dictionary-info>" #t (mecab-dictionary-info? dinfo)) |
---|
47 | (test* "#f" #f (mecab-dictionary-info? #f)) |
---|
48 | |
---|
49 | (mecab-destroy mecab)) |
---|
50 | |
---|
51 | (test-section "mecab-new") |
---|
52 | (let1 mecab (mecab-new) |
---|
53 | (test* "is-a? <mecab>" #t (is-a? mecab <mecab>)) |
---|
54 | (test* "mecab?" #t (mecab? mecab)) |
---|
55 | |
---|
56 | (test-section "mecab-destroy") |
---|
57 | (test* "mecab-destroyed?" #f (mecab-destroyed? mecab)) |
---|
58 | (mecab-destroy mecab) |
---|
59 | (test* "mecab-destroyed?" #t (mecab-destroyed? mecab)) |
---|
60 | ) |
---|
61 | |
---|
62 | (test-section "mecab-new: (int argc, char **argv)をとるAPIへの対応") |
---|
63 | ;;この他にも mecab-do, mecab-dict-index, mecab-dict-gen, mecab-cost-train, mecab-system-eval, mecab-test-gen があります |
---|
64 | (test* "ベクタで実装(オリジナルに近い?);引数0" #t (mecab? (mecab-new 0 #()))) |
---|
65 | (test* "ベクタで実装(オリジナルに近い?);引数1" #t (mecab? (mecab-new 1 #("A")))) |
---|
66 | (test* "ベクタで実装(オリジナルに近い?);引数2" #t (mecab? (mecab-new 2 #("A" "B")))) |
---|
67 | (test* "リストで実装;引数0" #t (mecab? (mecab-new 0 '()))) |
---|
68 | (test* "リストで実装;引数1" #t (mecab? (mecab-new 1 '("A")))) |
---|
69 | (test* "リストで実装;引数2" #t (mecab? (mecab-new 2 '("A" "B")))) |
---|
70 | (test* "独自形式;引数0" #t (mecab? (mecab-new))) |
---|
71 | (test* "独自形式;引数1" #t (mecab? (mecab-new "-a"))) |
---|
72 | (test* "独自形式;引数1(空)" #t (mecab? (mecab-new ""))) |
---|
73 | (test* "独自形式;引数2" #t (mecab? (mecab-new "-l" "1"))) |
---|
74 | (test* "独自形式;引数2(空)" #t (mecab? (mecab-new "" ""))) |
---|
75 | |
---|
76 | (test-section "mecab-new2") |
---|
77 | (let1 mecab (mecab-new2 "") |
---|
78 | (test* "is-a? <mecab>" #t (is-a? mecab <mecab>)) |
---|
79 | (test* "mecab?" #t (mecab? mecab)) |
---|
80 | (mecab-destroy mecab)) |
---|
81 | |
---|
82 | (test-section "mecab-version") |
---|
83 | (test* "mecab-version" "0.98pre1" (mecab-version)) |
---|
84 | |
---|
85 | (test-section "mecab-strerror") |
---|
86 | (mecab-new "") |
---|
87 | (test* "at mecab-new (ok)" "" (mecab-strerror #f)) |
---|
88 | (mecab-new "-d //") |
---|
89 | ;; "tagger.cpp(149) [load_dictionary_resource(param)] param.cpp(71) [ifs] no such file or directory: //dicrc" |
---|
90 | (test* "at mecab-new (err)" #f (string=? "" (mecab-strerror #f))) |
---|
91 | (let1 mecab (mecab-new) |
---|
92 | (mecab-sparse-tostr mecab "空が青い。") |
---|
93 | (test* "" "" (mecab-strerror mecab)) |
---|
94 | (mecab-destroy mecab)) |
---|
95 | |
---|
96 | (let1 mecab (mecab-new) |
---|
97 | (test-section "mecab-sparse-tostr") |
---|
98 | (test* "空が青い。" |
---|
99 | (string-join '("空\t名詞,一般,*,*,*,*,空,ソラ,ソラ" |
---|
100 | "が\t助詞,格助詞,一般,*,*,*,が,ガ,ガ" |
---|
101 | "青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ" |
---|
102 | "。\t記号,句点,*,*,*,*,。,。,。" |
---|
103 | "EOS" |
---|
104 | "") "\n") |
---|
105 | (mecab-sparse-tostr mecab "空が青い。")) |
---|
106 | |
---|
107 | (test-section "mecab-sparse-tostr2") |
---|
108 | (test* "\"空が青い。\", len=6" |
---|
109 | (string-join '("空\t名詞,一般,*,*,*,*,空,ソラ,ソラ" |
---|
110 | "が\t助詞,格助詞,一般,*,*,*,が,ガ,ガ" |
---|
111 | "EOS" |
---|
112 | "") "\n") |
---|
113 | (mecab-sparse-tostr2 mecab "空が青い。" 6)) |
---|
114 | |
---|
115 | (test-section "mecab-sparse-tonode, mecab-node-***") |
---|
116 | (let1 node (mecab-sparse-tonode mecab "空が青い。") |
---|
117 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
118 | (test* "no previous node" #f (mecab-node-prev node)) |
---|
119 | (test* "next node" #t (mecab-node? (mecab-node-next node))) |
---|
120 | (test* "enext" #f (mecab-node? (mecab-node-enext node))) |
---|
121 | (test* "bnext" #f (mecab-node? (mecab-node-bnext node))) |
---|
122 | (test* "surface" "" (mecab-node-surface node)) |
---|
123 | (test* "feature" "BOS/EOS,*,*,*,*,*,*,*,*" (mecab-node-feature node)) |
---|
124 | (test* "length" 0 (mecab-node-length node)) |
---|
125 | (test* "rlength" 0 (mecab-node-rlength node)) |
---|
126 | (test* "id" 0 (mecab-node-id node)) |
---|
127 | (test* "rc-attr" 0 (mecab-node-rc-attr node)) |
---|
128 | (test* "lc-attr" 0 (mecab-node-lc-attr node)) |
---|
129 | (test* "posid" 0 (mecab-node-posid node)) |
---|
130 | (test* "char-type" 0 (mecab-node-char-type node)) |
---|
131 | (test* "stat" 'mecab-bos-node (mecab-node-stat node)) |
---|
132 | (test* "best?" #t (mecab-node-best? node)) |
---|
133 | (test* "alpha" 0.0 (mecab-node-alpha node)) |
---|
134 | (test* "beta" 0.0 (mecab-node-beta node)) |
---|
135 | (test* "prob" 0.0 (mecab-node-prob node)) |
---|
136 | (test* "wcost" 0 (mecab-node-wcost node)) |
---|
137 | (test* "cost" 0 (mecab-node-cost node)) |
---|
138 | |
---|
139 | (set! node (mecab-node-next node)) |
---|
140 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
141 | (test* "previous node" #t (mecab-node? (mecab-node-prev node))) |
---|
142 | (test* "next node" #t (mecab-node? (mecab-node-next node))) |
---|
143 | (test* "enext" #t (mecab-node? (mecab-node-enext node))) |
---|
144 | (test* "bnext" #f (mecab-node? (mecab-node-bnext node))) |
---|
145 | (test* "surface" "空" (mecab-node-surface node)) |
---|
146 | (test* "feature" "名詞,一般,*,*,*,*,空,ソラ,ソラ" (mecab-node-feature node)) |
---|
147 | (test* "length" 3 (mecab-node-length node)) |
---|
148 | (test* "rlength" 3 (mecab-node-rlength node)) |
---|
149 | (test* "id" 1 (mecab-node-id node)) |
---|
150 | (test* "rc-attr" 1285 (mecab-node-rc-attr node)) |
---|
151 | (test* "lc-attr" 1285 (mecab-node-lc-attr node)) |
---|
152 | (test* "posid" 38 (mecab-node-posid node)) |
---|
153 | (test* "char-type" 2 (mecab-node-char-type node)) |
---|
154 | (test* "stat" 'mecab-nor-node (mecab-node-stat node)) |
---|
155 | (test* "best?" #t (mecab-node-best? node)) |
---|
156 | (test* "alpha" 0.0 (mecab-node-alpha node)) |
---|
157 | (test* "beta" 0.0 (mecab-node-beta node)) |
---|
158 | (test* "prob" 0.0 (mecab-node-prob node)) |
---|
159 | (test* "wcost" 7439 (mecab-node-wcost node)) |
---|
160 | (test* "cost" 7156 (mecab-node-cost node)) |
---|
161 | ) |
---|
162 | |
---|
163 | (test-section "mecab-sparse-tonode2") |
---|
164 | (let1 node (mecab-sparse-tonode2 mecab "空が青い。" 6) |
---|
165 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
166 | (test* "feature" "BOS/EOS,*,*,*,*,*,*,*,*" (mecab-node-feature node)) |
---|
167 | (test* "stat" 'mecab-bos-node (mecab-node-stat node)) |
---|
168 | |
---|
169 | (set! node (mecab-node-next node)) |
---|
170 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
171 | (test* "surface" "空" (mecab-node-surface node)) |
---|
172 | (test* "feature" "名詞,一般,*,*,*,*,空,ソラ,ソラ" (mecab-node-feature node)) |
---|
173 | (test* "stat" 'mecab-nor-node (mecab-node-stat node)) |
---|
174 | |
---|
175 | (set! node (mecab-node-next node)) |
---|
176 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
177 | (test* "surface" "が" (mecab-node-surface node)) |
---|
178 | (test* "feature" "助詞,格助詞,一般,*,*,*,が,ガ,ガ" (mecab-node-feature node)) |
---|
179 | (test* "stat" 'mecab-nor-node (mecab-node-stat node)) |
---|
180 | |
---|
181 | (set! node (mecab-node-next node)) |
---|
182 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
183 | (test* "feature" "BOS/EOS,*,*,*,*,*,*,*,*" (mecab-node-feature node)) |
---|
184 | (test* "stat" 'mecab-eos-node (mecab-node-stat node)) |
---|
185 | (test* "no next node" #f (mecab-node-next node)) |
---|
186 | ) |
---|
187 | ; (test-section "mecab-format-node") |
---|
188 | ; (let1 node (mecab-sparse-tonode mecab "空が青い。") |
---|
189 | ; (test* "BOS" "" (mecab-format-node mecab node))) |
---|
190 | (mecab-destroy mecab)) |
---|
191 | |
---|
192 | (let ([mecab (mecab-new "-l 1")] ;; |
---|
193 | [input "空が青い。"]) |
---|
194 | (test-section "mecab-nbest-sparse-tostr") |
---|
195 | (test* #`",|input|, N=1" |
---|
196 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
197 | (mecab-nbest-sparse-tostr mecab 1 input)) |
---|
198 | (test* #`",|input|, N=2" |
---|
199 | (string-append |
---|
200 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
201 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
202 | ) |
---|
203 | (mecab-nbest-sparse-tostr mecab 2 input)) |
---|
204 | (test* #`",|input|, N=3" |
---|
205 | (string-append |
---|
206 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
207 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
208 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
209 | ) |
---|
210 | (mecab-nbest-sparse-tostr mecab 3 input)) |
---|
211 | |
---|
212 | (test-section "mecab-nbest-sparse-tostr2") |
---|
213 | (test* #`",|input|, N=1" |
---|
214 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
215 | (mecab-nbest-sparse-tostr2 mecab 1 input 6)) |
---|
216 | (test* #`",|input|, N=2" |
---|
217 | (string-append |
---|
218 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
219 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
220 | ) |
---|
221 | (mecab-nbest-sparse-tostr2 mecab 2 input 6)) |
---|
222 | (test* #`",|input|, N=3" |
---|
223 | (string-append |
---|
224 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
225 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
226 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
227 | ) |
---|
228 | (mecab-nbest-sparse-tostr2 mecab 3 input 6)) |
---|
229 | |
---|
230 | (test-section "mecab-nbest-init") |
---|
231 | (test* "init" 1 (mecab-nbest-init mecab input)) |
---|
232 | (test-section "mecab-nbest-next-tostr") |
---|
233 | (test* "#1" |
---|
234 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
235 | (mecab-nbest-next-tostr mecab)) |
---|
236 | (test* "#2" |
---|
237 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
238 | (mecab-nbest-next-tostr mecab)) |
---|
239 | (test* "#3" |
---|
240 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
241 | (mecab-nbest-next-tostr mecab)) |
---|
242 | (test* "#4" |
---|
243 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,接続助詞,*,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
244 | (mecab-nbest-next-tostr mecab)) |
---|
245 | (test* "#5" |
---|
246 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青\t形容詞,自立,*,*,形容詞・アウオ段,ガル接続,青い,アオ,アオ\nい\t動詞,非自立,*,*,一段,連用形,いる,イ,イ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
247 | (mecab-nbest-next-tostr mecab)) |
---|
248 | (test* "#6" |
---|
249 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,接続助詞,*,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
250 | (mecab-nbest-next-tostr mecab)) |
---|
251 | (test* "#7" |
---|
252 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青\t形容詞,自立,*,*,形容詞・アウオ段,ガル接続,青い,アオ,アオ\nい\t動詞,非自立,*,*,一段,連用形,いる,イ,イ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
253 | (mecab-nbest-next-tostr mecab)) |
---|
254 | (test* "#8" |
---|
255 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t接続詞,*,*,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
256 | (mecab-nbest-next-tostr mecab)) |
---|
257 | (test* "#9" |
---|
258 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,接続助詞,*,*,*,*,が,ガ,ガ\n青い\t形容詞,自立,*,*,形容詞・アウオ段,基本形,青い,アオイ,アオイ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
259 | (mecab-nbest-next-tostr mecab)) |
---|
260 | (test* "#10" |
---|
261 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\n青\t形容詞,自立,*,*,形容詞・アウオ段,ガル接続,青い,アオ,アオ\nい\t動詞,非自立,*,*,一段,連用形,いる,イ,イ\n。\t記号,句点,*,*,*,*,。,。,。\nEOS\n" |
---|
262 | (mecab-nbest-next-tostr mecab)) |
---|
263 | (dotimes (i 733) |
---|
264 | (mecab-nbest-next-tostr mecab)) |
---|
265 | (test* "#744" |
---|
266 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t動詞,接尾,*,*,五段・ラ行,体言接続特殊2,がる,ガ,ガ\n青\t名詞,固有名詞,地域,一般,*,*,青,アオ,アオ\nい\t動詞,非自立,*,*,一段,未然形,いる,イ,イ\n。\t名詞,サ変接続,*,*,*,*,*\nEOS\n" |
---|
267 | (mecab-nbest-next-tostr mecab)) |
---|
268 | ;; no more results... |
---|
269 | (test* "#745" #f (mecab-nbest-next-tostr mecab)) |
---|
270 | (test* "mecab-strerror" #f (string=? "" (mecab-strerror mecab))) |
---|
271 | |
---|
272 | (test-section "mecab-nbest-init2") |
---|
273 | (test* "init2" 1 (mecab-nbest-init2 mecab input 6)) |
---|
274 | (test* "#1" |
---|
275 | "空\t名詞,一般,*,*,*,*,空,ソラ,ソラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
276 | (mecab-nbest-next-tostr mecab)) |
---|
277 | (test* "#2" |
---|
278 | "空\t名詞,一般,*,*,*,*,空,カラ,カラ\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
279 | (mecab-nbest-next-tostr mecab)) |
---|
280 | (test* "#3" |
---|
281 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t助詞,格助詞,一般,*,*,*,が,ガ,ガ\nEOS\n" |
---|
282 | (mecab-nbest-next-tostr mecab)) |
---|
283 | (dotimes (i 8) (mecab-nbest-next-tostr mecab)) |
---|
284 | (test* "#12" |
---|
285 | "空\t名詞,一般,*,*,*,*,空,クウ,クー\nが\t動詞,接尾,*,*,五段・ラ行,体言接続特殊2,がる,ガ,ガ\nEOS\n" |
---|
286 | (mecab-nbest-next-tostr mecab)) |
---|
287 | ;; no more results... |
---|
288 | (test* "#13" #f (mecab-nbest-next-tostr mecab)) |
---|
289 | (test* "mecab-strerror" #f (string=? "" (mecab-strerror mecab))) |
---|
290 | |
---|
291 | (test-section "mecab-nbest-next-tonode") |
---|
292 | (mecab-nbest-init mecab input) |
---|
293 | (test* "#1" #t (mecab-node? (mecab-nbest-next-tonode mecab))) |
---|
294 | (dotimes (i 742) (mecab-nbest-next-tonode mecab)) |
---|
295 | (test* "#744" #t (mecab-node? (mecab-nbest-next-tonode mecab))); EOS |
---|
296 | ;; no more results... |
---|
297 | (test* "#745" #f (mecab-node? (mecab-nbest-next-tonode mecab))) |
---|
298 | (test* "mecab-strerror" #f (string=? "" (mecab-strerror mecab))) |
---|
299 | |
---|
300 | (mecab-destroy mecab)) |
---|
301 | |
---|
302 | ;; |
---|
303 | ;; these values below may differ !!! |
---|
304 | (test-section "mecab-dictionary-info, mecab-dictionary-info-***") |
---|
305 | (let* ([mecab (mecab-new "")] |
---|
306 | [dinfo (mecab-dictionary-info mecab)]) |
---|
307 | (test* "mecab-dictionary-info?" #t (mecab-dictionary-info? dinfo)) |
---|
308 | (test* "mecab-dictionary-info-filename" |
---|
309 | "/usr/local/lib/mecab/dic/ipadic/sys.dic" (mecab-dictionary-info-filename dinfo)) |
---|
310 | (test* "mecab-dictionary-info-charset" |
---|
311 | "utf8" (mecab-dictionary-info-charset dinfo)) |
---|
312 | (test* "mecab-dictionary-info-size" |
---|
313 | 392126 (mecab-dictionary-info-size dinfo)) |
---|
314 | (test* "mecab-dictionary-info-type" 'mecab-sys-dic (mecab-dictionary-info-type dinfo)) |
---|
315 | (test* "mecab-dictionary-info-lsize" |
---|
316 | 1316 (mecab-dictionary-info-lsize dinfo)) |
---|
317 | (test* "mecab-dictionary-info-rsize" |
---|
318 | 1316 (mecab-dictionary-info-rsize dinfo)) |
---|
319 | (test* "mecab-dictionary-info-version" |
---|
320 | 102 (mecab-dictionary-info-version dinfo)) |
---|
321 | (let1 next-dinfo (mecab-dictionary-info-next dinfo) |
---|
322 | (test* "has next?" #t (mecab-dictionary-info? next-dinfo)) |
---|
323 | ) |
---|
324 | (mecab-destroy mecab)) |
---|
325 | |
---|
326 | (let1 mecab (mecab-new) |
---|
327 | (test-section "mecab-get[set]-partial: 部分解析の現在のモード(0/1)") |
---|
328 | (test* "default partial mode" 0 (mecab-get-partial mecab)) |
---|
329 | (mecab-set-partial mecab 1) |
---|
330 | (test* "set to 1" 1 (mecab-get-partial mecab)) |
---|
331 | (mecab-set-partial mecab 0) |
---|
332 | (test* "set to 0" 0 (mecab-get-partial mecab)) |
---|
333 | |
---|
334 | (test-section "mecab-get[set]-theta: ソフト分かち書きの温度パラメータ") |
---|
335 | (test* "default theta" 0.75 (mecab-get-theta mecab)) |
---|
336 | (mecab-set-theta mecab 1.0) |
---|
337 | (test* "set to 1.0" 1.0 (mecab-get-theta mecab)) |
---|
338 | (mecab-set-theta mecab 0.5) |
---|
339 | (test* "set to 0.5" 0.5 (mecab-get-theta mecab)) |
---|
340 | |
---|
341 | (test-section "mecab-get[set]-lattice-level: ラティスレベル (0/1/2)") |
---|
342 | (test* "default lattice level" 0 (mecab-get-lattice-level mecab)) |
---|
343 | (mecab-set-lattice-level mecab 1) |
---|
344 | (test* "set to 1" 1 (mecab-get-lattice-level mecab)) |
---|
345 | (mecab-set-lattice-level mecab 2) |
---|
346 | (test* "set to 2" 2 (mecab-get-lattice-level mecab)) |
---|
347 | (mecab-set-lattice-level mecab 0) |
---|
348 | (test* "set to 0" 0 (mecab-get-lattice-level mecab)) |
---|
349 | |
---|
350 | (test-section "mecab-get[set]-all-morphs: 出力モード(0/1)") |
---|
351 | (test* "default all-morphs" 0 (mecab-get-all-morphs mecab)) |
---|
352 | (mecab-set-all-morphs mecab 1) |
---|
353 | (test* "set to 1" 1 (mecab-get-all-morphs mecab)) |
---|
354 | (mecab-set-all-morphs mecab 0) |
---|
355 | (test* "set to 0" 0 (mecab-get-all-morphs mecab)) |
---|
356 | ) |
---|
357 | |
---|
358 | ;;;;;;;;;; |
---|
359 | ;; |
---|
360 | ;; TO DO |
---|
361 | ;; |
---|
362 | ;;(test-section "mecab-do") |
---|
363 | ;;(test-section "mecab-dict-index") |
---|
364 | ;;(test-section "mecab-dict-gen") |
---|
365 | ;;(test-section "mecab-cost-train") |
---|
366 | ;;(test-section "mecab-system-eval") |
---|
367 | ;;(test-section "mecab-test-gen") |
---|
368 | |
---|
369 | ;;; |
---|
370 | ;;; tagger (message passing) |
---|
371 | ;;; |
---|
372 | (test-section "tagger") |
---|
373 | (let1 tagger (mecab-tagger "") |
---|
374 | (test* "tagger'parse-to-string" |
---|
375 | (string-join '("今日\t名詞,副詞可能,*,*,*,*,今日,キョウ,キョー" |
---|
376 | "も\t助詞,係助詞,*,*,*,*,も,モ,モ" |
---|
377 | "し\t動詞,自立,*,*,サ変・スル,未然形,する,シ,シ" |
---|
378 | "ない\t助動詞,*,*,*,特殊・ナイ,基本形,ない,ナイ,ナイ" |
---|
379 | "と\t助詞,接続助詞,*,*,*,*,と,ト,ト" |
---|
380 | "ね\t助詞,終助詞,*,*,*,*,ね,ネ,ネ" |
---|
381 | "EOS" |
---|
382 | "") "\n") |
---|
383 | ([tagger'parse-to-string] "今日もしないとね")) |
---|
384 | |
---|
385 | (let1 node ([tagger'parse-to-node] "今日もしないとね") |
---|
386 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
387 | (test* "mecab-node-surface" "" (mecab-node-surface node)) |
---|
388 | (test* "mecab-node-feature" "BOS/EOS,*,*,*,*,*,*,*,*" (mecab-node-feature node)) |
---|
389 | (test* "mecab-node-cost" 0 (mecab-node-cost node)) |
---|
390 | |
---|
391 | (set! node (mecab-node-next node)) |
---|
392 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
393 | (test* "mecab-node-surface" "今日" (mecab-node-surface node)) |
---|
394 | (test* "mecab-node-feature" "名詞,副詞可能,*,*,*,*,今日,キョウ,キョー" (mecab-node-feature node)) |
---|
395 | (test* "mecab-node-cost" 3947 (mecab-node-cost node)) |
---|
396 | ;;(test* "format-node" "" ([tagger'format-node] node)) |
---|
397 | |
---|
398 | (set! node (mecab-node-next node)) |
---|
399 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
400 | (test* "mecab-node-surface" "も" (mecab-node-surface node)) |
---|
401 | (test* "mecab-node-feature" "助詞,係助詞,*,*,*,*,も,モ,モ" (mecab-node-feature node)) |
---|
402 | (test* "mecab-node-cost" 5553 (mecab-node-cost node)) |
---|
403 | |
---|
404 | (set! node (mecab-node-next node)) |
---|
405 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
406 | (test* "mecab-node-surface" "し" (mecab-node-surface node)) |
---|
407 | (test* "mecab-node-feature" "動詞,自立,*,*,サ変・スル,未然形,する,シ,シ" (mecab-node-feature node)) |
---|
408 | (test* "mecab-node-cost" 11566 (mecab-node-cost node)) |
---|
409 | |
---|
410 | (set! node (mecab-node-next node)) |
---|
411 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
412 | (test* "mecab-node-surface" "ない" (mecab-node-surface node)) |
---|
413 | (test* "mecab-node-feature" "助動詞,*,*,*,特殊・ナイ,基本形,ない,ナイ,ナイ" (mecab-node-feature node)) |
---|
414 | (test* "mecab-node-cost" 3601 (mecab-node-cost node)) |
---|
415 | |
---|
416 | (set! node (mecab-node-next node)) |
---|
417 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
418 | (test* "mecab-node-surface" "と" (mecab-node-surface node)) |
---|
419 | (test* "mecab-node-feature" "助詞,接続助詞,*,*,*,*,と,ト,ト" (mecab-node-feature node)) |
---|
420 | (test* "mecab-node-cost" 4716 (mecab-node-cost node)) |
---|
421 | |
---|
422 | (set! node (mecab-node-next node)) |
---|
423 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
424 | (test* "mecab-node-surface" "ね" (mecab-node-surface node)) |
---|
425 | (test* "mecab-node-feature" "助詞,終助詞,*,*,*,*,ね,ネ,ネ" (mecab-node-feature node)) |
---|
426 | (test* "mecab-node-cost" 10676 (mecab-node-cost node)) |
---|
427 | |
---|
428 | (set! node (mecab-node-next node)) |
---|
429 | (test* "mecab-node?" #t (mecab-node? node)) |
---|
430 | (test* "mecab-node-surface" "" (mecab-node-surface node)) |
---|
431 | (test* "mecab-node-feature" "BOS/EOS,*,*,*,*,*,*,*,*" (mecab-node-feature node)) |
---|
432 | (test* "mecab-node-cost" 8292 (mecab-node-cost node)) |
---|
433 | |
---|
434 | (set! node (mecab-node-next node)) |
---|
435 | (test* "mecab-node?" #f (mecab-node? node)) |
---|
436 | )) |
---|
437 | |
---|
438 | ;; epilogue |
---|
439 | (test-end) |
---|