sekka 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sekka-path +2 -9
- data/bin/sekka-server +20 -6
- data/emacs/sekka.el +62 -22
- data/lib/sekka/henkan.nnd +26 -18
- data/lib/sekka/jisyo-db.nnd +1 -1
- data/lib/sekka/path.rb +6 -0
- data/lib/sekka/sekkaversion.rb +1 -1
- data/test/henkan-main.nnd +31 -0
- metadata +5 -4
data/bin/sekka-path
CHANGED
@@ -2,13 +2,6 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
|
6
|
-
x.match( /\/sekka[-]/ )
|
7
|
-
}
|
5
|
+
require 'sekka/path'
|
8
6
|
|
9
|
-
|
10
|
-
STDERR.puts "Error: gem of sekka is not installed yet..."
|
11
|
-
exit( 1 )
|
12
|
-
else
|
13
|
-
puts arr[0].sub( /\/lib$/, "" )
|
14
|
-
end
|
7
|
+
puts SekkaPath.path
|
data/bin/sekka-server
CHANGED
@@ -16,8 +16,9 @@ DICTURL = "http://sumibi.org/sekka/dict/" + SekkaVersion.version
|
|
16
16
|
PIDFILE = DICTDIR + "/pid"
|
17
17
|
|
18
18
|
TC_FILE = DICTDIR + "/SEKKA-JISYO.SMALL.tch"
|
19
|
+
TSVFILE = DICTDIR + "/SEKKA-JISYO.SMALL.tsv"
|
19
20
|
SUMFILE = DICTDIR + "/SEKKA-JISYO.SMALL.md5"
|
20
|
-
|
21
|
+
TSVURL = DICTURL + "/SEKKA-JISYO.SMALL.tsv"
|
21
22
|
SUMURL = DICTURL + "/SEKKA-JISYO.SMALL.md5"
|
22
23
|
|
23
24
|
TC_FILE_LIST = [ DICTDIR + "/SEKKA-JISYO.CUSTOM.tch",
|
@@ -50,7 +51,7 @@ def main
|
|
50
51
|
if not File.exist?( TC_FILE )
|
51
52
|
STDERR.printf( "Info: Downloading SEKKA-JISYO\n" )
|
52
53
|
# 辞書をダウンロードする
|
53
|
-
cmd = sprintf( "curl -o %s %s",
|
54
|
+
cmd = sprintf( "curl -o %s %s", TSVFILE, TSVURL )
|
54
55
|
STDERR.printf( "Command : %s\n", cmd )
|
55
56
|
system( cmd )
|
56
57
|
cmd = sprintf( "curl -o %s %s", SUMFILE, SUMURL )
|
@@ -59,7 +60,7 @@ def main
|
|
59
60
|
|
60
61
|
# チェックサムを確認する
|
61
62
|
downloadSum = ""
|
62
|
-
open(
|
63
|
+
open( TSVFILE ) { |f|
|
63
64
|
dataBody = f.read
|
64
65
|
downloadSum = Digest::MD5.hexdigest( dataBody )
|
65
66
|
}
|
@@ -68,13 +69,26 @@ def main
|
|
68
69
|
STDERR.printf( " downloaded file's MD5 : %s\n", downloadSum )
|
69
70
|
STDERR.printf( " correct MD5 : %s\n", correctSum )
|
70
71
|
if downloadSum == correctSum
|
71
|
-
STDERR.printf( "Info: downloaded file [%s] verify OK.\n",
|
72
|
+
STDERR.printf( "Info: downloaded file [%s] verify OK.\n", TSVFILE )
|
72
73
|
else
|
73
|
-
STDERR.printf( "Error: downloaded file [%s] verify NG.\n",
|
74
|
-
File.unlink(
|
74
|
+
STDERR.printf( "Error: downloaded file [%s] verify NG.\n", TSVFILE )
|
75
|
+
File.unlink( TSVFILE )
|
75
76
|
exit( 1 )
|
76
77
|
end
|
77
78
|
}
|
79
|
+
|
80
|
+
# tsvファイルをTokyo CabinetのHashDB化する
|
81
|
+
STDERR.printf( "Info: Converting TSV file to Tokyo Cabinet *.tch\n" )
|
82
|
+
cmd = sprintf( "tchmgr importtsv %s %s", TC_FILE, TSVFILE )
|
83
|
+
STDERR.printf( "Command : %s\n", cmd )
|
84
|
+
system( cmd )
|
85
|
+
|
86
|
+
# 中身を確認する(tchmgrで読めるものができている)
|
87
|
+
STDERR.printf( "Info: inform *.tch\n" )
|
88
|
+
cmd = sprintf( "tchmgr inform %s", TC_FILE )
|
89
|
+
STDERR.printf( "Command : %s\n", cmd )
|
90
|
+
system( cmd )
|
91
|
+
|
78
92
|
end
|
79
93
|
|
80
94
|
# 辞書ディレクトリに存在している辞書ファイルリストを作る
|
data/emacs/sekka.el
CHANGED
@@ -730,8 +730,10 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
730
730
|
|
731
731
|
(define-key map "\C-s" 'popup-isearch)
|
732
732
|
(define-key map "\C-g" 'popup-close)
|
733
|
+
(define-key map "\C-r" 'popup-select)
|
733
734
|
map))
|
734
735
|
|
736
|
+
|
735
737
|
;; 選択操作回数のインクリメント
|
736
738
|
(defun sekka-select-operation-inc ()
|
737
739
|
(incf sekka-select-operation-times)
|
@@ -856,7 +858,8 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
856
858
|
(sekka-debug-print (format "filtered-lst = %S\n" (reverse lst)))
|
857
859
|
(if (null lst)
|
858
860
|
nil
|
859
|
-
(
|
861
|
+
(reverse lst))))
|
862
|
+
|
860
863
|
|
861
864
|
;; 指定された type の候補が存在するか調べる
|
862
865
|
(defun sekka-include-typep ( _type )
|
@@ -865,7 +868,7 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
865
868
|
;; 指定された type の候補に強制的に切りかえる
|
866
869
|
;; 切りかえが成功したかどうかを t or nil で返す。
|
867
870
|
(defun sekka-select-by-type ( _type )
|
868
|
-
(let ((kouho (sekka-select-by-type-filter _type)))
|
871
|
+
(let ((kouho (car (sekka-select-by-type-filter _type))))
|
869
872
|
(if (not kouho)
|
870
873
|
(progn
|
871
874
|
(cond
|
@@ -926,7 +929,7 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
926
929
|
|
927
930
|
|
928
931
|
;; 登録語リストからユーザーに該当単語を選択してもらう
|
929
|
-
(defun sekka-add-new-word-sub (yomi lst)
|
932
|
+
(defun sekka-add-new-word-sub (yomi lst hiragana-lst)
|
930
933
|
(let* ((etc "(自分で入力する)")
|
931
934
|
(lst (if (stringp lst)
|
932
935
|
(progn
|
@@ -934,7 +937,8 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
934
937
|
'())
|
935
938
|
lst))
|
936
939
|
(result (popup-menu*
|
937
|
-
(append lst
|
940
|
+
(append hiragana-lst
|
941
|
+
(append lst `(,etc)))
|
938
942
|
:margin t
|
939
943
|
:keymap sekka-popup-menu-keymap))
|
940
944
|
(b (copy-marker sekka-fence-start))
|
@@ -948,6 +952,11 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
948
952
|
(sekka-replace-kakutei-word (marker-position b)
|
949
953
|
(marker-position e)
|
950
954
|
tango)
|
955
|
+
|
956
|
+
(when (member result hiragana-lst) ;; 平仮名フレーズの場合
|
957
|
+
(setq yomi result)
|
958
|
+
(setq tango ""))
|
959
|
+
|
951
960
|
;; .sekka-jisyoとサーバーの両方に新しい単語を登録する
|
952
961
|
(let ((added (sekka-add-new-word-to-jisyo sekka-jisyo-filename yomi tango)))
|
953
962
|
(if added
|
@@ -961,15 +970,40 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
961
970
|
"変換候補のよみ(平仮名)に対応する新しい単語を追加する"
|
962
971
|
(interactive)
|
963
972
|
(setq case-fold-search nil)
|
964
|
-
(
|
973
|
+
(let ((type
|
974
|
+
(cond
|
975
|
+
((string-match-p "^[A-Z][^A-Z]+$" sekka-last-roman)
|
976
|
+
(if (sekka-select-by-type 'h) ;; 平仮名候補に自動切り替え
|
977
|
+
'H
|
978
|
+
nil))
|
979
|
+
((string-match-p "^[a-z][^A-Z]+$" sekka-last-roman)
|
980
|
+
'h)
|
981
|
+
(t
|
982
|
+
nil))))
|
965
983
|
(let* ((kouho (nth sekka-cand-cur sekka-henkan-kouho-list))
|
966
984
|
(hiragana (car kouho)))
|
967
985
|
(sekka-debug-print (format "sekka-register-new-word: sekka-last-roman=[%s] hiragana=%s result=%S\n" sekka-last-roman hiragana (string-match-p "^[A-Z][^A-Z]+$" sekka-last-roman)))
|
968
|
-
(
|
986
|
+
(cond
|
987
|
+
;; 漢字語彙をgoogleimeで取得
|
988
|
+
((eq 'H type)
|
969
989
|
(sekka-select-kakutei)
|
970
990
|
(sekka-add-new-word-sub
|
971
991
|
hiragana
|
972
|
-
(sekka-googleime-request hiragana)
|
992
|
+
(sekka-googleime-request hiragana)
|
993
|
+
'()))
|
994
|
+
;; 平仮名フレーズから選択
|
995
|
+
((eq 'h type)
|
996
|
+
(sekka-select-kakutei)
|
997
|
+
(let ((kouho (sekka-select-by-type-filter 'h)))
|
998
|
+
(sekka-debug-print (format "sekka-register-new-word: kouho=%S\n" kouho))
|
999
|
+
(sekka-add-new-word-sub
|
1000
|
+
hiragana
|
1001
|
+
'()
|
1002
|
+
(cons
|
1003
|
+
hiragana ;; 確定値の平仮名文言を先頭に追加。
|
1004
|
+
(mapcar
|
1005
|
+
(lambda (x) (car x)) kouho))))))
|
1006
|
+
)))
|
973
1007
|
|
974
1008
|
|
975
1009
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@@ -1145,11 +1179,16 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
1145
1179
|
(setq e (point))
|
1146
1180
|
(sekka-display-function b e nil)
|
1147
1181
|
(sekka-select-kakutei)
|
1148
|
-
(
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1182
|
+
(cond
|
1183
|
+
((string-match-p "^[A-Z][^A-Z]+$" sekka-last-roman)
|
1184
|
+
;; 漢字語彙
|
1185
|
+
(when sekka-use-googleime
|
1186
|
+
(if (not (sekka-include-typep 'j))
|
1187
|
+
(sekka-add-new-word))))
|
1188
|
+
(t
|
1189
|
+
;; 平仮名フレーズはGoogleIMEの問い合わせの自動起動はしない
|
1190
|
+
)))))))
|
1191
|
+
|
1153
1192
|
((sekka-kanji (preceding-char))
|
1154
1193
|
(sekka-debug-print (format "sekka-kanji(%s) => t\n" (preceding-char)))
|
1155
1194
|
|
@@ -1295,6 +1334,12 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
1295
1334
|
(define-key sticky-map sticky-key '(lambda ()(interactive)(insert sticky-key))))
|
1296
1335
|
|
1297
1336
|
|
1337
|
+
(defun sekka-insert-space (times)
|
1338
|
+
(if (null times)
|
1339
|
+
(insert " ")
|
1340
|
+
(dotimes(i times)
|
1341
|
+
(insert " "))))
|
1342
|
+
|
1298
1343
|
(defun sekka-spacekey-init-function ()
|
1299
1344
|
(define-key global-map (kbd "SPC")
|
1300
1345
|
'(lambda (&optional arg)(interactive "P")
|
@@ -1302,21 +1347,16 @@ non-nil で明示的に呼びだすまでGoogleIMEは起動しない。"
|
|
1302
1347
|
sekka-kakutei-with-spacekey)
|
1303
1348
|
(cond
|
1304
1349
|
((string= " " (char-to-string (preceding-char)))
|
1305
|
-
(insert
|
1350
|
+
(sekka-insert-space arg))
|
1306
1351
|
((eq 10 (preceding-char)) ;; 直前に改行があった
|
1307
|
-
(insert
|
1352
|
+
(sekka-insert-space arg))
|
1308
1353
|
((string= "/" (char-to-string (preceding-char)))
|
1309
1354
|
(delete-region (- (point) 1) (point))
|
1310
|
-
(insert
|
1355
|
+
(sekka-insert-space arg))
|
1311
1356
|
(t
|
1312
1357
|
(sekka-rK-trans))))
|
1313
1358
|
(t
|
1314
|
-
(
|
1315
|
-
((null arg)
|
1316
|
-
(insert " "))
|
1317
|
-
(t
|
1318
|
-
(dotimes(i arg)
|
1319
|
-
(insert " ")))))))))
|
1359
|
+
(sekka-insert-space arg))))))
|
1320
1360
|
|
1321
1361
|
|
1322
1362
|
(defun sekka-realtime-guide ()
|
@@ -1490,7 +1530,7 @@ point から行頭方向に同種の文字列が続く間を漢字変換しま
|
|
1490
1530
|
(setq default-input-method "japanese-sekka")
|
1491
1531
|
|
1492
1532
|
(defconst sekka-version
|
1493
|
-
"0.9.
|
1533
|
+
"0.9.1" ;;SEKKA-VERSION
|
1494
1534
|
)
|
1495
1535
|
(defun sekka-version (&optional arg)
|
1496
1536
|
"入力モード変更"
|
data/lib/sekka/henkan.nnd
CHANGED
@@ -171,24 +171,32 @@
|
|
171
171
|
(let ([num-list (to-list (keyword.scan #/[0-9]+/))]
|
172
172
|
[replaced (keyword.gsub #/[0-9]+/ "#")])
|
173
173
|
;; 辞書引きした結果の # 部分を 再度数値に戻す。
|
174
|
-
(
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
174
|
+
(let* ([result1 (henkan-okuri-nashi userid kvs replaced limit)]
|
175
|
+
[result2 (map
|
176
|
+
(lambda (entry)
|
177
|
+
(let* ([type-list (to-list (. (car entry) scan #/[#][0-9]/))]
|
178
|
+
[converted-list
|
179
|
+
(map
|
180
|
+
(lambda (_type _num)
|
181
|
+
(sekka-henkan-sharp-number _type _num))
|
182
|
+
type-list
|
183
|
+
num-list)]
|
184
|
+
[format-str (. (car entry) gsub #/[#][0-9]/ "%s")])
|
185
|
+
;; ユーザ入力クエリ中の数字のリストと辞書の中の # の個数がマッチしないといけない
|
186
|
+
(if (= (length num-list)
|
187
|
+
(length type-list))
|
188
|
+
(cons
|
189
|
+
(apply sprintf
|
190
|
+
(cons format-str
|
191
|
+
converted-list))
|
192
|
+
(append (drop-right (cdr entry) 1)
|
193
|
+
(list 'n)))
|
194
|
+
#f)))
|
195
|
+
result1)])
|
196
|
+
(filter
|
197
|
+
(lambda (x) x)
|
198
|
+
result2))))
|
199
|
+
|
192
200
|
|
193
201
|
|
194
202
|
;; 送り仮名ありの変換
|
data/lib/sekka/jisyo-db.nnd
CHANGED
data/lib/sekka/path.rb
ADDED
data/lib/sekka/sekkaversion.rb
CHANGED
data/test/henkan-main.nnd
CHANGED
@@ -566,6 +566,36 @@
|
|
566
566
|
'(("1000〜2000" #f "#から#" n))
|
567
567
|
(henkan-okuri-nashi-and-number userid kvs "1000kara2000" 0))
|
568
568
|
|
569
|
+
(test* "okuri nashi and number 8"
|
570
|
+
'(("2011年" #f "#ねん" n) ("2011年" #f "#ねん" n) ("二千十一年" #f "#ねん" n) ("二〇一一年" #f "#ねん" n))
|
571
|
+
(henkan-okuri-nashi-and-number userid kvs "2011nen" 0))
|
572
|
+
|
573
|
+
(test* "okuri nashi and number 9"
|
574
|
+
'(("10000年" #f "#ねん" n) ("10000年" #f "#ねん" n) ("一万年" #f "#ねん" n) ("一〇〇〇〇年" #f "#ねん" n))
|
575
|
+
(henkan-okuri-nashi-and-number userid kvs "10000nen" 0))
|
576
|
+
|
577
|
+
(test* "okuri nashi and number 10"
|
578
|
+
'(("2011年10月10日" #f "#ねん#がつ#にち" n) ("2011年10月10日" #f "#ねん#がつ#にち" n))
|
579
|
+
(henkan-okuri-nashi-and-number userid kvs "2011nen10gatu10ka" 0))
|
580
|
+
|
581
|
+
(test* "okuri nashi and number 11"
|
582
|
+
'()
|
583
|
+
(henkan-okuri-nashi-and-number userid kvs "2011nen10gatu" 0))
|
584
|
+
|
585
|
+
(test* "okuri nashi and number 12"
|
586
|
+
'(("10月10日" #f "#がつ#か" n) ("10月10日" #f "#がつ#か" n) ("一〇月一〇日" #f "#がつ#か" n) ("一〇月10日" #f "#がつ#か" n))
|
587
|
+
(henkan-okuri-nashi-and-number userid kvs "10gatu10ka" 0))
|
588
|
+
|
589
|
+
(test* "okuri nashi and number 13"
|
590
|
+
'()
|
591
|
+
(henkan-okuri-nashi-and-number userid kvs "10ka" 0))
|
592
|
+
|
593
|
+
(test* "okuri nashi and number 14"
|
594
|
+
'()
|
595
|
+
(henkan-okuri-nashi-and-number userid kvs "2011nen10ka" 0))
|
596
|
+
|
597
|
+
|
598
|
+
|
569
599
|
|
570
600
|
;;-------------------------------------------------------------------
|
571
601
|
(test-section "henkan (number)")
|
@@ -1091,6 +1121,7 @@
|
|
1091
1121
|
(sekkaHenkan userid kvs #f "3chi-mu" 0 "normal"))
|
1092
1122
|
|
1093
1123
|
|
1124
|
+
|
1094
1125
|
;;-------------------------------------------------------------------
|
1095
1126
|
(test-section "henkan kakutei")
|
1096
1127
|
(test* "henkan kakutei(for Elisp) 1"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sekka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kiyoka Nishiyama
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -259,6 +259,7 @@ files:
|
|
259
259
|
- lib/sekka/henkan.nnd
|
260
260
|
- lib/sekka/jisyo-db.nnd
|
261
261
|
- lib/sekka/kvs.rb
|
262
|
+
- lib/sekka/path.rb
|
262
263
|
- lib/sekka/roman-lib.nnd
|
263
264
|
- lib/sekka/sekkaversion.rb
|
264
265
|
- lib/sekka/sharp-number.nnd
|