sekka 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +22 -0
- data/bin/.gitignore +1 -0
- data/bin/sekka-jisyo +98 -0
- data/bin/sekka-server +83 -0
- data/emacs/http-cookies.el +416 -0
- data/emacs/http-get.el +448 -0
- data/emacs/sekka.el +1069 -0
- data/lib/sekka/alphabet-lib.nnd +59 -0
- data/lib/sekka/approximatesearch.rb +72 -0
- data/lib/sekka/convert-jisyo.nnd +129 -0
- data/lib/sekka/henkan.nnd +464 -0
- data/lib/sekka/jisyo-db.nnd +184 -0
- data/lib/sekka/kvs.rb +135 -0
- data/lib/sekka/roman-lib.nnd +660 -0
- data/lib/sekka/sekkaversion.rb +6 -0
- data/lib/sekka/util.nnd +64 -0
- data/lib/sekka.ru +36 -0
- data/lib/sekkaconfig.rb +62 -0
- data/lib/sekkaserver.rb +127 -0
- data/test/alphabet-lib.nnd +188 -0
- data/test/approximate-bench.nnd +83 -0
- data/test/common.nnd +51 -0
- data/test/henkan-main.nnd +942 -0
- data/test/jisyo.nnd +94 -0
- data/test/roman-lib.nnd +422 -0
- data/test/util.nnd +100 -0
- metadata +223 -0
data/test/jisyo.nnd
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
;;-*- mode: nendo; syntax: scheme -*-
|
2
|
+
;;;
|
3
|
+
;;; jisyo.nnd - SKK-JISYO形式からSEKKA-JISYO形式への変換部のテストスイート
|
4
|
+
;;;
|
5
|
+
;;; Copyright (c) 2010 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
6
|
+
;;;
|
7
|
+
;;; Redistribution and use in source and binary forms, with or without
|
8
|
+
;;; modification, are permitted provided that the following conditions
|
9
|
+
;;; are met:
|
10
|
+
;;;
|
11
|
+
;;; 1. Redistributions of source code must retain the above copyright
|
12
|
+
;;; notice, this list of conditions and the following disclaimer.
|
13
|
+
;;;
|
14
|
+
;;; 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
;;; notice, this list of conditions and the following disclaimer in the
|
16
|
+
;;; documentation and/or other materials provided with the distribution.
|
17
|
+
;;;
|
18
|
+
;;; 3. Neither the name of the authors nor the names of its contributors
|
19
|
+
;;; may be used to endorse or promote products derived from this
|
20
|
+
;;; software without specific prior written permission.
|
21
|
+
;;;
|
22
|
+
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
23
|
+
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
24
|
+
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
25
|
+
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
26
|
+
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
27
|
+
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
28
|
+
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
29
|
+
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
30
|
+
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
31
|
+
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
32
|
+
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
;;;
|
34
|
+
;;; $Id:
|
35
|
+
;;;
|
36
|
+
(use nendo.test)
|
37
|
+
(use sekka.convert-jisyo)
|
38
|
+
|
39
|
+
(define debug-print-length 10000)
|
40
|
+
|
41
|
+
(test-start "jisyo converter")
|
42
|
+
|
43
|
+
;;===================================================================
|
44
|
+
|
45
|
+
;;-------------------------------------------------------------------
|
46
|
+
(test-section "SKK2Sekka Convert")
|
47
|
+
|
48
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りなし1)"
|
49
|
+
'(("ai" . "Cあい") ("あい" . "/愛/哀/相/挨"))
|
50
|
+
(expand-okuri-nashi-entry "あい" "/愛/哀/相/挨"))
|
51
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りなし2)"
|
52
|
+
'(("un" . "Cうん") ("unn" . "Cうん") ("uq" . "Cうん") ("うん" . "/云/運/雲"))
|
53
|
+
(expand-okuri-nashi-entry "うん" "/云/運/雲"))
|
54
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りなし3)"
|
55
|
+
'(("ko-hi-" . "Cこーひー") ("ko-hi:" . "Cこーひー") ("ko-hi^" . "Cこーひー") ("ko:hi-" . "Cこーひー") ("ko:hi:" . "Cこーひー") ("ko:hi^" . "Cこーひー") ("ko^hi-" . "Cこーひー") ("ko^hi:" . "Cこーひー") ("ko^hi^" . "Cこーひー") ("こーひー" . "/コーヒー"))
|
56
|
+
(expand-okuri-nashi-entry "こーひー" "/コーヒー"))
|
57
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りなし4)"
|
58
|
+
'(("ka;ko" . "Cかっこ") ("ka@ko" . "Cかっこ") ("kakko" . "Cかっこ") ("かっこ" . "/確固/括弧/各個/各戸/確乎/羯鼓;雅楽の打楽器/格好/『/』;二重鉤括弧"))
|
59
|
+
(expand-okuri-nashi-entry "かっこ" "/確固/括弧/各個/各戸/確乎/羯鼓;雅楽の打楽器/格好/『/』;二重鉤括弧"))
|
60
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りなし5)"
|
61
|
+
#f
|
62
|
+
(expand-okuri-nashi-entry "すたんでぃんぐおべーしょん" "/スタンディングオベーション"))
|
63
|
+
|
64
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りあり1)"
|
65
|
+
'(("shiroI" . "Cしろi") ("siroI" . "Cしろi") ("しろi" . "/白"))
|
66
|
+
(expand-okuri-ari-entry "しろ" "i" "/白"))
|
67
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りあり2)"
|
68
|
+
'(("kaK" . "Cかk") ("かk" . "/書/掛/欠/架/駆/懸"))
|
69
|
+
(expand-okuri-ari-entry "か" "k" "/書/掛/欠/架/駆/懸"))
|
70
|
+
(test* "expanding SKK(1) entry to SEKKA(n) entry. (送りあり3)"
|
71
|
+
'(("kaT" . "Cかt") ("かt" . "/勝/買/飼/刈;(crop)草を刈る/狩;(hunt)兎を狩る/且;-つて/駆;バイクを駆って/交;飛び交って/克;(overcome) 逆境に克つ/糅;-てて加えて/苅;「刈」の異体字/驅;「駆」の旧字/支;ささえる/上;(尺八の)カリ⇔減り(メリ)/搗") ("ka`" . "Cか`") ("か`" . "/勝/買/飼/刈;(crop)草を刈る/狩;(hunt)兎を狩る/且;-つて/駆;バイクを駆って/交;飛び交って/克;(overcome) 逆境に克つ/糅;-てて加えて/苅;「刈」の異体字/驅;「駆」の旧字/支;ささえる/上;(尺八の)カリ⇔減り(メリ)/搗") ("ka+" . "Cか+") ("か+" . "/勝/買/飼/刈;(crop)草を刈る/狩;(hunt)兎を狩る/且;-つて/駆;バイクを駆って/交;飛び交って/克;(overcome) 逆境に克つ/糅;-てて加えて/苅;「刈」の異体字/驅;「駆」の旧字/支;ささえる/上;(尺八の)カリ⇔減り(メリ)/搗"))
|
72
|
+
(expand-okuri-ari-entry "か" "t" "/勝/買/飼/刈;(crop)草を刈る/狩;(hunt)兎を狩る/且;-つて/駆;バイクを駆って/交;飛び交って/克;(overcome) 逆境に克つ/糅;-てて加えて/苅;「刈」の異体字/驅;「駆」の旧字/支;ささえる/上;(尺八の)カリ⇔減り(メリ)/搗"))
|
73
|
+
|
74
|
+
(let1 _input (StringIO.new
|
75
|
+
(string-join
|
76
|
+
'(
|
77
|
+
";; コメント"
|
78
|
+
";; コメント コメント コメント コメント コメント "
|
79
|
+
"しろi /白/"
|
80
|
+
"あい /愛/哀/相/挨/"
|
81
|
+
"Greek /Α/Β/Γ/Δ/Ε/Ζ/Η/Θ/Ι/Κ/Λ/Μ/Ν/Ξ/Ο/Π/Ρ/Σ/Τ/Υ/Φ/Χ/Ψ/Ω/"
|
82
|
+
">あん /案/"
|
83
|
+
">やすi /易/"
|
84
|
+
"! /!/感嘆符/"
|
85
|
+
"? /?/"
|
86
|
+
"こーひー /コーヒー/"
|
87
|
+
)
|
88
|
+
"\n"))
|
89
|
+
(test* "convert SKK file to SEKKA jisyo file. (1)"
|
90
|
+
'("shiroI Cしろi" "siroI Cしろi" "しろi /白" "ai Cあい" "あい /愛/哀/相/挨" "Greek /Α/Β/Γ/Δ/Ε/Ζ/Η/Θ/Ι/Κ/Λ/Μ/Ν/Ξ/Ο/Π/Ρ/Σ/Τ/Υ/Φ/Χ/Ψ/Ω" ">an C>あん" ">ann C>あん" ">aq C>あん" ">あん /案" ">yasuI C>やすi" ">やすi /易" "! /!/感嘆符" "? /?" "ko-hi- Cこーひー" "ko-hi: Cこーひー" "ko-hi^ Cこーひー" "ko:hi- Cこーひー" "ko:hi: Cこーひー" "ko:hi^ Cこーひー" "ko^hi- Cこーひー" "ko^hi: Cこーひー" "ko^hi^ Cこーひー" "こーひー /コーヒー")
|
91
|
+
(convert-skk-jisyo-f _input)))
|
92
|
+
|
93
|
+
;;===================================================================
|
94
|
+
(test-end)
|
data/test/roman-lib.nnd
ADDED
@@ -0,0 +1,422 @@
|
|
1
|
+
;;-*- mode: nendo; syntax: scheme -*-
|
2
|
+
;;;
|
3
|
+
;;; roman-lib.nnd - ローマ字ライブラリ部のテストスイート
|
4
|
+
;;;
|
5
|
+
;;; Copyright (c) 2010 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
6
|
+
;;;
|
7
|
+
;;; Redistribution and use in source and binary forms, with or without
|
8
|
+
;;; modification, are permitted provided that the following conditions
|
9
|
+
;;; are met:
|
10
|
+
;;;
|
11
|
+
;;; 1. Redistributions of source code must retain the above copyright
|
12
|
+
;;; notice, this list of conditions and the following disclaimer.
|
13
|
+
;;;
|
14
|
+
;;; 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
;;; notice, this list of conditions and the following disclaimer in the
|
16
|
+
;;; documentation and/or other materials provided with the distribution.
|
17
|
+
;;;
|
18
|
+
;;; 3. Neither the name of the authors nor the names of its contributors
|
19
|
+
;;; may be used to endorse or promote products derived from this
|
20
|
+
;;; software without specific prior written permission.
|
21
|
+
;;;
|
22
|
+
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
23
|
+
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
24
|
+
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
25
|
+
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
26
|
+
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
27
|
+
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
28
|
+
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
29
|
+
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
30
|
+
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
31
|
+
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
32
|
+
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
;;;
|
34
|
+
;;; $Id:
|
35
|
+
;;;
|
36
|
+
(use nendo.test)
|
37
|
+
(use sekka.roman-lib)
|
38
|
+
(test-start "roman-lib")
|
39
|
+
|
40
|
+
;;===================================================================
|
41
|
+
|
42
|
+
;;-------------------------------------------------------------------
|
43
|
+
(test-section "upcase and downcase conversion")
|
44
|
+
(test* "downcase 1"
|
45
|
+
"aabbccddeeffgg"
|
46
|
+
(sekka-downcase "aAbBcCdDeEfFgG"))
|
47
|
+
(test* "downcase 2"
|
48
|
+
"aaa@@@@@@bbb"
|
49
|
+
(sekka-downcase "AAA@@@```BBB"))
|
50
|
+
(test* "downcase 3"
|
51
|
+
"aaa;;;;;;bbb"
|
52
|
+
(sekka-downcase "AAA+++;;;BBB"))
|
53
|
+
(test* "upcase 1"
|
54
|
+
"AABBCCDDEEFFGG"
|
55
|
+
(sekka-upcase "aAbBcCdDeEfFgG"))
|
56
|
+
(test* "upcase 2"
|
57
|
+
"AAA``````BBB"
|
58
|
+
(sekka-upcase "AAA@@@```BBB"))
|
59
|
+
(test* "upcase 2"
|
60
|
+
"AAA++++++BBB"
|
61
|
+
(sekka-upcase "AAA+++;;;BBB"))
|
62
|
+
|
63
|
+
|
64
|
+
;;-------------------------------------------------------------------
|
65
|
+
(test-section "kana->roman conversion hash (short)")
|
66
|
+
|
67
|
+
(test* "kana->roman 1"
|
68
|
+
'("fu" "hu")
|
69
|
+
(hash-table-get sekka-kana->roman-hash-short "ふ" #f))
|
70
|
+
(test* "kana->roman 2"
|
71
|
+
'("la")
|
72
|
+
(hash-table-get sekka-kana->roman-hash-short "ぁ" #f))
|
73
|
+
(test* "kana->roman 3"
|
74
|
+
'("chi" "tyi" "ti")
|
75
|
+
(hash-table-get sekka-kana->roman-hash-short "ち" #f))
|
76
|
+
(test* "kana->roman 4"
|
77
|
+
'("tt" "@" ";" "ltu")
|
78
|
+
(hash-table-get sekka-kana->roman-hash-short "っ" #f))
|
79
|
+
(test* "kana->roman 5"
|
80
|
+
'("-" "^" ":")
|
81
|
+
(hash-table-get sekka-kana->roman-hash-short "ー" #f))
|
82
|
+
|
83
|
+
;;-------------------------------------------------------------------
|
84
|
+
(test-section "kana->roman conversion hash (long)")
|
85
|
+
|
86
|
+
(test* "kana->roman 1"
|
87
|
+
'("kz" "kn")
|
88
|
+
(hash-table-get sekka-kana->roman-hash-long "かん" #f))
|
89
|
+
(test* "kana->roman 2"
|
90
|
+
'("kt")
|
91
|
+
(hash-table-get sekka-kana->roman-hash-long "こと" #f))
|
92
|
+
(test* "kana->roman 3"
|
93
|
+
'("ffu" "hhu" "@fu" "@hu" ";fu" ";hu")
|
94
|
+
(hash-table-get sekka-kana->roman-hash-long "っふ" #f))
|
95
|
+
|
96
|
+
;;-------------------------------------------------------------------
|
97
|
+
(test-section "roman->kana conversion hash (short)")
|
98
|
+
|
99
|
+
(test* "roman->kana 1"
|
100
|
+
'("あ")
|
101
|
+
(hash-table-get sekka-roman->kana-hash-short "a" #f))
|
102
|
+
(test* "roman->kana 2"
|
103
|
+
'("っぎゃ")
|
104
|
+
(hash-table-get sekka-roman->kana-hash-short "ggya" #f))
|
105
|
+
(test* "roman->kana 3"
|
106
|
+
'("し")
|
107
|
+
(hash-table-get sekka-roman->kana-hash-short "si" #f))
|
108
|
+
(test* "roman->kana 4"
|
109
|
+
'("ー")
|
110
|
+
(hash-table-get sekka-roman->kana-hash-short "-" #f))
|
111
|
+
(test* "roman->kana 5"
|
112
|
+
'("ー")
|
113
|
+
(hash-table-get sekka-roman->kana-hash-short ":" #f))
|
114
|
+
(test* "roman->kana 6"
|
115
|
+
'("っ")
|
116
|
+
(hash-table-get sekka-roman->kana-hash-short "ltu" #f))
|
117
|
+
(test* "roman->kana 7"
|
118
|
+
'("っ")
|
119
|
+
(hash-table-get sekka-roman->kana-hash-short "@" #f))
|
120
|
+
(test* "roman->kana 8"
|
121
|
+
'("っ")
|
122
|
+
(hash-table-get sekka-roman->kana-hash-short ";" #f))
|
123
|
+
|
124
|
+
;;-------------------------------------------------------------------
|
125
|
+
(test-section "roman->kana conversion hash (long)")
|
126
|
+
|
127
|
+
(test* "roman->kana 1"
|
128
|
+
'("かん")
|
129
|
+
(hash-table-get sekka-roman->kana-hash-long "kn" #f))
|
130
|
+
(test* "roman->kana 2"
|
131
|
+
'("かん")
|
132
|
+
(hash-table-get sekka-roman->kana-hash-long "kz" #f))
|
133
|
+
(test* "roman->kana 3"
|
134
|
+
'("こと")
|
135
|
+
(hash-table-get sekka-roman->kana-hash-long "kt" #f))
|
136
|
+
(test* "roman->kana 4"
|
137
|
+
'("です")
|
138
|
+
(hash-table-get sekka-roman->kana-hash-long "ds" #f))
|
139
|
+
(test* "roman->kana 5"
|
140
|
+
'("ます")
|
141
|
+
(hash-table-get sekka-roman->kana-hash-long "ms" #f))
|
142
|
+
(test* "roman->kana 6"
|
143
|
+
'("なん")
|
144
|
+
(hash-table-get sekka-roman->kana-hash-long "nz" #f))
|
145
|
+
(test* "roman->kana 7"
|
146
|
+
'("ふぉん")
|
147
|
+
(hash-table-get sekka-roman->kana-hash-long "fl" #f))
|
148
|
+
|
149
|
+
;;-------------------------------------------------------------------
|
150
|
+
(test-section "hiragana<->katanaka conversion functions")
|
151
|
+
|
152
|
+
(test* "hiragana->katakana 1"
|
153
|
+
"アイウエオーァィゥェォッ"
|
154
|
+
(gen-hiragana->katakana "あいうえおーぁぃぅぇぉっ"))
|
155
|
+
(test* "hiragana->katakana 2"
|
156
|
+
"パイナップル"
|
157
|
+
(gen-hiragana->katakana "ぱいなっぷる"))
|
158
|
+
(test* "hiragana->katakana 3"
|
159
|
+
"アメニモマケズ"
|
160
|
+
(gen-hiragana->katakana "あめにもまけず"))
|
161
|
+
|
162
|
+
(test* "hiragana->katakana 1"
|
163
|
+
"あいうえおーぁぃぅぇぉっ"
|
164
|
+
(gen-katakana->hiragana "アイウエオーァィゥェォッ"))
|
165
|
+
(test* "hiragana->katakana 2"
|
166
|
+
"ありがとうございます"
|
167
|
+
(gen-katakana->hiragana "アリガトウゴザイマス"))
|
168
|
+
(test* "hiragana->katakana 3"
|
169
|
+
"いろはにほへとちりぬるを"
|
170
|
+
(gen-katakana->hiragana "イロハニホヘトチリヌルヲ"))
|
171
|
+
|
172
|
+
(test* "is katakana 1"
|
173
|
+
#t
|
174
|
+
(is-katakana "アメニモマケズ"))
|
175
|
+
(test* "is katakana 2"
|
176
|
+
#f
|
177
|
+
(is-katakana "englishア"))
|
178
|
+
(test* "is katakana 3"
|
179
|
+
#f
|
180
|
+
(is-katakana "アenglish"))
|
181
|
+
(test* "is katakana 4"
|
182
|
+
#f
|
183
|
+
(is-katakana "engアlish"))
|
184
|
+
(test* "is katakana 5"
|
185
|
+
#f
|
186
|
+
(is-katakana "あア"))
|
187
|
+
(test* "is katakana 6"
|
188
|
+
#f
|
189
|
+
(is-katakana "アメニEモマケズ"))
|
190
|
+
(test* "is katakana 7"
|
191
|
+
#t
|
192
|
+
(is-katakana "コーヒー"))
|
193
|
+
(test* "is hiragana 1"
|
194
|
+
#t
|
195
|
+
(is-hiragana "ひらがなのぶんしょう"))
|
196
|
+
(test* "is hiragana 2"
|
197
|
+
#f
|
198
|
+
(is-hiragana "ひらがなノぶんしょう"))
|
199
|
+
(test* "is hiragana 3"
|
200
|
+
#f
|
201
|
+
(is-hiragana "Eひらがなのぶんしょう"))
|
202
|
+
(test* "is hiragana 4"
|
203
|
+
#f
|
204
|
+
(is-hiragana "ひらがなEのぶんしょう"))
|
205
|
+
(test* "is hiragana 5"
|
206
|
+
#f
|
207
|
+
(is-hiragana "ひらがなのぶんしょうE"))
|
208
|
+
(test* "is hiragana 6"
|
209
|
+
#f
|
210
|
+
(is-hiragana "あア"))
|
211
|
+
(test* "is hiragana 7"
|
212
|
+
#t
|
213
|
+
(is-hiragana "こーひー"))
|
214
|
+
(test* "is hiragana-and-okuri 1"
|
215
|
+
#t
|
216
|
+
(is-hiragana-and-okuri "あr"))
|
217
|
+
(test* "is hiragana-and-okuri 2"
|
218
|
+
#f
|
219
|
+
(is-hiragana-and-okuri "あ"))
|
220
|
+
(test* "is hiragana-and-okuri 3"
|
221
|
+
#t
|
222
|
+
(is-hiragana-and-okuri "おこなu"))
|
223
|
+
(test* "is hiragana-and-okuri 4"
|
224
|
+
#f
|
225
|
+
(is-hiragana-and-okuri "おこなU"))
|
226
|
+
(test* "is hiragana-and-okuri 5"
|
227
|
+
#f
|
228
|
+
(is-hiragana-and-okuri "a"))
|
229
|
+
(test* "is hiragana-and-okuri 6"
|
230
|
+
#f
|
231
|
+
(is-hiragana-and-okuri "au"))
|
232
|
+
(test* "is hiragana-and-okuri 7"
|
233
|
+
#f
|
234
|
+
(is-hiragana-and-okuri "1"))
|
235
|
+
(test* "is hiragana-and-okuri 8"
|
236
|
+
#f
|
237
|
+
(is-hiragana-and-okuri "123"))
|
238
|
+
|
239
|
+
;;-------------------------------------------------------------------
|
240
|
+
(test-section "drop okurigana functions")
|
241
|
+
(test* "drop okri 1"
|
242
|
+
"行"
|
243
|
+
(drop-okuri "行う"))
|
244
|
+
(test* "drop okri 2"
|
245
|
+
"行"
|
246
|
+
(drop-okuri "行なう"))
|
247
|
+
(test* "drop okri 3"
|
248
|
+
"見"
|
249
|
+
(drop-okuri "見る"))
|
250
|
+
(test* "drop okri 4"
|
251
|
+
"変化"
|
252
|
+
(drop-okuri "変化する"))
|
253
|
+
(test* "drop okri 5"
|
254
|
+
"見付"
|
255
|
+
(drop-okuri "見付ける"))
|
256
|
+
|
257
|
+
;;-------------------------------------------------------------------
|
258
|
+
(test-section "kana->roman conversion functions")
|
259
|
+
|
260
|
+
(let1 hira-list
|
261
|
+
(hash-table-keys sekka-kana->roman-hash-long)
|
262
|
+
(test* "kana->roman table length" 402 (length hira-list))
|
263
|
+
(test* "kana->roman key duplicate check" 402 (length (uniq (sort hira-list)))))
|
264
|
+
|
265
|
+
(test* "hiragana -> roman-pattern0"
|
266
|
+
'(
|
267
|
+
(("ka") ("nn" "n" "q"))
|
268
|
+
(("kz" "kn")))
|
269
|
+
(gen-hiragana->roman-pattens "かん"))
|
270
|
+
(test* "hiragana -> roman-pattern1"
|
271
|
+
'(
|
272
|
+
(("ka") ("nn" "n" "q") ("ji" "zi"))
|
273
|
+
(("kz" "kn") ("ji" "zi")))
|
274
|
+
(gen-hiragana->roman-pattens "かんじ"))
|
275
|
+
(test* "hiragana -> roman-pattern2"
|
276
|
+
'(
|
277
|
+
(("he") ("nn" "n" "q") ("ka") ("nn" "n" "q"))
|
278
|
+
(("hd") ("kz" "kn")))
|
279
|
+
(gen-hiragana->roman-pattens "へんかん"))
|
280
|
+
(test* "hiragana -> roman-pattern3"
|
281
|
+
'(
|
282
|
+
(("ka") ("nn" "n" "q") ("ji" "zi") ("he") ("nn" "n" "q") ("ka") ("nn" "n" "q"))
|
283
|
+
(("kz" "kn") ("ji" "zi") ("hd") ("kz" "kn")))
|
284
|
+
(gen-hiragana->roman-pattens "かんじへんかん"))
|
285
|
+
(test* "hiragana -> roman-pattern4"
|
286
|
+
'((("shi" "si") ("ze") ("nn" "n" "q") ("ge") ("nn" "n" "q") ("go") ("sho" "syo" "xo") ("ri"))
|
287
|
+
(("shi" "si") ("zd") ("gd") ("go") ("sho" "syo" "xo") ("ri")))
|
288
|
+
(gen-hiragana->roman-pattens "しぜんげんごしょり"))
|
289
|
+
(test* "hiragana -> roman-pattern5"
|
290
|
+
'((("ka") ("kko" "@ko" ";ko")))
|
291
|
+
(gen-hiragana->roman-pattens "かっこ"))
|
292
|
+
|
293
|
+
(test* "patterns -> roman-list1"
|
294
|
+
'("kanji" "kannji" "kannzi" "kanzi" "kaqji" "kaqzi" "knji" "knzi" "kzji" "kzzi")
|
295
|
+
(patterns->roman-list '(
|
296
|
+
(("ka") ("nn" "n" "q") ("ji" "zi"))
|
297
|
+
(("kz" "kn") ("ji" "zi")))))
|
298
|
+
|
299
|
+
(test* "patterns -> roman-list2"
|
300
|
+
'("shizdgdgoshori" "shizdgdgosyori" "shizdgdgoxori" "shizengengoshori" "shizengengosyori" "shizengengoxori" "shizengenngoshori" "shizengenngosyori" "shizengenngoxori" "shizengeqgoshori" "shizengeqgosyori" "shizengeqgoxori" "shizenngengoshori" "shizenngengosyori" "shizenngengoxori" "shizenngenngoshori" "shizenngenngosyori" "shizenngenngoxori" "shizenngeqgoshori" "shizenngeqgosyori" "shizenngeqgoxori" "shizeqgengoshori" "shizeqgengosyori" "shizeqgengoxori" "shizeqgenngoshori" "shizeqgenngosyori" "shizeqgenngoxori" "shizeqgeqgoshori" "shizeqgeqgosyori" "shizeqgeqgoxori" "sizdgdgoshori" "sizdgdgosyori" "sizdgdgoxori" "sizengengoshori" "sizengengosyori" "sizengengoxori" "sizengenngoshori" "sizengenngosyori" "sizengenngoxori" "sizengeqgoshori" "sizengeqgosyori" "sizengeqgoxori" "sizenngengoshori" "sizenngengosyori" "sizenngengoxori" "sizenngenngoshori" "sizenngenngosyori" "sizenngenngoxori" "sizenngeqgoshori" "sizenngeqgosyori" "sizenngeqgoxori" "sizeqgengoshori" "sizeqgengosyori" "sizeqgengoxori" "sizeqgenngoshori" "sizeqgenngosyori" "sizeqgenngoxori" "sizeqgeqgoshori" "sizeqgeqgosyori" "sizeqgeqgoxori")
|
301
|
+
(patterns->roman-list '(
|
302
|
+
(("shi" "si") ("ze") ("nn" "n" "q") ("ge") ("nn" "n" "q") ("go") ("sho" "syo" "xo") ("ri"))
|
303
|
+
(("shi" "si") ("zd") ("gd") ("go") ("sho" "syo" "xo") ("ri")))))
|
304
|
+
|
305
|
+
(test* "hiragana -> roman-list1"
|
306
|
+
'("kanji" "kannji" "kannzi" "kanzi" "kaqji" "kaqzi" "knji" "knzi" "kzji" "kzzi")
|
307
|
+
(gen-hiragana->roman-list "かんじ"))
|
308
|
+
|
309
|
+
(test* "hiragana -> roman-list2"
|
310
|
+
'("nishiyama" "nisiyama")
|
311
|
+
(gen-hiragana->roman-list "にしやま"))
|
312
|
+
|
313
|
+
(test* "hiragana -> roman-list3"
|
314
|
+
'("toukgou" "toukyou" "tpkgou" "tpkyou")
|
315
|
+
(gen-hiragana->roman-list "とうきょう"))
|
316
|
+
|
317
|
+
(test* "hiragana -> roman-list4"
|
318
|
+
'("ko-hi-" "ko-hi:" "ko-hi^" "ko:hi-" "ko:hi:" "ko:hi^" "ko^hi-" "ko^hi:" "ko^hi^")
|
319
|
+
(gen-hiragana->roman-list "こーひー"))
|
320
|
+
|
321
|
+
(test* "hiragana -> roman-list5"
|
322
|
+
'("tsumiki" "tumiki")
|
323
|
+
(gen-hiragana->roman-list "つみき"))
|
324
|
+
|
325
|
+
|
326
|
+
;;-------------------------------------------------------------------
|
327
|
+
(test-section "roman->kana conversion functions")
|
328
|
+
(test* "roman -> hiragana 1"
|
329
|
+
'("つみき")
|
330
|
+
(gen-roman->hiragana "tsumiki" :normal))
|
331
|
+
(test* "roman -> hiragana 2"
|
332
|
+
'("こーひー")
|
333
|
+
(gen-roman->hiragana "ko-hi-" :normal))
|
334
|
+
(test* "roman -> hiragana 3"
|
335
|
+
'("かんじ" "かぬんい")
|
336
|
+
(gen-roman->hiragana "kanji" :normal))
|
337
|
+
(test* "roman -> hiragana 4"
|
338
|
+
'("かぬんい" "かんじ")
|
339
|
+
(gen-roman->hiragana "kanji" :azik))
|
340
|
+
(test* "roman -> hiragana 5"
|
341
|
+
'("かんじ")
|
342
|
+
(gen-roman->hiragana "kannji" :normal))
|
343
|
+
(test* "roman -> hiragana 6"
|
344
|
+
'("ちゃんじ" "ちゃなんい")
|
345
|
+
(gen-roman->hiragana "canzi" :normal))
|
346
|
+
(test* "roman -> hiragana 7"
|
347
|
+
'("ちゃなんい" "ちゃんじ")
|
348
|
+
(gen-roman->hiragana "canzi" :azik))
|
349
|
+
(test* "roman -> hiragana 8"
|
350
|
+
'("とうきょうとっきょきょかきょく")
|
351
|
+
(gen-roman->hiragana "toukyoutokkyokyokakyoku" :normal))
|
352
|
+
(test* "roman -> hiragana 9"
|
353
|
+
'("はっぴょうってきょうかぁ")
|
354
|
+
(gen-roman->hiragana "happyouttekyoukala" :normal))
|
355
|
+
(test* "roman -> hiragana 10"
|
356
|
+
'("はっぴょうってきょうかぁ")
|
357
|
+
(gen-roman->hiragana "ha@pyou@tekyoukala" :normal))
|
358
|
+
(test* "roman -> hiragana 11"
|
359
|
+
'("かんじ")
|
360
|
+
(gen-roman->hiragana "knji" :normal))
|
361
|
+
(test* "roman -> hiragana 12"
|
362
|
+
'("かっこ")
|
363
|
+
(gen-roman->hiragana "ka@ko" :normal))
|
364
|
+
(test* "roman -> hiragana 13"
|
365
|
+
'("こーひー")
|
366
|
+
(gen-roman->hiragana "ko:hi:" :normal))
|
367
|
+
(test* "roman -> hiragana 14"
|
368
|
+
'()
|
369
|
+
(gen-roman->hiragana "b" :normal))
|
370
|
+
(test* "roman -> hiragana 15"
|
371
|
+
'("んんんん")
|
372
|
+
(gen-roman->hiragana "nnqnnq" :normal))
|
373
|
+
(test* "roman -> hiragana 16"
|
374
|
+
'("んんんん" "ないない")
|
375
|
+
(gen-roman->hiragana "nqnq" :normal))
|
376
|
+
(test* "roman -> hiragana 17"
|
377
|
+
'("ないない" "んんんん")
|
378
|
+
(gen-roman->hiragana "nqnq" :azik))
|
379
|
+
(test* "roman -> hiragana 18"
|
380
|
+
'("そうです")
|
381
|
+
(gen-roman->hiragana "spds" :normal))
|
382
|
+
(test* "roman -> hiragana 19"
|
383
|
+
'("そうです")
|
384
|
+
(gen-roman->hiragana "spds" :azik))
|
385
|
+
(test* "roman -> hiragana 20"
|
386
|
+
'("もうしょ")
|
387
|
+
(gen-roman->hiragana "mpxo" :normal))
|
388
|
+
(test* "roman -> hiragana 21"
|
389
|
+
'("もうしょ")
|
390
|
+
(gen-roman->hiragana "mpxo" :azik))
|
391
|
+
(test* "roman -> hiragana 22"
|
392
|
+
'("ものこと")
|
393
|
+
(gen-roman->hiragana "mnkt" :normal))
|
394
|
+
(test* "roman -> hiragana 23"
|
395
|
+
'("ものこと")
|
396
|
+
(gen-roman->hiragana "mnkt" :azik))
|
397
|
+
(test* "roman -> hiragana 24"
|
398
|
+
'("しぜんげんごしょり" "しぜにぇにょしょり")
|
399
|
+
(gen-roman->hiragana "shizengengosyori" :normal))
|
400
|
+
(test* "roman -> hiragana 25"
|
401
|
+
'("しぜにぇにょしょり" "しぜんげんごしょり")
|
402
|
+
(gen-roman->hiragana "shizengengosyori" :azik))
|
403
|
+
(test* "roman -> hiragana 26"
|
404
|
+
'("しぜんげんごしょり")
|
405
|
+
(gen-roman->hiragana "shizenngenngosyori" :normal))
|
406
|
+
(test* "roman -> hiragana 27"
|
407
|
+
'("かっこ")
|
408
|
+
(gen-roman->hiragana "ka@ko" :normal))
|
409
|
+
(test* "roman -> hiragana 28"
|
410
|
+
'("かった")
|
411
|
+
(gen-roman->hiragana "ka@ta" :normal))
|
412
|
+
(test* "roman -> hiragana 29"
|
413
|
+
'("かっこ")
|
414
|
+
(gen-roman->hiragana "ka;ko" :normal))
|
415
|
+
(test* "roman -> hiragana 30"
|
416
|
+
'("かった")
|
417
|
+
(gen-roman->hiragana "ka;ta" :normal))
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
;;===================================================================
|
422
|
+
(test-end)
|
data/test/util.nnd
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
;;-*- mode: nendo; syntax: scheme -*-
|
2
|
+
;;;
|
3
|
+
;;; util.nnd - ユーティリティー部のテストスイート
|
4
|
+
;;;
|
5
|
+
;;; Copyright (c) 2010 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
6
|
+
;;;
|
7
|
+
;;; Redistribution and use in source and binary forms, with or without
|
8
|
+
;;; modification, are permitted provided that the following conditions
|
9
|
+
;;; are met:
|
10
|
+
;;;
|
11
|
+
;;; 1. Redistributions of source code must retain the above copyright
|
12
|
+
;;; notice, this list of conditions and the following disclaimer.
|
13
|
+
;;;
|
14
|
+
;;; 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
;;; notice, this list of conditions and the following disclaimer in the
|
16
|
+
;;; documentation and/or other materials provided with the distribution.
|
17
|
+
;;;
|
18
|
+
;;; 3. Neither the name of the authors nor the names of its contributors
|
19
|
+
;;; may be used to endorse or promote products derived from this
|
20
|
+
;;; software without specific prior written permission.
|
21
|
+
;;;
|
22
|
+
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
23
|
+
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
24
|
+
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
25
|
+
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
26
|
+
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
27
|
+
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
28
|
+
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
29
|
+
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
30
|
+
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
31
|
+
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
32
|
+
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
;;;
|
34
|
+
;;; $Id:
|
35
|
+
;;;
|
36
|
+
(use nendo.test)
|
37
|
+
(use sekka.util)
|
38
|
+
|
39
|
+
(test-start "util")
|
40
|
+
|
41
|
+
;;===================================================================
|
42
|
+
|
43
|
+
;;-------------------------------------------------------------------
|
44
|
+
(test-section "string librarys")
|
45
|
+
|
46
|
+
(test* "string-drop 1"
|
47
|
+
"2345"
|
48
|
+
(string-drop "12345" 1))
|
49
|
+
(test* "string-drop 2"
|
50
|
+
""
|
51
|
+
(string-drop "12345" 5))
|
52
|
+
(test* "string-drop 3"
|
53
|
+
""
|
54
|
+
(string-drop "12345" 6))
|
55
|
+
(test* "string-drop 4"
|
56
|
+
"本語"
|
57
|
+
(string-drop "日本語" 1))
|
58
|
+
(test* "string-drop 5"
|
59
|
+
"自然言語処理"
|
60
|
+
(string-drop "統計的自然言語処理" 3))
|
61
|
+
(test* "string-split-first-and-rest 1"
|
62
|
+
'("1" . "2345")
|
63
|
+
(string-split-first-and-rest "12345"))
|
64
|
+
(test* "string-split-first-and-rest 2"
|
65
|
+
'("1" . "")
|
66
|
+
(string-split-first-and-rest "1"))
|
67
|
+
(test* "string-split-first-and-rest 3"
|
68
|
+
'("" . "")
|
69
|
+
(string-split-first-and-rest ""))
|
70
|
+
(test* "string-split-first-and-rest 4"
|
71
|
+
'("頭" . "とシッポ")
|
72
|
+
(string-split-first-and-rest "頭とシッポ"))
|
73
|
+
|
74
|
+
(test* "string-downcase-first 1"
|
75
|
+
"aBCDE"
|
76
|
+
(string-downcase-first "ABCDE"))
|
77
|
+
|
78
|
+
(test* "string-downcase-first 2"
|
79
|
+
"abcde"
|
80
|
+
(string-downcase-first "abcde"))
|
81
|
+
|
82
|
+
(test* "string-downcase-first 3"
|
83
|
+
"abcde"
|
84
|
+
(string-downcase-first "Abcde"))
|
85
|
+
|
86
|
+
(test* "string-downcase-first 4"
|
87
|
+
"a"
|
88
|
+
(string-downcase-first "A"))
|
89
|
+
|
90
|
+
(test* "string-downcase-first 5"
|
91
|
+
"あいうえお"
|
92
|
+
(string-downcase-first "あいうえお"))
|
93
|
+
|
94
|
+
(test* "string-downcase-first 6"
|
95
|
+
"aあいう"
|
96
|
+
(string-downcase-first "Aあいう"))
|
97
|
+
|
98
|
+
|
99
|
+
;;===================================================================
|
100
|
+
(test-end)
|