diff --git a/ojosama_test.go b/ojosama_test.go index e26b5a8..f7b5af2 100644 --- a/ojosama_test.go +++ b/ojosama_test.go @@ -17,7 +17,7 @@ func TestConvert(t *testing.T) { { desc: "正常系: 名詞の手前には「お」をお付けいたしますわ", src: "これはハーブです", - want: "これはおハーブですわ", + want: "こちらはおハーブですわ", opt: nil, wantErr: false, }, @@ -101,7 +101,7 @@ func TestConvert(t *testing.T) { { desc: "正常系: アルファベット単語の場合は「お」をつけませんの", src: "これはgrassです。あれはabcdefg12345です", - want: "これはgrassですわ。あれはabcdefg12345ですわ", + want: "こちらはgrassですわ。あちらはabcdefg12345ですわ", opt: nil, wantErr: false, }, @@ -171,7 +171,7 @@ func TestConvert(t *testing.T) { { desc: "正常系: 波線のばしを付与する場合がありますわ", src: "これはハーブです!", - want: "これはおハーブですわ~~!!!", + want: "こちらはおハーブですわ~~!!!", opt: &ConvertOption{ forceAppendLongNote: forceAppendLongNote{ enable: true, @@ -348,6 +348,34 @@ func TestConvert(t *testing.T) { opt: nil, wantErr: false, }, + { + desc: "正常系: こそあど言葉(こ)にも対応しておりましてよ", + src: "これ、この、ここ、こちら、こう、こんな。", + want: "こちら、こちらの、こちら、こちら、こう、このような。", + opt: nil, + wantErr: false, + }, + { + desc: "正常系: こそあど言葉(そ)にも対応しておりましてよ", + src: "それ、その、そこ、そちら、そう、そんな。", + want: "そちら、そちらの、そちら、そちら、そう、そのような。", + opt: nil, + wantErr: false, + }, + { + desc: "正常系: こそあど言葉(あ)にも対応しておりましてよ", + src: "あれは、あの、あそこ、あちら、ああ、あんな。", + want: "あちらは、あちらの、あちら、あちら、ああ、あのような。", + opt: nil, + wantErr: false, + }, + { + desc: "正常系: こそあど言葉(ど)にも対応しておりましてよ", + src: "どれ、どの、どこ、どちら、どう、どんな。", + want: "どちら、どちらの、どちら、どちら、どう、どのような。", + opt: nil, + wantErr: false, + }, } for _, tt := range tests { diff --git a/rule.go b/rule.go index 8c8c251..230be1f 100644 --- a/rule.go +++ b/rule.go @@ -272,6 +272,8 @@ var ( } convertRules = []convertRule{ + // 名詞、代名詞、一般 + // 三人称 { Conditions: []convertCondition{ { @@ -285,6 +287,7 @@ var ( }, Value: "貴方", }, + // 一人称 { Conditions: []convertCondition{ { @@ -427,6 +430,193 @@ var ( }, Value: "ママ上", }, + + // こそあど言葉 + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"これ"}, + }, + }, + Value: "こちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"この"}, + }, + }, + Value: "こちらの", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"ここ"}, + }, + }, + Value: "こちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"こんな"}, + }, + }, + Value: "このような", + }, + + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"それ"}, + }, + }, + Value: "そちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"その"}, + }, + }, + Value: "そちらの", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"そこ"}, + }, + }, + Value: "そちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"そんな"}, + }, + }, + Value: "そのような", + }, + + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"あれ"}, + }, + }, + Value: "あちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"あの"}, + }, + }, + Value: "あちらの", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"あそこ"}, + }, + }, + Value: "あちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"あんな"}, + }, + }, + Value: "あのような", + }, + + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"名詞", "代名詞", "一般"}, + }, + { + Type: convertTypeSurface, + Value: []string{"どれ"}, + }, + }, + Value: "どちら", + }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"どの"}, + }, + }, + Value: "どちらの", + }, { Conditions: []convertCondition{ { @@ -440,6 +630,20 @@ var ( }, Value: "どちら", }, + { + Conditions: []convertCondition{ + { + Type: convertTypeFeatures, + Value: []string{"連体詞"}, + }, + { + Type: convertTypeSurface, + Value: []string{"どんな"}, + }, + }, + Value: "どのような", + }, + { Conditions: []convertCondition{ {