Skip to content

Commit

Permalink
✨こそあど言葉に対応いたしましたわ #10 (#22)
Browse files Browse the repository at this point in the history
* こそあどことばの「こ」

* こそあどことばの「そ」

* こそあどことばの「あ」

* こそあどことばの「ど」
  • Loading branch information
jiro4989 authored Jun 20, 2022
1 parent 36afbf0 commit 4c969f6
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 3 deletions.
34 changes: 31 additions & 3 deletions ojosama_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestConvert(t *testing.T) {
{
desc: "正常系: 名詞の手前には「お」をお付けいたしますわ",
src: "これはハーブです",
want: "これはおハーブですわ",
want: "こちらはおハーブですわ",
opt: nil,
wantErr: false,
},
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestConvert(t *testing.T) {
{
desc: "正常系: アルファベット単語の場合は「お」をつけませんの",
src: "これはgrassです。あれはabcdefg12345です",
want: "これはgrassですわ。あれはabcdefg12345ですわ",
want: "こちらはgrassですわ。あちらはabcdefg12345ですわ",
opt: nil,
wantErr: false,
},
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestConvert(t *testing.T) {
{
desc: "正常系: 波線のばしを付与する場合がありますわ",
src: "これはハーブです!",
want: "これはおハーブですわ~~!!!",
want: "こちらはおハーブですわ~~!!!",
opt: &ConvertOption{
forceAppendLongNote: forceAppendLongNote{
enable: true,
Expand Down Expand Up @@ -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 {
Expand Down
204 changes: 204 additions & 0 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ var (
}

convertRules = []convertRule{
// 名詞、代名詞、一般
// 三人称
{
Conditions: []convertCondition{
{
Expand All @@ -285,6 +287,7 @@ var (
},
Value: "貴方",
},
// 一人称
{
Conditions: []convertCondition{
{
Expand Down Expand Up @@ -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{
{
Expand All @@ -440,6 +630,20 @@ var (
},
Value: "どちら",
},
{
Conditions: []convertCondition{
{
Type: convertTypeFeatures,
Value: []string{"連体詞"},
},
{
Type: convertTypeSurface,
Value: []string{"どんな"},
},
},
Value: "どのような",
},

{
Conditions: []convertCondition{
{
Expand Down

0 comments on commit 4c969f6

Please sign in to comment.