Skip to content

Commit

Permalink
fix(rule): Accept non-independent(非自立) verb that is previous of "たり" (#2
Browse files Browse the repository at this point in the history
)

Problem
--

Valid sentence is treated as invalid; for example `利用方法を学習したり、実際に試してみたりすることができる環境です`.

This example is analyzed as following;

```
[ { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 894860,
       word_type: 'KNOWN',
       surface_form: '利用',
       pos: '名詞',
       pos_detail_1: 'サ変接続',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '利用',
       reading: 'リヨウ',
       pronunciation: 'リヨー' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 1488950,
       word_type: 'KNOWN',
       surface_form: '方法',
       pos: '名詞',
       pos_detail_1: '一般',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '方法',
       reading: 'ホウホウ',
       pronunciation: 'ホーホー' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92880,
       word_type: 'KNOWN',
       surface_form: 'を',
       pos: '助詞',
       pos_detail_1: '格助詞',
       pos_detail_2: '一般',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'を',
       reading: 'ヲ',
       pronunciation: 'ヲ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 496210,
       word_type: 'KNOWN',
       surface_form: '学習',
       pos: '名詞',
       pos_detail_1: 'サ変接続',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '学習',
       reading: 'ガクシュウ',
       pronunciation: 'ガクシュー' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 3011810,
       word_type: 'KNOWN',
       surface_form: 'し',
       pos: '動詞',
       pos_detail_1: '自立',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: 'サ変・スル',
       conjugated_form: '連用形',
       basic_form: 'する',
       reading: 'シ',
       pronunciation: 'シ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92960,
       word_type: 'KNOWN',
       surface_form: 'たり',
       pos: '助詞',
       pos_detail_1: '並立助詞',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'たり',
       reading: 'タリ',
       pronunciation: 'タリ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 51340,
       word_type: 'KNOWN',
       surface_form: '、',
       pos: '名詞',
       pos_detail_1: '数',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '、',
       reading: '、',
       pronunciation: '、' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 2198950,
       word_type: 'KNOWN',
       surface_form: '実際',
       pos: '名詞',
       pos_detail_1: '一般',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '実際',
       reading: 'ジッサイ',
       pronunciation: 'ジッサイ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92030,
       word_type: 'KNOWN',
       surface_form: 'に',
       pos: '助詞',
       pos_detail_1: '格助詞',
       pos_detail_2: '一般',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'に',
       reading: 'ニ',
       pronunciation: 'ニ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 550320,
       word_type: 'KNOWN',
       surface_form: '試し',
       pos: '動詞',
       pos_detail_1: '自立',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '五段・サ行',
       conjugated_form: '連用形',
       basic_form: '試す',
       reading: 'タメシ',
       pronunciation: 'タメシ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92780,
       word_type: 'KNOWN',
       surface_form: 'て',
       pos: '助詞',
       pos_detail_1: '接続助詞',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'て',
       reading: 'テ',
       pronunciation: 'テ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 2943410,
       word_type: 'KNOWN',
       surface_form: 'み',
       pos: '動詞',
       pos_detail_1: '非自立',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '一段',
       conjugated_form: '連用形',
       basic_form: 'みる',
       reading: 'ミ',
       pronunciation: 'ミ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92960,
       word_type: 'KNOWN',
       surface_form: 'たり',
       pos: '助詞',
       pos_detail_1: '並立助詞',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'たり',
       reading: 'タリ',
       pronunciation: 'タリ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 3011740,
       word_type: 'KNOWN',
       surface_form: 'する',
       pos: '動詞',
       pos_detail_1: '自立',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: 'サ変・スル',
       conjugated_form: '基本形',
       basic_form: 'する',
       reading: 'スル',
       pronunciation: 'スル' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 63910,
       word_type: 'KNOWN',
       surface_form: 'こと',
       pos: '名詞',
       pos_detail_1: '非自立',
       pos_detail_2: '一般',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'こと',
       reading: 'コト',
       pronunciation: 'コト' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 92920,
       word_type: 'KNOWN',
       surface_form: 'が',
       pos: '助詞',
       pos_detail_1: '格助詞',
       pos_detail_2: '一般',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: 'が',
       reading: 'ガ',
       pronunciation: 'ガ' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 3370300,
       word_type: 'KNOWN',
       surface_form: 'できる',
       pos: '動詞',
       pos_detail_1: '自立',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '一段',
       conjugated_form: '基本形',
       basic_form: 'できる',
       reading: 'デキル',
       pronunciation: 'デキル' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 361770,
       word_type: 'KNOWN',
       surface_form: '環境',
       pos: '名詞',
       pos_detail_1: '一般',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '*',
       conjugated_form: '*',
       basic_form: '環境',
       reading: 'カンキョウ',
       pronunciation: 'カンキョー' } },
  { type: 'WordNode',
    children: [ [Object] ],
    position: { start: [Object], end: [Object] },
    data:
     { word_id: 23760,
       word_type: 'KNOWN',
       surface_form: 'です',
       pos: '助動詞',
       pos_detail_1: '*',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '特殊・デス',
       conjugated_form: '基本形',
       basic_form: 'です',
       reading: 'デス',
       pronunciation: 'デス' } } ]
```

The verb that is previous of "たり", that is only allowed independent (自立) verb.

Solution
--

Allow non-independent (非自立) verb.
  • Loading branch information
moznion authored and azu committed Jan 16, 2018
1 parent 87a9ce8 commit 6b32967
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/textlint-rule-prefer-tari-tari.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const 動詞 = {
type: "WordNode",
data: {
pos: "動詞",
pos_detail_1: "自立"
pos_detail_1: ["自立", "非自立"]
}
};
const たり = {
Expand Down Expand Up @@ -83,9 +83,12 @@ const report = context => {
// console.log(afterSuru.nodeList);
report(
node,
new RuleError(`例示・並列・対表現において、片方の動詞が「〜たり」表現な場合は、もう片方の動詞も「〜たり」とします。`, {
index: source.originalIndexFromIndex(afterSuru.position.index)
})
new RuleError(
`例示・並列・対表現において、片方の動詞が「〜たり」表現な場合は、もう片方の動詞も「〜たり」とします。`,
{
index: source.originalIndexFromIndex(afterSuru.position.index)
}
)
);
}
});
Expand Down
1 change: 1 addition & 0 deletions test/textlint-rule-prefer-tari-tari-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tester.run("textlint-rule-prefer-tari-tari", rule, {
"白一色になった畠の中に散在する農家はプレハブ住宅であったり茅葺きであったりした",
"薄暗い階段や廊下では観客が食べたり呑んだりしている",
"高かったりまずかったりする",
"利用方法を学習したり、実際に試してみたりすることができる環境です",
// "たり" があるが続ける必要がないパターン
"お前あんまり変なことに関わり合ったりしない方がいいよ",
"ジョークが言えなくても、せめて怒ったりするな。理屈っぽいこと言うな。",
Expand Down

0 comments on commit 6b32967

Please sign in to comment.