From 4c969f6732bcf1b2602ca61b38a054c46507d2c7 Mon Sep 17 00:00:00 2001 From: jiro Date: Mon, 20 Jun 2022 23:03:04 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=E3=81=93=E3=81=9D=E3=81=82=E3=81=A9?= =?UTF-8?q?=E8=A8=80=E8=91=89=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=82=8F=20#10=20(#22)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * こそあどことばの「こ」 * こそあどことばの「そ」 * こそあどことばの「あ」 * こそあどことばの「ど」 --- ojosama_test.go | 34 +++++++- rule.go | 204 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+), 3 deletions(-) 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{ {