@@ -9,7 +9,7 @@ const DefaultOptions = {
9
9
// 例) カクカク、ドキドキ、ビリビリ
10
10
// https://ja.wikipedia.org/wiki/%E6%93%AC%E5%A3%B0%E8%AA%9E
11
11
allowOnomatopee : true ,
12
-
12
+
13
13
// 許可する単語
14
14
// RegExp-like Stringを使用可能
15
15
allow : [ ]
@@ -19,9 +19,19 @@ function isOnomatopee(str) {
19
19
return / ^ [ ァ - ロ ワ ヲ ン ー ] * $ / . test ( str ) ;
20
20
}
21
21
22
- export default function ( context , options = { } ) {
22
+ /**
23
+ * 漢数字かどうかを判定する
24
+ * https://azu.github.io/morpheme-match/?text=%E5%80%A4%E3%81%AF%E4%B9%9D%E4%B9%9D%E3%81%A7%E3%81%99%E3%80%82
25
+ * @param {import("kuromojin").KuromojiToken } token
26
+ * @returns {boolean }
27
+ */
28
+ function isNumberToken ( token ) {
29
+ return token . pos === "名詞" && token . pos_detail_1 === "数" ;
30
+ }
31
+
32
+ export default function ( context , options = { } ) {
23
33
const allowOnomatopee = options . allowOnomatopee !== undefined ? options . allowOnomatopee
24
- : DefaultOptions . allowOnomatopee ;
34
+ : DefaultOptions . allowOnomatopee ;
25
35
const allow = options . allow || DefaultOptions . allow ;
26
36
const { Syntax, RuleError, report, getSource } = context ;
27
37
return {
@@ -38,6 +48,12 @@ export default function(context, options = {}) {
38
48
if ( prevWord !== currentWord ) {
39
49
return ;
40
50
}
51
+ // 漢数字は例外とする
52
+ // 例) 値は"九九"です。
53
+ // https://azu.github.io/morpheme-match/?text=%E5%80%A4%E3%81%AF%E4%B9%9D%E4%B9%9D%E3%81%A7%E3%81%99%E3%80%82
54
+ if ( isNumberToken ( prevToken ) && isNumberToken ( nextToken ) ) {
55
+ return ;
56
+ }
41
57
if ( allowOnomatopee && isOnomatopee ( prevWord ) && isOnomatopee ( currentWord ) ) {
42
58
return ;
43
59
}
0 commit comments