@@ -9,7 +9,7 @@ const DefaultOptions = {
99 // 例) カクカク、ドキドキ、ビリビリ
1010 // https://ja.wikipedia.org/wiki/%E6%93%AC%E5%A3%B0%E8%AA%9E
1111 allowOnomatopee : true ,
12-
12+
1313 // 許可する単語
1414 // RegExp-like Stringを使用可能
1515 allow : [ ]
@@ -19,9 +19,19 @@ function isOnomatopee(str) {
1919 return / ^ [ ァ - ロ ワ ヲ ン ー ] * $ / . test ( str ) ;
2020}
2121
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 = { } ) {
2333 const allowOnomatopee = options . allowOnomatopee !== undefined ? options . allowOnomatopee
24- : DefaultOptions . allowOnomatopee ;
34+ : DefaultOptions . allowOnomatopee ;
2535 const allow = options . allow || DefaultOptions . allow ;
2636 const { Syntax, RuleError, report, getSource } = context ;
2737 return {
@@ -38,6 +48,12 @@ export default function(context, options = {}) {
3848 if ( prevWord !== currentWord ) {
3949 return ;
4050 }
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+ }
4157 if ( allowOnomatopee && isOnomatopee ( prevWord ) && isOnomatopee ( currentWord ) ) {
4258 return ;
4359 }
0 commit comments