diff --git a/text/corpus/rules-measure.json b/text/corpus/rules-measure.json index 2ea9202c3..047a603c5 100644 --- a/text/corpus/rules-measure.json +++ b/text/corpus/rules-measure.json @@ -5033,6 +5033,42 @@ "falseAlarms": 0 } }, + "inline-triad": { + "groups": { + "academic": { + "documents": 5, + "fired": 0 + }, + "blog": { + "documents": 9, + "fired": 0 + }, + "business": { + "documents": 41, + "fired": 0 + }, + "docs": { + "documents": 11, + "fired": 0 + }, + "legal": { + "documents": 14, + "fired": 0 + }, + "literature": { + "documents": 9, + "fired": 0 + }, + "speech": { + "documents": 3, + "fired": 0 + }, + "technical": { + "documents": 27, + "fired": 0 + } + } + }, "installment-total-mismatch": { "groups": { "academic": { @@ -9039,6 +9075,42 @@ "cleanSamples": 12 } }, + "section-reflection-ending": { + "groups": { + "academic": { + "documents": 10, + "fired": 0 + }, + "blog": { + "documents": 23, + "fired": 0 + }, + "business": { + "documents": 80, + "fired": 0 + }, + "docs": { + "documents": 21, + "fired": 0 + }, + "legal": { + "documents": 35, + "fired": 0 + }, + "literature": { + "documents": 13, + "fired": 0 + }, + "speech": { + "documents": 7, + "fired": 0 + }, + "technical": { + "documents": 26, + "fired": 0 + } + } + }, "sentence-initial-conjunction-run": { "groups": { "academic": { diff --git a/text/docs/samples/en/README.md b/text/docs/samples/en/README.md index 7a30ec379..97e3af502 100644 --- a/text/docs/samples/en/README.md +++ b/text/docs/samples/en/README.md @@ -11,7 +11,7 @@ Or paste a draft into the [playground](https://isamu.github.io/lab/en/playground 日本語の見本: [../ja/README.md](../ja/README.md) -Rules with a sample: 268 / 268 +Rules with a sample: 270 / 270 ## Readability @@ -314,12 +314,14 @@ Traits common in generated text. None of them alone says the text was generated; | [Headings decorated with emoji](emoji-heading.md) (`emoji-heading`) | Headings with an emoji in them ("## 🚀 Getting started"), one after another | | [Too many decorative figures](figurative-density.md) (`figurative-density`) | Figures such as "like magic" or "secret sauce" piled up instead of the mechanism | | [An honesty marker](honesty-marker.md) (`honesty-marker`) | A sentence flagged as candid ("honestly", "if I'm being honest") | +| [Threes strung on commas](inline-triad.md) (`inline-triad`) | Three short phrases strung on commas with no "and", again and again | | [Too many dashes](no-em-dash.md) (`no-em-dash`) | Too many dashes, which is also one of the better-known marks of generated text | | [Too many sweeping claims about people](over-general-claim.md) (`over-general-claim`) | Sweeping claims about people ("most people", "nobody") piled up | | [Paragraph lengths are too uniform](paragraph-length-variance.md) (`paragraph-length-variance`) | Paragraphs all of about the same length, as if poured into a mould | | [Questions answered with a fragment](q-fragment-answer.md) (`q-fragment-answer`) | Questions the writer answers at once with a fragment ("Is it perfect? No.") | | [Everything comes in threes](rule-of-three.md) (`rule-of-three`) | Lists that almost all have exactly three items, as if padded or trimmed to fit | | [Section lengths are too uniform](section-length-uniformity.md) (`section-length-uniformity`) | Every section filled to the same size, which is what a template does | +| [Every section closes on a personal reflection](section-reflection-ending.md) (`section-reflection-ending`) | Nearly every section closing on "I think ..." or "I feel ..." | | [Monotonous sentence rhythm](sentence-rhythm.md) (`sentence-rhythm`) | Sentences that are all about the same length, so the text reads as a drone | | [Too many stock transitions](stock-transition.md) (`stock-transition`) | Too many sentences opening with "Moreover" or "Additionally" | | [Too many denials of a premise nobody stated](unprompted-denial.md) (`unprompted-denial`) | Sentences that deny a premise nobody stated ("This isn't about tooling.") | diff --git a/text/docs/samples/en/agreement-slip.md b/text/docs/samples/en/agreement-slip.md index cbf3b750b..755e61a31 100644 --- a/text/docs/samples/en/agreement-slip.md +++ b/text/docs/samples/en/agreement-slip.md @@ -39,9 +39,9 @@ booking-email.md business/email · English genre from --genre ⚠ Words that do not agree "These new version" mixes singular and plural - A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), or two determiners in a row ("the some roads"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. + A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), two determiners in a row ("the some roads"), or a noun where a second verb belongs ("to watch and photography wildlife"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. - → Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). + → Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). For a noun where a verb belongs, write the verb ("photography" becomes "photograph"). Relax this rule: npx chaffjs relax agreement-slip @@ -53,9 +53,9 @@ booking-email.md business/email · English genre from --genre ⚠ Words that do not agree "a significant changes" mixes singular and plural - A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), or two determiners in a row ("the some roads"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. + A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), two determiners in a row ("the some roads"), or a noun where a second verb belongs ("to watch and photography wildlife"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. - → Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). + → Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). For a noun where a verb belongs, write the verb ("photography" becomes "photograph"). Relax this rule: npx chaffjs relax agreement-slip @@ -114,9 +114,9 @@ $ npx chaffjs explain agreement-slip --genre business/email Words that do not agree (agreement-slip) - A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), or two determiners in a row ("the some roads"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. + A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), two determiners in a row ("the some roads"), or a noun where a second verb belongs ("to watch and photography wildlife"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. - How to fix: Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). + How to fix: Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). For a noun where a verb belongs, write the verb ("photography" becomes "photograph"). Levels (there is no limit to count to; a level sets how a finding is marked): strict error diff --git a/text/docs/samples/en/inline-triad.md b/text/docs/samples/en/inline-triad.md new file mode 100644 index 000000000..305c03408 --- /dev/null +++ b/text/docs/samples/en/inline-triad.md @@ -0,0 +1,190 @@ + + +# Threes strung on commas (`inline-triad`) + +**Where it helps:** essays, blog posts, newsletters. Any prose drafted with an AI that keeps reaching for three. + +## Original + +```markdown chaff-before +# Learning to cook late + +For years my idea of dinner was pasta with sauce from a jar. +At thirty I decided that had to change, and I bought a pan that was not already scratched. + +I started with simple things: scrambled eggs, roasted vegetables, a basic tomato soup. +I burned the garlic more often than I can count, and the smoke alarm learned my schedule. +Most dishes, I noticed, begin the same way: an onion, some garlic, a little oil. +After a month I stopped reading the recipe line by line and began to taste as I went. + +What changed most was the evening itself. +Instead of scrolling while I waited for a delivery, I was chopping, stirring, paying attention. +I forgot about work. +I thought about whether the onions were ready, and whether the soup needed more salt. + +Later I started asking friends over for dinner, which I had always avoided. +The meals were not perfect. +But people do not really come for the food. +They come for the table, the conversation, the feeling of being cared for. +Cooking gave me a way to offer that, and it still does on most weeknights. + +I am still not a great cook. +The list of failures is much longer, and I keep adding to it every month. +But I no longer feel that cooking is something I missed. +It is something I am learning slowly, one meal at a time, in a small kitchen. +If you think it is too late to learn something new, I would gently suggest that it is not. +Being a beginner as an adult is uncomfortable, but there is a quiet pleasure in it as well. +``` + +## What chaff says + +```text chaff-output +$ npx chaffjs --no-guide --genre blog/essay cooking.md + +cooking.md blog/essay · English genre from --genre + +─── line 6 ─────────────────────────────────────────────────── + + I started with simple things: scrambled eggs, roasted vegetables, a basic tomato soup. + + · Threes strung on commas + + "scrambled eggs, roasted vegetables, a basic tomato soup" and other threes strung on commas: 14 per 1000 words (limit 3) + Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content. + + → Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + + Relax this rule: npx chaffjs relax inline-triad + + +─── line 8 ─────────────────────────────────────────────────── + + Most dishes, I noticed, begin the same way: an onion, some garlic, a little oil. + + · Threes strung on commas + + "an onion, some garlic, a little oil" and other threes strung on commas: 14 per 1000 words (limit 3) + Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content. + + → Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + + Relax this rule: npx chaffjs relax inline-triad + + +─── line 12 ────────────────────────────────────────────────── + + Instead of scrolling while I waited for a delivery, I was chopping, stirring, paying attention. + + · Threes strung on commas + + "I was chopping, stirring, paying attention" and other threes strung on commas: 14 per 1000 words (limit 3) + Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content. + + → Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + + Relax this rule: npx chaffjs relax inline-triad + + +─── line 19 ────────────────────────────────────────────────── + + They come for the table, the conversation, the feeling of being cared for. + + · Threes strung on commas + + "They come for the table, the conversation, the feeling of being cared for" and other threes strung on commas: 14 per 1000 words (limit 3) + Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content. + + → Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + + Relax this rule: npx chaffjs relax inline-triad + + +──────────────────────────────────────────────────────────── + + 4 notes All judged by machine + (the same text gives the same result every time) + + The text was not changed. Fixing it is the writer's job. +``` + +## Corrected + +```markdown chaff-after +# Learning to cook late + +For years my idea of dinner was pasta with sauce from a jar. +At thirty I decided that had to change, and I bought a pan that was not already scratched. + +I started with scrambled eggs and a basic tomato soup. +I burned the garlic more often than I can count, and the smoke alarm learned my schedule. +Most dishes, I noticed, begin the same way, with an onion and a little oil. +After a month I stopped reading the recipe line by line and began to taste as I went. + +What changed most was the evening itself. +Instead of scrolling while I waited for a delivery, I was chopping and paying attention. +I forgot about work. +I thought about whether the onions were ready, and whether the soup needed more salt. + +Later I started asking friends over for dinner, which I had always avoided. +The meals were not perfect. +But people do not really come for the food. +They come for the conversation and the feeling of being cared for. +Cooking gave me a way to offer that, and it still does on most weeknights. + +I am still not a great cook. +The list of failures is much longer, and I keep adding to it every month. +But I no longer feel that cooking is something I missed. +It is something I am learning slowly, one meal at a time, in a small kitchen. +If you think it is too late to learn something new, I would gently suggest that it is not. +Being a beginner as an adult is uncomfortable, but there is a quiet pleasure in it as well. +``` + +## How it was fixed + +The draft lists things in threes again and again, each time with commas and no "and": three first dishes, three things in the pan, three things done at the stove, three reasons friends come over. +One such run is a turn of phrase. Four in a short essay make the pattern louder than what the writer is saying. + +The fix asks of each run whether there really are three things. +Where one item only filled the slot (the roasted vegetables, the garlic beside the onion, the stirring beside the chopping, the table beside the conversation), it goes, and the two that are left are joined with "and". + +## Settings + +The rule counts three short phrases strung on commas with no "and" or "or", per 1000 words. +A list joined with "and" is not counted, since human prose writes those as often. +Runs holding a figure, capitalised names and titles, one word said again (old, old, old), runs inside a list or quotation marks, and runs of four or more are left out. +A document shorter than 200 words, or with fewer than three runs, is not measured. + +```yaml chaff-settings +rules: + inline-triad: relaxed +``` + +The rule runs only on English. + +```text chaff-explain +$ npx chaffjs explain inline-triad --genre blog/essay + + Threes strung on commas (inline-triad) + + Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content. + + How to fix: Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + + Rewrite depth: light (words and sentences; the structure and the voice stay). With a shallower chaff fix-plan --depth, the plan names this rule without fixing it. + + Levels: + strict up to 2 runs of three per 1000 words + → normal up to 3 runs of three per 1000 words + relaxed up to 5 runs of three per 1000 words + off not checked + + Now: normal. + + Change it: npx chaffjs relax inline-triad --why "reason" +``` + +[All samples](README.md) diff --git a/text/docs/samples/en/section-reflection-ending.md b/text/docs/samples/en/section-reflection-ending.md new file mode 100644 index 000000000..baeed0577 --- /dev/null +++ b/text/docs/samples/en/section-reflection-ending.md @@ -0,0 +1,186 @@ + + +# Every section closes on a personal reflection (`section-reflection-ending`) + +**Where it helps:** personal blog posts, trip and event reports, newsletter columns. Especially a draft written to a prompt. + +## Original + +```markdown chaff-before +# Cycling to work + +## Mornings + +The ride to the station takes about ten minutes. I think the fresh air is the best part of the day. + +## Evenings + +The way home has more hills, and my legs ached the first week. I feel it has become good exercise. + +## Rainy days + +On rainy days I take the train. I believe not forcing it is what keeps a habit going. + +## Money + +I save about eighty dollars a month on the train pass. I think small savings add up. +``` + +## What chaff says + +```text chaff-output +$ npx chaffjs --no-guide --genre blog/essay post.md + +post.md blog/essay · English genre from --genre + +─── line 5 ─────────────────────────────────────────────────── + + The ride to the station takes about ten minutes. + + ⚠ Monotonous sentence rhythm + + Sentence length varies by only 24% (want 30%) + When every sentence is the same length, the reader loses the rhythm. It is also a common shape of generated text. + + → Mix in short sentences. Splitting one in two is enough. + + Relax this rule: npx chaffjs relax sentence-rhythm + + +─── line 5 ─────────────────────────────────────────────────── + + I think the fresh air is the best part of the day. + + · Every section closes on a personal reflection + + "I think" and other reflections close 4 of 4 sections (100%, 50% needed) + Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + + → Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + + Relax this rule: npx chaffjs relax section-reflection-ending + + +─── line 9 ─────────────────────────────────────────────────── + + I feel it has become good exercise. + + · Every section closes on a personal reflection + + "I feel" and other reflections close 4 of 4 sections (100%, 50% needed) + Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + + → Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + + Relax this rule: npx chaffjs relax section-reflection-ending + + +─── line 13 ────────────────────────────────────────────────── + + I believe not forcing it is what keeps a habit going. + + · Every section closes on a personal reflection + + "I believe" and other reflections close 4 of 4 sections (100%, 50% needed) + Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + + → Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + + Relax this rule: npx chaffjs relax section-reflection-ending + + +─── line 17 ────────────────────────────────────────────────── + + I think small savings add up. + + · Every section closes on a personal reflection + + "I think" and other reflections close 4 of 4 sections (100%, 50% needed) + Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + + → Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + + Relax this rule: npx chaffjs relax section-reflection-ending + + +──────────────────────────────────────────────────────────── + + 1 warning, 4 notes All judged by machine + (the same text gives the same result every time) + + The text was not changed. Fixing it is the writer's job. +``` + +## Revised + +```markdown chaff-after +# Cycling to work + +## Mornings + +The ride to the station takes about ten minutes. I leave home five minutes later. + +## Evenings + +The way home has more hills, and my legs ached the first week. Not now. + +## Rainy days + +On rainy days I take the train, which last month meant six days out of the twenty I worked. + +## Money + +I save about eighty dollars a month on the train pass. The bike pays for itself in a year and a half. +``` + +## How to fix + +Each of the four sections closes on "I think ...", "I feel ..." or "I believe ...". +Closing one section on a reflection is ordinary; closing every one the same way reads as a template that adds a line of feeling after the content. + +The revision replaces each reflection with what the section found: the time of leaving, when the aching stopped, the number of rainy days, how long the bike takes to pay for itself. +If a reflection matters, keep it in the one section where it matters most. + +## Settings + +It reports once half or more of the sections close on a reflection. + +```yaml chaff-settings +rules: + section-reflection-ending: strict +``` + +`strict` reports from 40%, `relaxed` from 67%. +A document with fewer than 4 sections that hold a paragraph is not measured. + +```text chaff-explain +$ npx chaffjs explain section-reflection-ending --genre blog/essay + + Every section closes on a personal reflection (section-reflection-ending) + + Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + + How to fix: Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + + Levels: + strict reported when 40% or more of the sections close on a reflection + → normal reported when 50% or more of the sections close on a reflection + relaxed reported when 67% or more of the sections close on a reflection + off not checked + + Options (set under options in chaff.yaml): + min_sections: 4 (default) + The fewest sections measured. With few sections, one or two reflective closings make a large share, and a person's writing is reported too + + Set one: write options: { section-reflection-ending: { : } } in chaff.yaml + + Now: normal. + + Change it: npx chaffjs relax section-reflection-ending --why "reason" +``` + +[All samples](README.md) diff --git a/text/docs/samples/ja/README.md b/text/docs/samples/ja/README.md index b2ad77cc3..6518cb8f0 100644 --- a/text/docs/samples/ja/README.md +++ b/text/docs/samples/ja/README.md @@ -11,7 +11,7 @@ chaff が見つけるまちがいを、ルールごとに一つずつ見本に English samples: [../en/README.md](../en/README.md) -見本のあるルール: 282 / 282 +見本のあるルール: 283 / 283 ## 読みやすさ @@ -333,6 +333,7 @@ English samples: [../en/README.md](../en/README.md) | [段落の長さが揃いすぎている](paragraph-length-variance.md)(`paragraph-length-variance`) | どの段落もほぼ同じ長さで、型に流しこんだように見える所 | | [3 項目の箇条書きばかり](rule-of-three.md)(`rule-of-three`) | 箇条書きがどれも三つの項目で、数を合わせて並べたように見える所 | | [節の長さが揃いすぎている](section-length-uniformity.md)(`section-length-uniformity`) | どの節もほぼ同じ長さに埋めてあり、ひな形を埋めたように見える所 | +| [どの節も所感の文で閉じる](section-reflection-ending.md)(`section-reflection-ending`) | 「〜と思います」「〜と感じています」のように、節のほとんどが所感の文で閉じている所 | | [文の長さが単調](sentence-rhythm.md)(`sentence-rhythm`) | どの文もほぼ同じ長さで、読むリズムが単調な所 | | [決まった接ぎで始まる文が多い](stock-transition.md)(`stock-transition`) | 「さらに」「加えて」「このように」で始まる文が多く、何がどう繋がるのかを言わずに並べている所 | | [翻訳調が多い](translationese-density.md)(`translationese-density`) | 「〜を可能にする」「重要な役割を果たす」「あなたは」のような、英語の構文を写した言い回しが多い所 | diff --git a/text/docs/samples/ja/section-reflection-ending.md b/text/docs/samples/ja/section-reflection-ending.md new file mode 100644 index 000000000..ca2557a9b --- /dev/null +++ b/text/docs/samples/ja/section-reflection-ending.md @@ -0,0 +1,186 @@ + + +# どの節も所感の文で閉じる(`section-reflection-ending`) + +**こんな文書に:** ブログの体験記、出張や展示会の報告、社内報のコラム。とくに AI に下書きを頼んだ文章に出やすい型です。 + +## 元の文章 + +```markdown chaff-before +# 自転車通勤を始めて + +## 朝 + +駅まで歩いていた道を、自転車で十分ほど走ります。朝の空気が気持ちよく、続けてよかったと思います。 + +## 帰り + +帰りは坂が多く、最初の週は脚が張りました。いまは慣れて、いい運動になっていると感じています。 + +## 雨の日 + +雨の日は電車にしています。無理をしないことが、長く続けるこつかもしれません。 + +## お金 + +定期代が月に八千円ほど浮きました。小さな額でも、積み重なると大きいと思います。 +``` + +## chaff の指摘 + +```text chaff-output +$ npx chaffjs --no-guide --genre blog/essay post.md + +post.md blog/essay · 日本語 ジャンルは --genre から + +─── 5 行目 ─────────────────────────────────────────────────── + + 駅まで歩いていた道を、自転車で十分ほど走ります。 + + ⚠ 文の長さが単調 + + 文の長さのばらつきが 19%(36% 以上ほしい) + どの文も同じ長さだと、読者は途中で読むリズムを失います。生成された文章によく出る形でもあります。 + + → 短い文をいくつか混ぜてください。1 文を 2 つに割るだけで変わります。 + + このルールをゆるめる: npx chaffjs relax sentence-rhythm + + +─── 5 行目 ─────────────────────────────────────────────────── + + 朝の空気が気持ちよく、続けてよかったと思います。 + + · どの節も所感の文で閉じる + + 「と思います」など、4 節のうち 4 節が所感の文で閉じています(100%、50% から) + 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + + → 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + + このルールをゆるめる: npx chaffjs relax section-reflection-ending + + +─── 9 行目 ─────────────────────────────────────────────────── + + いまは慣れて、いい運動になっていると感じています。 + + · どの節も所感の文で閉じる + + 「と感じています」など、4 節のうち 4 節が所感の文で閉じています(100%、50% から) + 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + + → 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + + このルールをゆるめる: npx chaffjs relax section-reflection-ending + + +─── 13 行目 ────────────────────────────────────────────────── + + 無理をしないことが、長く続けるこつかもしれません。 + + · どの節も所感の文で閉じる + + 「かもしれません」など、4 節のうち 4 節が所感の文で閉じています(100%、50% から) + 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + + → 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + + このルールをゆるめる: npx chaffjs relax section-reflection-ending + + +─── 17 行目 ────────────────────────────────────────────────── + + 小さな額でも、積み重なると大きいと思います。 + + · どの節も所感の文で閉じる + + 「と思います」など、4 節のうち 4 節が所感の文で閉じています(100%、50% から) + 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + + → 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + + このルールをゆるめる: npx chaffjs relax section-reflection-ending + + +──────────────────────────────────────────────────────────── + + 注意 1 件、参考 4 件 すべて機械による判定です + (同じ文章なら何度実行しても同じ結果になります) + + 文章は書き換えていません。直すのは書いた人です。 +``` + +## 直した文章 + +```markdown chaff-after +# 自転車通勤を始めて + +## 朝 + +駅まで歩いていた道を、自転車で十分ほど走ります。家を出るのは五分遅くなりました。 + +## 帰り + +帰りは坂が多く、最初の週は脚が張りました。二週目には治りました。いまは平気です。 + +## 雨の日 + +雨の日は電車です。先月は、雨で自転車に乗れなかった日が月のうち六日ありました。 + +## お金 + +定期代が月に八千円ほど浮きました。自転車の代金は、一年半で元が取れる計算です。 +``` + +## 直し方 + +元の文章は、四つの節がどれも「〜と思います」「〜と感じています」「〜かもしれません」で閉じています。 +一つの節を所感で閉じるのは人もよく書きますが、どの節も同じように閉じると、中身を書いたあとに感想を一文足す型に見えます。 + +直した文章では、所感の文を、その節で分かったこと(家を出る時刻、脚の張りが治った時期、雨の日数、元が取れるまでの期間)に置き換えました。 +感想を残したい節があれば、一番言いたい節だけに残します。 + +## 設定 + +節のうち半分以上が所感の文で閉じると指摘します。 + +```yaml chaff-settings +rules: + section-reflection-ending: strict +``` + +`strict` にすると 40% から、`relaxed` は 67% からです。 +段落のある節が 4 つより少ない文書は測りません。 + +```text chaff-explain +$ npx chaffjs explain section-reflection-ending --genre blog/essay + + どの節も所感の文で閉じる (section-reflection-ending) + + 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + + 直しかた: 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + + 設定できる値: + strict 所感の文で閉じる節が 40% 以上なら指摘 + → normal 所感の文で閉じる節が 50% 以上なら指摘 + relaxed 所感の文で閉じる節が 67% 以上なら指摘 + off 見ない + + オプション(chaff.yaml の options で決めます): + min_sections: 4 (既定) + 測る節の数の下限。節が少ないと、所感で閉じる節が 1 つ 2 つでも割合が大きく出て、人の書いた文書でも当たります + + 決める: chaff.yaml に options: { section-reflection-ending: { <名前>: <値> } } を書く + + いまは normal です。 + + 変える: npx chaffjs relax section-reflection-ending --why "理由" +``` + +[見本の一覧へ](README.md) diff --git a/text/packages/chaff/README.ja.md b/text/packages/chaff/README.ja.md index 344bdda5e..ce06a60df 100644 --- a/text/packages/chaff/README.ja.md +++ b/text/packages/chaff/README.ja.md @@ -256,7 +256,7 @@ npx chaffjs ai-score article.md 低・中・高と、出てい npx chaffjs ai-score article.md --format json 同じものを JSON で ``` -短すぎる文書は測らず、そう言います。目印の一つが `email-stock-courtesy` で、英文のメールに「I hope this email finds you well」「I apologize for any inconvenience」のような決まり文句が 2 つ以上重なった所を言います。`honesty-marker` は、「正直、」「正直に言うと」「if I'm being honest」のように本音だと前置きする言い回しを、ブログと業務文書では 1 つでも言います。もう一つの例が `closing-exhortation` で、「ぜひ〜してみてください」「きっと〜はずです」のように結びで読み手を励ます文が 2 つ以上重なった所を言います。`cold-open` は、状況も例もないまま、短い願い(「〜に任せたい。」)、前の文の語の引き直し(この「だいたい」が)、難所の予告(「それだけのことに見えて」)が書き出しに重なった所を言います。`unprompted-denial` は、「〜の話ではありません」「〜の材料になりません」のように、誰も言っていない前提を打ち消して終わる文が多い所を言います。 +短すぎる文書は測らず、そう言います。目印の一つが `email-stock-courtesy` で、英文のメールに「I hope this email finds you well」「I apologize for any inconvenience」のような決まり文句が 2 つ以上重なった所を言います。`honesty-marker` は、「正直、」「正直に言うと」「if I'm being honest」のように本音だと前置きする言い回しを、ブログと業務文書では 1 つでも言います。`inline-triad` は、「the table, the conversation, the feeling of being cared for」のように、短い句を三つ、and を入れずにカンマだけで並べる形が何度も出る所を言います(英語の文書だけ)。もう一つの例が `closing-exhortation` で、「ぜひ〜してみてください」「きっと〜はずです」のように結びで読み手を励ます文が 2 つ以上重なった所を言います。`cold-open` は、状況も例もないまま、短い願い(「〜に任せたい。」)、前の文の語の引き直し(この「だいたい」が)、難所の予告(「それだけのことに見えて」)が書き出しに重なった所を言います。`section-reflection-ending` は、「〜と思います」「〜と感じています」のように、節のほとんどが所感の文で閉じている所を言います。`unprompted-denial` は、「〜の話ではありません」「〜の材料になりません」のように、誰も言っていない前提を打ち消して終わる文が多い所を言います。 ## AI の評価に使う(chaff grade) @@ -367,8 +367,10 @@ rule the rewrite raised; `npx chaffjs test --checks ai-tells` asks about **AI score.** `chaff ai-score ` — a quick AI-likeness score (low, medium, high): counts the signs of generated text that human documents of the same genre rarely show. It is not a verdict on whether AI wrote it. One sign is `email-stock-courtesy`: two or more stock email courtesies in one English email. `honesty-marker`: a sentence flagged as -candid ("Honestly,", 「正直、」), reported alone in blog posts and business documents. -`closing-exhortation`: a closing that cheers the reader on two or more times. `unprompted-denial`: many sentences that +candid ("Honestly,", 「正直、」), reported alone in blog posts and business documents. `inline-triad`: three short +phrases strung on commas with no "and", again and again (English only). +`closing-exhortation`: a closing that cheers the reader on two or more times. `section-reflection-ending`: nearly every +section closing on a personal reflection ("I think ...", 「〜と思います」). `unprompted-denial`: many sentences that deny a premise nobody stated ("This isn't about tooling."). **AI evals.** `npx chaffjs grade outputs.jsonl --out results.jsonl` grades a JSONL file of a model's outputs (`id` and diff --git a/text/packages/chaff/README.md b/text/packages/chaff/README.md index 51fbd71bc..a2c7eb9e8 100644 --- a/text/packages/chaff/README.md +++ b/text/packages/chaff/README.md @@ -208,9 +208,11 @@ A quick AI-likeness reading: low, medium or high. It counts the signs of generat human documents of the same genre rarely show. It is not a verdict on whether AI wrote it, and it is not meant to be one. Among the signs: `email-stock-courtesy`, two or more stock email courtesies ("I hope this email finds you well", "I apologize for any inconvenience") in one English email; `honesty-marker`, a sentence flagged -as candid ("Honestly,", "if I'm being honest", 「正直、」), reported alone in blog posts and business documents; `closing-exhortation`, a closing that cheers +as candid ("Honestly,", "if I'm being honest", 「正直、」), reported alone in blog posts and business documents; `inline-triad`, three short phrases strung on commas with no "and", +again and again ("the table, the conversation, the feeling of being cared for"; English only); `closing-exhortation`, a closing that cheers the reader on two or more times ("You've got this", 「ぜひ〜してみてください」); `cold-open`, an opening that piles a bare wish, a word of -the previous sentence repeated in quotes, and a teaser ("Sounds simple. It isn't.") before any situation or example; and +the previous sentence repeated in quotes, and a teaser ("Sounds simple. It isn't.") before any situation or example; `section-reflection-ending`, nearly every section closing on a +personal reflection ("I think ...", 「〜と思います」); and `unprompted-denial`, many sentences that deny a premise nobody stated ("This isn't about tooling.", 「〜の話ではありません」). ## Grading a model's output diff --git a/text/packages/chaff/rules/agreement-slip.yaml b/text/packages/chaff/rules/agreement-slip.yaml index 9004b44c3..93a6acc55 100644 --- a/text/packages/chaff/rules/agreement-slip.yaml +++ b/text/packages/chaff/rules/agreement-slip.yaml @@ -15,6 +15,7 @@ extra_word_lists: misnumbered-phrase, determiner-after-article, homophone-slip, + noun-for-verb, ] severity: warning @@ -23,8 +24,8 @@ name: en: Words that do not agree why: - ja: 「a significant changes」「these new version」のように限定詞と名詞の単数・複数が食い違う文や、「Your can check」のように所有の語が主語の位置にある文や、「the some roads」のように冠詞の後ろに限定詞が続く文は、書き換えの途中で片方だけ直した跡です。読み手はつまずき、急いで書いた文書に見えます。解析器の読みが一通りに決まる形だけを数え、単数と複数が同じ綴りの語(series / data)、代名詞にも読める this / these の直後の語、名詞を重ねた語(a sales team)は数えていません。 - en: A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), or two determiners in a row ("the some roads"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. + ja: 「a significant changes」「these new version」のように限定詞と名詞の単数・複数が食い違う文や、「Your can check」のように所有の語が主語の位置にある文や、「the some roads」のように冠詞の後ろに限定詞が続く文、「to watch and photography wildlife」のように動詞を並べる所に名詞がある文は、書き換えの途中で片方だけ直した跡です。読み手はつまずき、急いで書いた文書に見えます。解析器の読みが一通りに決まる形だけを数え、単数と複数が同じ綴りの語(series / data)、代名詞にも読める this / these の直後の語、名詞を重ねた語(a sales team)は数えていません。 + en: A determiner and a noun that differ in number ("a significant changes", "these new version"), a possessive where the subject belongs ("Your can check"), two determiners in a row ("the some roads"), or a noun where a second verb belongs ("to watch and photography wildlife"), is left over from an edit that fixed one word and not the other. The reader stumbles, and the document looks rushed. Only forms with one reading are counted; nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these" (which can stand alone), and nouns that modify another noun ("a sales team") are not. message: ja: 「{word}」で単数と複数が合っていません @@ -40,10 +41,13 @@ messages: determiner: ja: 「{word}」で、限定詞が二つ続いています en: '"{word}" puts two determiners in a row' + conjunct: + ja: 「{word}」で、動詞を並べる所に名詞があります({verb} のつもりかもしれません) + en: '"{word}" puts a noun where a second verb belongs ("{verb}" may be meant)' how_to_fix: - ja: 限定詞か名詞のどちらかに揃えてください(a significant change / significant changes)。所有の語なら、主語の語に直してください(Your can → You can、their will → they will)。限定詞が二つ続いていれば、どちらかを消してください(the some roads → some roads か that some roads)。 - en: Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). + ja: 限定詞か名詞のどちらかに揃えてください(a significant change / significant changes)。所有の語なら、主語の語に直してください(Your can → You can、their will → they will)。限定詞が二つ続いていれば、どちらかを消してください(the some roads → some roads か that some roads)。動詞を並べる所の名詞は、動詞に直してください(photography → photograph)。 + en: Make the determiner and the noun agree ("a significant change" or "significant changes"). For a possessive, write the subject you meant ("Your can" becomes "You can", "their will" becomes "they will"). For two determiners in a row, drop one ("the some roads" becomes "some roads", or "that some roads" if that was meant). For a noun where a verb belongs, write the verb ("photography" becomes "photograph"). levels: { strict: error, normal: warning, relaxed: info } @@ -62,5 +66,5 @@ example: after: This new version will ship in May. not_flagged: - ja: 単数と複数で形が同じ名詞(series、data)、this や these の直後の語、名詞を修飾する名詞(a sales team)、前置詞の後ろの所有の語と名詞の will や can(at its will)は指しません。homophone-slip が一覧に持つ組(their are)は、正しい語まで言うその規則が指し、ここでは指しません。 - en: Nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these", nouns that modify another noun ("a sales team"), and a possessive after a preposition with "will" or "can" as its noun ("at its will") are not reported. A pair homophone-slip lists ("their are") is reported by that rule, with the word meant, and not here. + ja: 単数と複数で形が同じ名詞(series、data)、this や these の直後の語、名詞を修飾する名詞(a sales team)、前置詞の後ろの所有の語と名詞の will や can(at its will)は指しません。homophone-slip が一覧に持つ組(their are)は、正しい語まで言うその規則が指し、ここでは指しません。to と動詞と and の後ろの名詞は、後ろに目的語が無ければ(to hike and photography.)名詞を並べた文かもしれないので指しません。 + en: Nouns spelled alike in both numbers ("series", "data"), a word right after "this" or "these", nouns that modify another noun ("a sales team"), and a possessive after a preposition with "will" or "can" as its noun ("at its will") are not reported. A pair homophone-slip lists ("their are") is reported by that rule, with the word meant, and not here. A noun after "to", a verb and "and" is not reported without an object after it ("to hike and photography."), where it may be a second noun phrase. diff --git a/text/packages/chaff/rules/inline-triad.yaml b/text/packages/chaff/rules/inline-triad.yaml new file mode 100644 index 000000000..2d5244eda --- /dev/null +++ b/text/packages/chaff/rules/inline-triad.yaml @@ -0,0 +1,63 @@ +id: inline-triad +layer: L2 +status: stable +how_to_find: inline-triad +extra_word_lists: [inline-triad] +languages: [en] +severity: info + +name: + ja: 文の中で三つずつ並べる + en: Threes strung on commas + +why: + ja: 生成された文章は、"the table, the conversation, the feeling of being cared for" のように、短い句を三つ、and も or も入れずにカンマだけでつなぐ形を繰り返します。三つは収まりがよいので、言いたいことが二つでも四つでも三つにされます。一つなら文の調子ですが、重なると中身より型が目立ちます。 + en: 'Generated prose keeps stringing three short phrases on commas with no "and" between them: "the table, the conversation, the feeling of being cared for". Three feels complete, so two things become three and four become three. Once is a turn of phrase; again and again, the pattern shows more than the content.' + +message: + ja: 「{matched}」など、and を入れずに三つ並べた句が 1000 語あたり {density} 個あります({limit} 個まで) + en: '"{matched}" and other threes strung on commas: {density} per 1000 words (limit {limit})' + +how_to_fix: + ja: 本当に三つあるときだけ三つ並べてください。足りない一つを足したのなら消し、残す並びには and を入れてください。 + en: Keep three only where there really are three. Drop the item added to make three, and join the rest with "and". + +# 1000 語あたりの個数。件数で数えると長い文書ほど当たる。 +levels: { strict: 2, normal: 3, relaxed: 5 } + +use_for: [blog, business, technical, legal, docs, academic, literature, speech] + +group: ai-tells +summary: + ja: 短い句を三つ、and を入れずにカンマだけで並べる形が何度も出る所 + en: Three short phrases strung on commas with no "and", again and again + +example: + en: + pad: true + before: | + I started with simple things: scrambled eggs, roasted vegetables, a basic tomato soup. Most dishes start the same way: an onion, some garlic, a little oil. I was chopping, stirring, paying attention. People come for the table, the conversation, the feeling of being cared for. + after: | + I started with scrambled eggs and a basic tomato soup. Most dishes start with an onion and a little oil. I was chopping and paying attention. People come for the conversation and the feeling of being cared for. + +not_flagged: + ja: 英語の文書だけを見ます。短い文書や、こうした並びが 3 つより少ない文書は測りません。and や or でつないだ並び(fast, cheap, and reliable)は人の文書のほうが多く書くので数えません。数字を含む並び(日付、金額、住所)、大文字で始まる名前や肩書きの並び(Jane Roe, Director, GDS)、同じ語の繰り返し(old, old, old)、箇条書きの中、引用符の中の並びは数えません。四つ以上の並びは三つとは数えません。 + en: Only English documents are checked. A short document, or one with fewer than three such runs, is not measured. A list joined with and / or (fast, cheap, and reliable) is not counted, since human documents write those more often. Runs holding a figure (a date, an amount, an address), names and titles that start with a capital (Jane Roe, Director, GDS), one word said again (old, old, old), runs inside a list or inside quotation marks, and runs of four or more are not counted. +level_meaning: + ja: 1000 語あたり三つの並び {limit} 個まで + en: up to {limit} {limit|run of three|runs of three} per 1000 words + +rewrite: + depth: light + en: + direction: In each run of three strung on commas, drop the item that repeats the other two and join the rest with "and". Where there really are three, keep them and add the "and". + pairs: + - before: They come for the table, the conversation, the feeling of being cared for. + after: They come for the conversation and the feeling of being cared for. + - before: I was chopping, stirring, paying attention. + after: I was chopping and paying attention. + keep: + - items that say different things + avoid: + - inventing a fourth item to get away from three + - adding content the document does not have diff --git a/text/packages/chaff/rules/latin-spacing.yaml b/text/packages/chaff/rules/latin-spacing.yaml index b1e3bee13..e69694c48 100644 --- a/text/packages/chaff/rules/latin-spacing.yaml +++ b/text/packages/chaff/rules/latin-spacing.yaml @@ -12,6 +12,7 @@ uses: [pos] # 建物の名前の後ろに空白で区切った階・部屋の番号(本社 5階)を見分ける。 # 名前だけを並べた行で、組織の名前と名前のあいだの空白(経営企画部 IR担当)を見分ける。 # 行の頭に図表の札だけを書いた後ろの空白(表 6種類の…)を見分ける。 +# URL と参照日の括弧書き((2024/3/12参照))を書いた出典の行を見分ける。 extra_word_lists: [ prefecture-unit, @@ -27,6 +28,7 @@ extra_word_lists: company-form, licence-word, figure-label, + access-date-label, ] name: @@ -73,8 +75,8 @@ example: 表は Excel で作り、Word に貼ります。図は PowerPoint で描きます。最後に PDF にします。 not_flagged: - ja: 電話番号や日付のような番号、版番号(1.0.0)、予約番号や型番(MN-48215)の前後、単位つきの日付や時刻(9月、10時5分)、AM・PM を付けた時刻(9:30AM)の後ろ、建物の名前の後ろに空白で区切った階や部屋の番号(本社 5階)の前、名前だけを並べた行の名前と名前のあいだ(経営企画部 IR担当)、英字の肩書きと、行の終わりまでの人の名前のあいだ(代表取締役CEO 森川 遼)、6 桁以上の番号やナンバープレートの前後、項目名とコロンの後ろの値の組のあいだ(所属:経済学科 1年)、項目名と値のあいだ(Bronzeプラン 10万円 (税込))、日本語の句をつなぐ英語の語の前後(名前 or メッセージ)、英字の語に付けた接尾の語(PDF版、IT化)の前、チャンネルや宛先の名前(#pj_oss-team、@sato)の後ろ、見出しの番号、行の頭の項目の番号(「一 JIS…」の一、イ)の後ろ、行の頭に図表の札だけを書いた後ろ(表 6種類の…)、名前だけを並べた行の空白を含む組織の名前の前(初等中等教育局 GIGA StuDX(…)推進チーム)、「」と“”の中、文献の記載の行、変換で区切りが消えて一続きになった数の表の数の前後、リンクの文字の中、文書の最後に掲載先が付けた利用条件の断り書き(ライセンスの名前と条件の URL を書いた短い段落)は数えません。どちらの空け方が正しいかは決めません。少ないほうが全体の 2 割を超えるほど多ければ(5 箇所以上)、また二通りが 2 箇所以上ずつの同数なら、1 箇所ずつではなく、書き方が二通りあることを 1 件で言います。1 対 1 の同数は言いません。 - en: Codes such as phone numbers, dates and version numbers (1.0.0), the spaces beside a booking or model number (MN-48215), dates and times with units (9月, 10時5分), the space after a time with AM or PM (9:30AM), the space before a floor or room number after the name of a building (本社 5階), the space between names on a line of names alone (経営企画部 IR担当), the space between a title in letters and the person's name that ends the line (代表取締役CEO 森川 遼), the spaces beside a code of six digits or more or a number plate, the space between the parts of a value after a label and a colon (所属:経済学科 1年), the space between a label and its value (Bronzeプラン 10万円 (税込)), the spaces around an English word joining Japanese phrases (名前 or メッセージ), the boundary before a suffix bound to a Latin word (PDF版, IT化), the boundary after a channel or handle name (#pj_oss-team, @sato), heading numbers, the space after an item number at the head of a line (一 JIS…), the space after a figure or table label alone at the head of a line (表 6種類の…), the space before an organisation's name that holds spaces on a line of names alone (初等中等教育局 GIGA StuDX(…)推進チーム), quotations in 「」 and “”, a line of a bibliographic entry, the spaces beside the numbers of a table of numbers a converter ran together, the text of links and a licence notice the publisher appends at the end (a short closing paragraph that names a licence and links to its terms) are not counted. Neither way is called right. When the less common way is more than a fifth of the places (and at least five), or both ways are used equally at two places or more each, it is reported once, as a document written two ways, rather than place by place. A one-to-one tie is not reported. + ja: 電話番号や日付のような番号、版番号(1.0.0)、予約番号や型番(MN-48215)の前後、単位つきの日付や時刻(9月、10時5分)、AM・PM を付けた時刻(9:30AM)の後ろ、建物の名前の後ろに空白で区切った階や部屋の番号(本社 5階)の前、名前だけを並べた行の名前と名前のあいだ(経営企画部 IR担当)、英字の肩書きと、行の終わりまでの人の名前のあいだ(代表取締役CEO 森川 遼)、6 桁以上の番号やナンバープレートの前後、項目名とコロンの後ろの値の組のあいだ(所属:経済学科 1年)、項目名と値のあいだ(Bronzeプラン 10万円 (税込))、日本語の句をつなぐ英語の語の前後(名前 or メッセージ)、英字の語に付けた接尾の語(PDF版、IT化)の前、チャンネルや宛先の名前(#pj_oss-team、@sato)の後ろ、見出しの番号、行の頭の項目の番号(「一 JIS…」の一、イ)の後ろ、行の頭に図表の札だけを書いた後ろ(表 6種類の…)、名前だけを並べた行の空白を含む組織の名前の前(初等中等教育局 GIGA StuDX(…)推進チーム)、「」と“”の中、文献の記載の行、URL と参照日の括弧書き((2024/3/12参照))を書いた出典の行、変換で区切りが消えて一続きになった数の表の数の前後、リンクの文字の中、文書の最後に掲載先が付けた利用条件の断り書き(ライセンスの名前と条件の URL を書いた短い段落)は数えません。どちらの空け方が正しいかは決めません。少ないほうが全体の 2 割を超えるほど多ければ(5 箇所以上)、また二通りが 2 箇所以上ずつの同数なら、1 箇所ずつではなく、書き方が二通りあることを 1 件で言います。1 対 1 の同数は言いません。 + en: Codes such as phone numbers, dates and version numbers (1.0.0), the spaces beside a booking or model number (MN-48215), dates and times with units (9月, 10時5分), the space after a time with AM or PM (9:30AM), the space before a floor or room number after the name of a building (本社 5階), the space between names on a line of names alone (経営企画部 IR担当), the space between a title in letters and the person's name that ends the line (代表取締役CEO 森川 遼), the spaces beside a code of six digits or more or a number plate, the space between the parts of a value after a label and a colon (所属:経済学科 1年), the space between a label and its value (Bronzeプラン 10万円 (税込)), the spaces around an English word joining Japanese phrases (名前 or メッセージ), the boundary before a suffix bound to a Latin word (PDF版, IT化), the boundary after a channel or handle name (#pj_oss-team, @sato), heading numbers, the space after an item number at the head of a line (一 JIS…), the space after a figure or table label alone at the head of a line (表 6種類の…), the space before an organisation's name that holds spaces on a line of names alone (初等中等教育局 GIGA StuDX(…)推進チーム), quotations in 「」 and “”, a line of a bibliographic entry, a source line that gives a URL and an access date in brackets ((2024/3/12参照)), the spaces beside the numbers of a table of numbers a converter ran together, the text of links and a licence notice the publisher appends at the end (a short closing paragraph that names a licence and links to its terms) are not counted. Neither way is called right. When the less common way is more than a fifth of the places (and at least five), or both ways are used equally at two places or more each, it is reported once, as a document written two ways, rather than place by place. A one-to-one tie is not reported. level_meaning: ja: 少ないほうの空け方が {limit} 箇所あれば指摘 en: reported once {limit} {limit|place goes|places go} against the document's habit diff --git a/text/packages/chaff/rules/no-mixed-desumasu.yaml b/text/packages/chaff/rules/no-mixed-desumasu.yaml index 4534d4933..5902e0ec0 100644 --- a/text/packages/chaff/rules/no-mixed-desumasu.yaml +++ b/text/packages/chaff/rules/no-mixed-desumasu.yaml @@ -21,6 +21,7 @@ extra_word_lists: interviewer-mark, feeling-aside, page-pointer, + person-suffix, ] requires: [pos] languages: [ja] @@ -127,8 +128,8 @@ example: 新しい料金は来月から始まります。請求書の形式も変わります。支払いの期限は月末です。古い料金は三月で終わります。 not_flagged: - ja: どちらの調子が正しいかは決めません。多いほうに揃っていない、少ないほうの文だけを指します。チームが chaff.yaml の options で本文・箇条書き・見出しの調子を決めたときだけ、そのまとまりでは混ざっていなくても決めた調子と違う文を指し、そのまとまりがそろっているかは見ません。文書の中で二つの調子が同じ数なら、揃える先の多いほうが無いので、どちらも指しません。本文と箇条書きは別々に数えます。箇条書きの中の少ないほうが文書全体では多いほうなら、その文は指しません。項目や段落の頭の太字の札(「- **速く書ける。** 説明です。」の「速く書ける。」)は見出しと同じく文に数えません。項目の頭の太字の札とコロンの直後の注記が、同じ項目の続きの文と違う調子のとき(「- **HDDが見つからない**:マウントされていない。差し直すと直ります。」の「マウントされていない。」)も、欄の値のような短い書き方なので指しません。免責や変更の予告を書いた段落(「…ご了承ください。」)が、2 文以上すべて文書の多いほうと違う同じ調子でそろっているときも、本文とは別の決まり文句として数えません。読み手の相談や質問を載せる節(見出しが「【相談事例等】」「ご質問内容」)の文も、尋ねた人の言葉のままなので数えません。文書の最後に掲載先が付けた利用条件の断り書き(ライセンスの名前と条件の URL を書いた短い段落)も数えません。札を付けて引いた言葉(「例:」「Q:」で始まる文、「用例」だけの段落の下の段落)、「■ 調査目的」のような印付きの札の行の下の記入欄の値、〒や「電話:」の行がある問い合わせ先の段落、一つの文の中に「?」で並べて引いた問い(…一覧か?順序付きか?などです。)、一番上の見出し(#)が二つ以上ある文書で、その見出しの下の 2 文以上がみな文書の多いほうと違う同じ調子でそろった部分(通達の後ろに付いた、ページの説明)も数えません。見出しが無くても、文書の多いほうの最後の文より後ろの 2 文以上がみな違う同じ調子でそろい(その調子の文がそれより前に無く)、その間に調子を持たない行(「第1」のようなリンクの並び)を挟むときは、ページの後ろの注記として数えません。数えたうえで指さないのは、丁寧な形でしか言わない挨拶(お疲れ様でした。)と結びの頼み(承認をお願いします。)、見出しの下にその一文だけを置いて、ページの読み手に詳しい所を示す丁寧な案内(## 概要 の下の「本検討会の概要は、…をご覧ください。」)、相手への願い(信じてほしい。)、条件だけで問う文(…だったら?)、演説で主語を言わずに決意を言い切る文(戦争の惨禍を、二度と繰り返さない。)、演説でこれから成し遂げることを「〜を…ていく。」と言い切る文(現場の気づきを、幹部の皆さんが形にしていく。)、次の文が「そんな」「こんな」「これだけで」で受ける場面や行いの書き出し(PDFが送れない。そんなときは…)、「!」で終わる叫び(わかるかっ!)、読み手に呼びかける終助詞「よ」「ね」「かな」で終わる文(…含まれているよ。…のかな?)、ブログで書き手が気持ちを漏らす文(形容詞で言い切る「まだよかった。」や、「〜し、」で並べてこぼす「画面は止まるし、音も途切れる。」)、※や*で始まる行の注記、文で終わらない行の塊に前後を挟まれた表のセル(制限なし。)、インタビュー(見出しの節の半分以上が聞き手の「――」の問いで始まる文書)の答えの段落の文です。答えは話した言葉を書き起こしたもので、話し手は丁寧な文と常体の文を混ぜて話します。動画の題(末尾に再生時間を括弧で書いた見出し)の下の説明も、動画の言葉のままなので数えません。 - en: Neither register is called right; only the sentences in the minority are pointed at. Only where a team names in chaff.yaml's options the register its body, lists or headings require is a sentence in the other register pointed at with no mix, and that region is then not checked for consistency. When the document holds as many sentences in one register as in the other, there is no majority to match and neither side is pointed at. The body and each list are counted apart, and a sentence in a list's minority is left alone when its register is the document's majority. A bold label that opens an item or a paragraph and is followed by more text on its line is a heading, not a sentence. The note right after a list item's bold label and colon is not pointed at either when the item goes on in the other register (- **HDDが見つからない**:マウントされていない。差し直すと直ります。), since it is written as a field's value. A paragraph of disclaimer or notice wording (…ご了承ください。) whose two or more sentences all share the register the rest of the document does not use is boilerplate in its own voice and is not counted. Nor are the sentences of a section whose heading names what a reader asked (【相談事例等】, ご質問内容), since they quote the asker in their own words. Nor is a licence notice the publisher appends at the end (a short closing paragraph that names a licence and links to its terms). Nor are words quoted under a label (a sentence opening with 例: or Q:, the paragraph under a lone 用例), the value under a marked field label (■ 調査目的), a contact block (a paragraph with a 〒 or 電話: line), questions run together inside one sentence (…一覧か?順序付きか?などです。), or, in a document with two top-level (#) headings or more, a part under one of them whose two or more sentences all share the register the rest of the document does not use (a page's note about the directive it carries). Nor, without such a heading, are the two or more sentences after the last one in the document's register when they all share the other register, used nowhere before them, and a line without a register (links such as 第1) sits among them (a page's note under the text it carries). Counted but never pointed at are a greeting or a closing request said only politely (お疲れ様でした。承認をお願いします。), a polite pointer the page gives its reader to where more is said, as the only sentence under its heading (本検討会の概要は、…をご覧ください。 under ## 概要),a wish to others (信じてほしい。), a question that gives only a condition (…だったら?), a speaker declaring a resolve without a subject in a speech (戦争の惨禍を、二度と繰り返さない。), a speaker stating in a speech what is to be carried out, ending in 〜ていく with an object (現場の気づきを、幹部の皆さんが形にしていく。), a scene-setting opener the next sentence takes up with そんな, こんな or これだけで, a cry that ends in an exclamation mark (わかるかっ!), a sentence that closes with a particle addressing the reader, よ, ね or かな (…含まれているよ。…のかな?), a blog writer's aside of feeling, ending on an adjective (まだよかった。) or running complaints together with 〜し、 (画面は止まるし、音も途切れる。),a note on a line opening with ※ or *, a table cell set out between runs of lines that do not end as sentences (制限なし。), and the sentences of an interview's answers (in a document where at least half of the headed sections open with the interviewer's ―― question), since an answer is speech set down and a speaker mixes polite and plain sentences. Nor is the caption under a video's title (a heading ending with its running time in brackets), which is in the video's own words. + ja: どちらの調子が正しいかは決めません。多いほうに揃っていない、少ないほうの文だけを指します。チームが chaff.yaml の options で本文・箇条書き・見出しの調子を決めたときだけ、そのまとまりでは混ざっていなくても決めた調子と違う文を指し、そのまとまりがそろっているかは見ません。文書の中で二つの調子が同じ数なら、揃える先の多いほうが無いので、どちらも指しません。本文と箇条書きは別々に数えます。箇条書きの中の少ないほうが文書全体では多いほうなら、その文は指しません。項目や段落の頭の太字の札(「- **速く書ける。** 説明です。」の「速く書ける。」)は見出しと同じく文に数えません。項目の頭の太字の札とコロンの直後の注記が、同じ項目の続きの文と違う調子のとき(「- **HDDが見つからない**:マウントされていない。差し直すと直ります。」の「マウントされていない。」)も、欄の値のような短い書き方なので指しません。免責や変更の予告を書いた段落(「…ご了承ください。」)が、2 文以上すべて文書の多いほうと違う同じ調子でそろっているときも、本文とは別の決まり文句として数えません。読み手の相談や質問を載せる節(見出しが「【相談事例等】」「ご質問内容」)の文も、尋ねた人の言葉のままなので数えません。文書の最後に掲載先が付けた利用条件の断り書き(ライセンスの名前と条件の URL を書いた短い段落)も数えません。札を付けて引いた言葉(「例:」「Q:」で始まる文、「用例」だけの段落の下の段落)、「■ 調査目的」のような印付きの札の行の下の記入欄の値、〒や「電話:」の行がある問い合わせ先の段落、一つの文の中に「?」で並べて引いた問い(…一覧か?順序付きか?などです。)、一番上の見出し(#)が二つ以上ある文書で、その見出しの下の 2 文以上がみな文書の多いほうと違う同じ調子でそろった部分(通達の後ろに付いた、ページの説明)も数えません。見出しが無くても、文書の多いほうの最後の文より後ろの 2 文以上がみな違う同じ調子でそろい(その調子の文がそれより前に無く)、その間に調子を持たない行(「第1」のようなリンクの並び)を挟むときは、ページの後ろの注記として数えません。数えたうえで指さないのは、丁寧な形でしか言わない挨拶(お疲れ様でした。)と結びの頼み(承認をお願いします。)、見出しの下にその一文だけを置いて、ページの読み手に詳しい所を示す丁寧な案内(## 概要 の下の「本検討会の概要は、…をご覧ください。」)、相手への願い(信じてほしい。)、条件だけで問う文(…だったら?)、演説で主語を言わずに決意を言い切る文(戦争の惨禍を、二度と繰り返さない。)、演説でこれから成し遂げることを「〜を…ていく。」と言い切る文(現場の気づきを、幹部の皆さんが形にしていく。)、次の文が「そんな」「こんな」「これだけで」で受ける場面や行いの書き出し(PDFが送れない。そんなときは…)、「!」で終わる叫び(わかるかっ!)、読み手に呼びかける終助詞「よ」「ね」「かな」で終わる文(…含まれているよ。…のかな?)、ブログで書き手が気持ちを漏らす文(形容詞で言い切る「まだよかった。」や、「〜し、」で並べてこぼす「画面は止まるし、音も途切れる。」)、※や*で始まる行の注記、文で終わらない行の塊に前後を挟まれた表のセル(制限なし。)、インタビュー(見出しの節の半分以上が聞き手の「――」の問いで始まる文書)の答えの段落の文です。答えは話した言葉を書き起こしたもので、話し手は丁寧な文と常体の文を混ぜて話します。動画の題(末尾に再生時間を括弧で書いた見出し)の下の説明も、動画の言葉のままなので数えません。敬称の付いた人の名前を見出しにし、職業だけの文で始まる節(### 山田花子さん / 写真家。…)も、常体で書くのが慣例の寄稿者の紹介なので数えません。 + en: Neither register is called right; only the sentences in the minority are pointed at. Only where a team names in chaff.yaml's options the register its body, lists or headings require is a sentence in the other register pointed at with no mix, and that region is then not checked for consistency. When the document holds as many sentences in one register as in the other, there is no majority to match and neither side is pointed at. The body and each list are counted apart, and a sentence in a list's minority is left alone when its register is the document's majority. A bold label that opens an item or a paragraph and is followed by more text on its line is a heading, not a sentence. The note right after a list item's bold label and colon is not pointed at either when the item goes on in the other register (- **HDDが見つからない**:マウントされていない。差し直すと直ります。), since it is written as a field's value. A paragraph of disclaimer or notice wording (…ご了承ください。) whose two or more sentences all share the register the rest of the document does not use is boilerplate in its own voice and is not counted. Nor are the sentences of a section whose heading names what a reader asked (【相談事例等】, ご質問内容), since they quote the asker in their own words. Nor is a licence notice the publisher appends at the end (a short closing paragraph that names a licence and links to its terms). Nor are words quoted under a label (a sentence opening with 例: or Q:, the paragraph under a lone 用例), the value under a marked field label (■ 調査目的), a contact block (a paragraph with a 〒 or 電話: line), questions run together inside one sentence (…一覧か?順序付きか?などです。), or, in a document with two top-level (#) headings or more, a part under one of them whose two or more sentences all share the register the rest of the document does not use (a page's note about the directive it carries). Nor, without such a heading, are the two or more sentences after the last one in the document's register when they all share the other register, used nowhere before them, and a line without a register (links such as 第1) sits among them (a page's note under the text it carries). Counted but never pointed at are a greeting or a closing request said only politely (お疲れ様でした。承認をお願いします。), a polite pointer the page gives its reader to where more is said, as the only sentence under its heading (本検討会の概要は、…をご覧ください。 under ## 概要),a wish to others (信じてほしい。), a question that gives only a condition (…だったら?), a speaker declaring a resolve without a subject in a speech (戦争の惨禍を、二度と繰り返さない。), a speaker stating in a speech what is to be carried out, ending in 〜ていく with an object (現場の気づきを、幹部の皆さんが形にしていく。), a scene-setting opener the next sentence takes up with そんな, こんな or これだけで, a cry that ends in an exclamation mark (わかるかっ!), a sentence that closes with a particle addressing the reader, よ, ね or かな (…含まれているよ。…のかな?), a blog writer's aside of feeling, ending on an adjective (まだよかった。) or running complaints together with 〜し、 (画面は止まるし、音も途切れる。),a note on a line opening with ※ or *, a table cell set out between runs of lines that do not end as sentences (制限なし。), and the sentences of an interview's answers (in a document where at least half of the headed sections open with the interviewer's ―― question), since an answer is speech set down and a speaker mixes polite and plain sentences. Nor is the caption under a video's title (a heading ending with its running time in brackets), which is in the video's own words. Nor is a section headed by a person's name with an honorific that opens on an occupation alone (### 山田花子さん / 写真家。…): a contributor's profile, written in the plain form by convention. level_meaning: ja: 少ないほうの調子の文が {limit} 文以下のとき、それを指摘 en: reported when the minority register has {limit} {limit|sentence|sentences} or fewer diff --git a/text/packages/chaff/rules/repeated-sentence-ending.yaml b/text/packages/chaff/rules/repeated-sentence-ending.yaml index 7c9dbe8cc..c36dbe22b 100644 --- a/text/packages/chaff/rules/repeated-sentence-ending.yaml +++ b/text/packages/chaff/rules/repeated-sentence-ending.yaml @@ -43,8 +43,8 @@ example: この機能は必要で、設定も簡単です。費用はかかりません。 not_flagged: - ja: 段落をまたいだ文は続きと見ません。助動詞で終わらない文(体言止め、言い切りの動詞)は比べず、そこで続きが切れます。動詞が違えば(読みました、書きました)同じ文末とは見ません。述語の前の語まで同じ締めの句を三文以上重ねた繰り返し(いい船でした。…いい船でした。…いい船でした。)は、一つと数えます。一つの文の中に「?」で並べた問い(これはリストか?順序付きか?…などです。)も比べません。違う語を同じ型で定義する文の並び(台風は〜を指します。ハリケーンは〜を指します。)は、型をそろえたものなので指しません。見出しの語([通信関連]、化学品事業……)で始まる文は新しい項目の始まりで、前の項目の文とは続きと見ません。変換で一文に平らになった表(数字のセルがつながったもの、単位の括弧で閉じる見出しのセルが並ぶもの)は、その後ろの注まで含めて書き手の文ではないので比べず、そこで続きが切れます。 - en: Sentences in different paragraphs are not a run. A sentence that does not end with an auxiliary (a noun, a bare verb) is not compared and breaks the run. Different verbs (読みました, 書きました) are different endings. Three sentences or more in a row that close on the very same phrase, the word before the predicate included (いい船でした。…いい船でした。…いい船でした。), are a refrain and count once. Questions run together inside one sentence (これはリストか?順序付きか?…などです。) are not compared either. Sentences that each define a different term in the same frame (台風は〜を指します。ハリケーンは〜を指します。) share their ending on purpose and are not reported. A sentence that opens with a label ([通信関連], 化学品事業……) starts a new item of a list and does not continue the run before it. A table a converter flattened into one sentence (numbers of two cells run together, header cells each closed by a unit in brackets), with the note it runs into, is not the writer's sentence, so it is not compared and breaks the run. + ja: 段落をまたいだ文は続きと見ません。助動詞で終わらない文(体言止め、言い切りの動詞)は比べず、そこで続きが切れます。動詞が違えば(読みました、書きました)同じ文末とは見ません。述語の前の語まで同じ締めの句を三文以上重ねた繰り返し(いい船でした。…いい船でした。…いい船でした。)は、一つと数えます。一つの文の中に「?」で並べた問い(これはリストか?順序付きか?…などです。)も比べません。違う語を同じ型で定義する文の並び(台風は〜を指します。ハリケーンは〜を指します。)は、型をそろえたものなので指しません。見出しの語([通信関連]、化学品事業……)で始まる文は新しい項目の始まりで、前の項目の文とは続きと見ません。変換で一文に平らになった表(数字のセルがつながったもの、単位の括弧で閉じる見出しのセルが並ぶもの)は、その後ろの注まで含めて書き手の文ではないので比べず、そこで続きが切れます。平らになった表で始まる段落(最初の文が見出しの行)は、後ろの文も表の行がセルの中の句点で切れたものなので、段落ごと比べません。 + en: Sentences in different paragraphs are not a run. A sentence that does not end with an auxiliary (a noun, a bare verb) is not compared and breaks the run. Different verbs (読みました, 書きました) are different endings. Three sentences or more in a row that close on the very same phrase, the word before the predicate included (いい船でした。…いい船でした。…いい船でした。), are a refrain and count once. Questions run together inside one sentence (これはリストか?順序付きか?…などです。) are not compared either. Sentences that each define a different term in the same frame (台風は〜を指します。ハリケーンは〜を指します。) share their ending on purpose and are not reported. A sentence that opens with a label ([通信関連], 化学品事業……) starts a new item of a list and does not continue the run before it. A table a converter flattened into one sentence (numbers of two cells run together, header cells each closed by a unit in brackets), with the note it runs into, is not the writer's sentence, so it is not compared and breaks the run. A paragraph that opens with such a table (its first sentence is the header row) holds the table's rows, cut only at the stops inside their cells, and is not compared at all. level_meaning: ja: 同じ文末の文が {limit} 文続くまで en: up to {limit} {limit|sentence|sentences} in a row with the same ending diff --git a/text/packages/chaff/rules/section-reflection-ending.yaml b/text/packages/chaff/rules/section-reflection-ending.yaml new file mode 100644 index 000000000..758aad55b --- /dev/null +++ b/text/packages/chaff/rules/section-reflection-ending.yaml @@ -0,0 +1,125 @@ +id: section-reflection-ending +layer: L2 +status: stable +how_to_find: section-reflection-ending +word_list: section-reflection-ending +uses: [pos] +severity: info + +name: + ja: どの節も所感の文で閉じる + en: Every section closes on a personal reflection + +why: + ja: 「〜と思います」「〜と感じています」で節を閉じるのは、人の随筆や報告にも普通にある書き方です。ただ、節のほとんどが同じように所感で閉じると、中身を書いたあとに感想を一文足す型に見え、生成文によくある形です。 + en: Closing a section with "I think ..." or "I feel ..." is ordinary in essays and reports. When nearly every section closes that way, it reads as a template that adds a line of feeling after the content, a shape common in generated text. + +message: + ja: 「{matched}」など、{sections} 節のうち {count} 節が所感の文で閉じています({share}%、{limit}% から) + en: '"{matched}" and other reflections close {count} of {sections} sections ({share}%, {limit}% needed)' + +how_to_fix: + ja: 所感の文を消すか、その節で分かったこと(数字、起きたこと、次にすること)で閉じてください。感想を残すなら、一番言いたい節だけにします。 + en: Drop the reflection, or close the section on what it found (a number, what happened, what comes next). Keep a reflection only where it matters most. + +# 所感の文で閉じる節の割合(%)。人の文書で測った割合の最も高いものより上に置く(rules:measure の人の文書と、isamu/chaff-corpus の人の文書)。 +levels: { strict: 40, normal: 50, relaxed: 67 } + +options: + min_sections: + kind: count + default: 4 + about: + ja: 測る節の数の下限。節が少ないと、所感で閉じる節が 1 つ 2 つでも割合が大きく出て、人の書いた文書でも当たります + en: The fewest sections measured. With few sections, one or two reflective closings make a large share, and a person's writing is reported too + +use_for: [technical/readme, blog, business, legal, docs, academic, literature, speech] + +group: ai-tells +summary: + ja: 「〜と思います」「〜と感じています」のように、節のほとんどが所感の文で閉じている所 + en: Nearly every section closing on "I think ..." or "I feel ..." +example: + ja: + config: { genre: blog/essay } + before: | + # 自転車通勤を始めて + + ## 朝 + + 駅まで歩いていた道を、自転車で十分ほど走ります。朝の空気が気持ちよく、続けてよかったと思います。 + + ## 帰り + + 帰りは坂が多く、最初の週は脚が張りました。いまは慣れて、いい運動になっていると感じています。 + + ## 雨の日 + + 雨の日は電車にしています。無理をしないことが、長く続けるこつかもしれません。 + + ## お金 + + 定期代が月に八千円ほど浮きました。小さな額でも、積み重なると大きいと思います。 + after: | + # 自転車通勤を始めて + + ## 朝 + + 駅まで歩いていた道を、自転車で十分ほど走ります。家を出るのは五分遅くなりました。 + + ## 帰り + + 帰りは坂が多く、最初の週は脚が張りました。二週目には治りました。いまは平気です。 + + ## 雨の日 + + 雨の日は電車です。先月は、雨で自転車に乗れなかった日が月のうち六日ありました。 + + ## お金 + + 定期代が月に八千円ほど浮きました。自転車の代金は、一年半で元が取れる計算です。 + en: + config: { genre: blog/essay } + before: | + # Cycling to work + + ## Mornings + + The ride to the station takes about ten minutes. I think the fresh air is the best part of the day. + + ## Evenings + + The way home has more hills, and my legs ached the first week. I feel it has become good exercise. + + ## Rainy days + + On rainy days I take the train. I believe not forcing it is what keeps a habit going. + + ## Money + + I save about eighty dollars a month on the train pass. I think small savings add up. + after: | + # Cycling to work + + ## Mornings + + The ride to the station takes about ten minutes. I leave home five minutes later. + + ## Evenings + + The way home has more hills, and my legs ached the first week. Not now. + + ## Rainy days + + On rainy days I take the train, which last month meant six days out of the twenty I worked. + + ## Money + + I save about eighty dollars a month on the train pass. The bike pays for itself in a year and a half. + +not_flagged: + ja: 所感で閉じる節が一つでも、節のうち割合が上限より低ければ言いません。節(段落のある節)が 4 より少ない文書は測りません(min_sections で変えられます)。見るのは、節の最後の段落の最後の文だけです。箇条書きだけの節は数えません。 + en: A reflection closing one section, or a share below the limit, is not reported. A document with fewer than 4 sections that hold a paragraph is not measured (min_sections changes it). Only the last sentence of a section's last paragraph is read; a section of only a list is not counted. +level_meaning: + ja: 所感の文で閉じる節が {limit}% 以上なら指摘 + en: reported when {limit}% or more of the sections close on a reflection diff --git a/text/packages/chaff/rules/topic-predicate-distance.yaml b/text/packages/chaff/rules/topic-predicate-distance.yaml index e53c5612c..91c06daff 100644 --- a/text/packages/chaff/rules/topic-predicate-distance.yaml +++ b/text/packages/chaff/rules/topic-predicate-distance.yaml @@ -3,7 +3,7 @@ layer: L3 status: stable how_to_find: topic-predicate-distance requires: [pos] -extra_word_lists: [topic-clause-close, statute-article-opener, topic-adverb] +extra_word_lists: [topic-clause-close, statute-article-opener, topic-adverb, topic-phrase-particle] languages: [ja] severity: info @@ -45,8 +45,8 @@ example: 来週は、新しい担当者の紹介、先月から続く予算の見直し、春の本社移転の準備、秋の採用計画の確認、年末の懇親会の段取りを話し合います。そのため定例会議は二時間に延長します。 not_flagged: - ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」「〜の想定のため、」(後ろが話し手の頼み(〜していただけると、〜いただきたい)でもよい)「〜であり、」(主題との間に別の主題(〜は)が無く、文末がまた繋辞か「〜がある」でないとき。主題が行いを名詞にしたもの(〜することは重要であり、…影響を及ぼす可能性があります)なら、後ろに別の主語があれば文末は何でもよい。後ろの主語は節を名詞にしたもの(〜することが求められている)でもよく、文末の名詞に「が」の主語が付くとき(〜を図ることが必要である)や、最後の読点の後に行いを名詞にした主語(〜を行うことも、〜を図ることが)があるときは繋辞で終わっても)、受け身の「〜され、」(受け身の主語が名詞(支部が置かれ)でなく、後ろに時を言うのではない名詞の新しい主題(〜の議論は)が立ち、主題との間に別の主題が無いとき)、繋辞の理由「〜ものですから、」「〜であるので、」(後ろに時を言うのではない名詞の新しい主題(私たちは)が立ち、主題との間に別の主題が無いとき)、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」(打ち消しの「〜ませんが、」「〜ませんでしたが、」も)の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題(〜は、〜には)に移る文か、直後に名詞の新しい主題(〜ましたが、赤澤大臣は…、〜ておりますが、本事業は、…)が立って文末まで続く文、主題が行いを名詞にしたもの(〜することは差し控えますが、…)、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」、問いの「〜のか、」(語は語彙表 topic-clause-close)、述語の後ろに丸数字の番号(③)が来て一行に詰まった箇条の次の項目が始まるところ、「〜のは」の主題が「という」で名詞に掛かる節の中で繋辞の述語を得て、その名詞句が読点で終わるところ(〜来てほしいのは日本であったという調査の結果、…)、主題が読点を挟まずに「〜という〜」の節の中で述語を得て、その名詞句の後の読点の後ろに名詞の新しい主題が立つところ(食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…))は、その節の終わりまでを数えます。後ろの節の主語には「〜のほとんどは」も数えます。副詞になる「は」(最後は=結局のところ。語は語彙表 topic-adverb)は主題と読みません。前に名詞や「の」が付けば(交渉の最後は)主題です。時や場面を言う「は」(今夜は、当日は、〜ときは)の後ろに別の主題があれば、その主題から数えます。時や場面を言う主題(決定後は、普及以前は)は、「〜ますが、」「〜でしたが、」の後ろに別の主語があれば、間に別の主語があってもそこまでを数えます。法令でも契約でもない文書が条文をそのまま載せた文(「第7条 …」、形は語彙表 statute-article-opener)は、書き手が直せる文ではないので数えません。英語の文書には使いません。 - en: Sentences with no topic (noun + は), quotations in 「」, and distances up to the limit are not counted. When the topic gets its own predicate in an earlier clause (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜の想定のため (or followed by the speaker asking a favour, as in 〜していただけると, 〜いただきたい), 〜であり (when no other topic stands between and the sentence does not end on a copula or 〜がある again, or ends on anything when the topic is an act made a noun and a subject of its own follows (〜することは重要であり、…影響を及ぼす可能性があります); the later subject may be a clause made a noun, 〜することが求められている, and when the final noun has a subject of its own with が, 〜を図ることが必要である, or an act made a noun with が or も follows the last comma, 〜を行うことも重要な役割である, the sentence may end on a copula), a passive 〜され whose own subject is not a noun (支部が置かれ), followed by a new topic on a noun that does not set the time (〜の議論は) with no other topic between, a copula's reason 〜ものですから or 〜であるので followed by a new topic on a noun that does not set the time (私たちは) with no other topic between, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが (or the negative 〜ませんが, 〜ませんでしたが) with no other subject between the topic and it, followed by a clause with a subject of its own (〜が) and then a new topic (〜は, 〜には), or straight away by a noun as a new topic that runs to the end (〜ましたが、赤澤大臣は…, 〜ておりますが、本事業は、…), or always when the topic is an act made a noun (〜することは差し控えますが、…); 〜ことから, 〜つつ, 〜としても, 〜こととし or a question's 〜のか with no other subject between the topic and it, from the topic-clause-close word list; a circled number (③) after a predicate, where a list run into one line starts its next item; a 〜のは topic that gets its copula inside a clause という makes a noun's content, when that noun phrase ends at a comma, as in 〜来てほしいのは日本であったという調査の結果、…; a topic that gets its predicate, with no comma between, inside a clause という makes a noun's content, when a new topic on a noun follows the comma after that noun phrase, as in 食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…), the count stops at that clause's end. A later clause's subject may be a part, as in 〜のほとんどは. A は that makes an adverb of the noun before it (最後は, in the end; the words are in the topic-adverb word list) is not a topic; with a noun or の before it (交渉の最後は) it is. When a は that sets the time or the case (今夜は, 当日は, 〜ときは) is followed by another topic, the count starts from that topic. A topic that sets the time or the case (決定後は, 普及以前は) ends at 〜ますが or 〜でしたが when a subject of its own follows, even with another subject between. An article of a statute that a document of another kind quotes as it stands (第7条 …, the forms in the statute-article-opener word list) is not the writer's sentence and is not counted. Not used on English documents. + ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」「〜の想定のため、」(後ろが話し手の頼み(〜していただけると、〜いただきたい)でもよい)「〜であり、」(主題との間に別の主題(〜は)が無く、文末がまた繋辞か「〜がある」でないとき。主題が行いを名詞にしたもの(〜することは重要であり、…影響を及ぼす可能性があります)なら、後ろに別の主語があれば文末は何でもよい。後ろの主語は節を名詞にしたもの(〜することが求められている)でもよく、文末の名詞に「が」の主語が付くとき(〜を図ることが必要である)や、最後の読点の後に行いを名詞にした主語(〜を行うことも、〜を図ることが)があるときは繋辞で終わっても)、受け身の「〜され、」(受け身の主語が名詞(支部が置かれ)でなく、後ろに時を言うのではない名詞の新しい主題(〜の議論は)が立ち、主題との間に別の主題が無いとき)、繋辞の理由「〜ものですから、」「〜であるので、」(後ろに時を言うのではない名詞の新しい主題(私たちは)が立ち、主題との間に別の主題が無いとき)、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」(打ち消しの「〜ませんが、」「〜ませんでしたが、」も)の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題(〜は、〜には)に移る文か、直後に名詞の新しい主題(〜ましたが、赤澤大臣は…、〜ておりますが、本事業は、…)が立って文末まで続く文、主題が行いを名詞にしたもの(〜することは差し控えますが、…)、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」、問いの「〜のか、」(語は語彙表 topic-clause-close)、述語の後ろに丸数字の番号(③)が来て一行に詰まった箇条の次の項目が始まるところ、「〜のは」の主題が「という」で名詞に掛かる節の中で繋辞の述語を得て、その名詞句が読点で終わるところ(〜来てほしいのは日本であったという調査の結果、…)、主題が読点を挟まずに「〜という〜」の節の中で述語を得て、その名詞句の後の読点の後ろに名詞の新しい主題が立つところ(食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…))は、その節の終わりまでを数えます。後ろの節の主語には「〜のほとんどは」も、「〜については」「〜に関しては」(語は語彙表 topic-phrase-particle)も数えます。副詞になる「は」(最後は=結局のところ。語は語彙表 topic-adverb)は主題と読みません。前に名詞や「の」が付けば(交渉の最後は)主題です。時や場面を言う「は」(今夜は、当日は、〜ときは)の後ろに別の主題があれば、その主題から数えます。時や場面を言う主題(決定後は、普及以前は)は、「〜ますが、」「〜でしたが、」の後ろに別の主語があれば、間に別の主語があってもそこまでを数えます。法令でも契約でもない文書が条文をそのまま載せた文(「第7条 …」、形は語彙表 statute-article-opener)は、書き手が直せる文ではないので数えません。英語の文書には使いません。 + en: Sentences with no topic (noun + は), quotations in 「」, and distances up to the limit are not counted. When the topic gets its own predicate in an earlier clause (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜の想定のため (or followed by the speaker asking a favour, as in 〜していただけると, 〜いただきたい), 〜であり (when no other topic stands between and the sentence does not end on a copula or 〜がある again, or ends on anything when the topic is an act made a noun and a subject of its own follows (〜することは重要であり、…影響を及ぼす可能性があります); the later subject may be a clause made a noun, 〜することが求められている, and when the final noun has a subject of its own with が, 〜を図ることが必要である, or an act made a noun with が or も follows the last comma, 〜を行うことも重要な役割である, the sentence may end on a copula), a passive 〜され whose own subject is not a noun (支部が置かれ), followed by a new topic on a noun that does not set the time (〜の議論は) with no other topic between, a copula's reason 〜ものですから or 〜であるので followed by a new topic on a noun that does not set the time (私たちは) with no other topic between, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが (or the negative 〜ませんが, 〜ませんでしたが) with no other subject between the topic and it, followed by a clause with a subject of its own (〜が) and then a new topic (〜は, 〜には), or straight away by a noun as a new topic that runs to the end (〜ましたが、赤澤大臣は…, 〜ておりますが、本事業は、…), or always when the topic is an act made a noun (〜することは差し控えますが、…); 〜ことから, 〜つつ, 〜としても, 〜こととし or a question's 〜のか with no other subject between the topic and it, from the topic-clause-close word list; a circled number (③) after a predicate, where a list run into one line starts its next item; a 〜のは topic that gets its copula inside a clause という makes a noun's content, when that noun phrase ends at a comma, as in 〜来てほしいのは日本であったという調査の結果、…; a topic that gets its predicate, with no comma between, inside a clause という makes a noun's content, when a new topic on a noun follows the comma after that noun phrase, as in 食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…), the count stops at that clause's end. A later clause's subject may be a part, as in 〜のほとんどは, or stand on a compound particle, as in 〜については and 〜に関しては (the topic-phrase-particle word list). A は that makes an adverb of the noun before it (最後は, in the end; the words are in the topic-adverb word list) is not a topic; with a noun or の before it (交渉の最後は) it is. When a は that sets the time or the case (今夜は, 当日は, 〜ときは) is followed by another topic, the count starts from that topic. A topic that sets the time or the case (決定後は, 普及以前は) ends at 〜ますが or 〜でしたが when a subject of its own follows, even with another subject between. An article of a statute that a document of another kind quotes as it stands (第7条 …, the forms in the statute-article-opener word list) is not the writer's sentence and is not counted. Not used on English documents. level_meaning: ja: 主題から述語まで {limit} 字まで en: up to {limit} {limit|character|characters} between the topic and the predicate diff --git a/text/packages/chaff/skills/chaff/SKILL.md b/text/packages/chaff/skills/chaff/SKILL.md index 15eee729a..17342bdbd 100644 --- a/text/packages/chaff/skills/chaff/SKILL.md +++ b/text/packages/chaff/skills/chaff/SKILL.md @@ -225,8 +225,10 @@ chaff marks the shapes common in generated text (group "Signs of generated text" `contrast-framing`, `stock-transition`, `announcing-opener`, `colon-lead-in`, `over-general-claim` (English only), `q-fragment-answer` (English only), `assistant-residue`, `email-stock-courtesy` (English emails: stacked "I hope this email finds you well"-type courtesies), `honesty-marker` ("Honestly,", 「正直、」: one is reported in blog posts and business documents), +`inline-triad` (English only: three short phrases strung on commas with no "and", again and again), `closing-exhortation` (a closing that cheers the reader on: 「ぜひ〜してみてください」, "You've got this"), `cold-open` (an opening that piles a bare wish, a quoted echo of the previous sentence and a teaser), +`section-reflection-ending` (nearly every section closing on a personal reflection: 「〜と思います」, "I think ..."), `unprompted-denial` (sentences that deny a premise nobody stated: 「〜の話ではありません」, "This isn't about tooling."), and the signals `ai-generated-composite` reads, among others). Most of them do not run in `technical/spec` or in the legal, docs, literature and speech genres; `assistant-residue` (words left from a pasted chat reply) runs in almost every genre. `npx chaffjs rules --json` diff --git a/text/packages/chaff/src/ai-score/human-shares.ts b/text/packages/chaff/src/ai-score/human-shares.ts index 36f5449c3..c4e069886 100644 --- a/text/packages/chaff/src/ai-score/human-shares.ts +++ b/text/packages/chaff/src/ai-score/human-shares.ts @@ -162,6 +162,16 @@ export const HUMAN_SHARES: HumanShares = { technical: { documents: 49, fired: 0 }, }, "honesty-marker": { blog: { documents: 23, fired: 0 }, business: { documents: 80, fired: 0 } }, + "inline-triad": { + academic: { documents: 5, fired: 0 }, + blog: { documents: 9, fired: 0 }, + business: { documents: 41, fired: 0 }, + docs: { documents: 11, fired: 0 }, + legal: { documents: 14, fired: 0 }, + literature: { documents: 9, fired: 0 }, + speech: { documents: 3, fired: 0 }, + technical: { documents: 27, fired: 0 }, + }, "no-em-dash": { academic: { documents: 10, fired: 0 }, blog: { documents: 23, fired: 0 }, @@ -226,6 +236,16 @@ export const HUMAN_SHARES: HumanShares = { speech: { documents: 7, fired: 0 }, technical: { documents: 26, fired: 0 }, }, + "section-reflection-ending": { + academic: { documents: 10, fired: 0 }, + blog: { documents: 23, fired: 0 }, + business: { documents: 80, fired: 0 }, + docs: { documents: 21, fired: 0 }, + legal: { documents: 35, fired: 0 }, + literature: { documents: 13, fired: 0 }, + speech: { documents: 7, fired: 0 }, + technical: { documents: 26, fired: 0 }, + }, "sentence-rhythm": { academic: { documents: 10, fired: 0 }, blog: { documents: 23, fired: 1 }, diff --git a/text/packages/chaff/src/detectors/agreement-slip.ts b/text/packages/chaff/src/detectors/agreement-slip.ts index 8ef0d3786..387758493 100644 --- a/text/packages/chaff/src/detectors/agreement-slip.ts +++ b/text/packages/chaff/src/detectors/agreement-slip.ts @@ -28,9 +28,17 @@ export type AgreementLists = { readonly prepositions?: ReadonlySet; /** homophone-slip が言う組(their are)。その規則が正しい語まで言うので、ここでは数えない。 */ readonly homophones?: ReadonlySet; + /** 動詞の所に書いた、綴りの違う派生名詞と、意図した動詞(photography → photograph)。 */ + readonly nounForVerb?: ReadonlyMap; }; -export type Slip = { readonly variant: "number" | "possessive" | "determiner"; readonly first: Token; readonly last: Token; readonly word: string }; +export type Slip = { + readonly variant: "number" | "possessive" | "determiner" | "conjunct"; + readonly first: Token; + readonly last: Token; + readonly word: string; + readonly verb?: string; +}; const SPACE_ONLY = /^\s+$/u; const UPPER_START = /^\p{Lu}/u; @@ -221,18 +229,42 @@ const doubledDeterminerAt = (source: string, tokens: readonly Token[], at: numbe return slipOf("determiner", source, article, second); }; +/** 名詞の後ろで、目的語の頭になる品詞。名詞は目的語を取らないので、ここに立つ名詞は動詞の書き損じ。 */ +const OBJECT_START = new Set(["NOUN", "PROPN", "DET", "PRON"]); + +/** + * to と動詞の原形と and の後ろの、目的語を取る派生名詞(to safely watch and photography wildlife)。動詞を並べる所に、名詞を書いた跡。 + * 名詞の後ろに目的語が無ければ(to hike and photography.)、名詞句を並べた文かもしれないので数えない。 + */ +const conjunctSlipAt = (source: string, tokens: readonly Token[], at: number, lists: AgreementLists): Slip | undefined => { + const to = tokens[at]; + if (to === undefined || to.pos !== "PART" || lower(to) !== "to") return undefined; + const verbAt = tokens.findIndex((token, index) => index > at && token.pos !== "ADV"); + const [verb, and, noun, object] = [tokens[verbAt], tokens[verbAt + 1], tokens[verbAt + 2], tokens[verbAt + 3]]; + if (verbAt === -1 || !isBaseVerb(verb) || and === undefined || lower(and) !== "and" || !isCommonNoun(noun)) return undefined; + const meant = lists.nounForVerb?.get(lower(noun)); + if (meant === undefined || object === undefined || !OBJECT_START.has(object.pos)) return undefined; + const span = tokens.slice(at, verbAt + 3); + if (!joinedBySpace(source, span) || !joinedBySpace(source, [noun, object])) return undefined; + return { ...slipOf("conjunct", source, to, noun), verb: meant }; +}; + export const agreementIn = (source: string, tokens: readonly Token[], lists: AgreementLists): Slip[] => tokens.flatMap((_, at) => { const slip = numberSlipAt(source, tokens, at, lists) ?? possessiveSlipAt(source, tokens, at, lists) ?? misnumberedAt(source, tokens, at, lists) ?? - doubledDeterminerAt(source, tokens, at, lists); + doubledDeterminerAt(source, tokens, at, lists) ?? + conjunctSlipAt(source, tokens, at, lists); return slip === undefined ? [] : [slip]; }); const setOf = (lexicon: Lexicon | undefined): ReadonlySet => new Set((lexicon ?? []).map((entry) => entry.pattern.toLowerCase())); +const rewritesOf = (lexicon: Lexicon | undefined): ReadonlyMap => + new Map((lexicon ?? []).flatMap((entry): [string, string][] => (entry.rewrite === undefined ? [] : [[entry.pattern.toLowerCase(), entry.rewrite]]))); + const listsOf = (lexicons: Readonly>): AgreementLists => ({ singular: lexicons["singular-determiner"] ?? [], plural: lexicons["plural-determiner"] ?? [], @@ -244,6 +276,7 @@ const listsOf = (lexicons: Readonly>): AgreementLists => afterArticle: setOf(lexicons["determiner-after-article"]), prepositions: setOf(lexicons["object-preposition"]), homophones: setOf(lexicons["homophone-slip"]), + nounForVerb: rewritesOf(lexicons["noun-for-verb"]), }); export const agreementSlip: Detector = (doc): Finding[] => { @@ -255,7 +288,7 @@ export const agreementSlip: Detector = (doc): Finding[] => { line: 0, column: 0, quote: sentence.text.trim(), - values: { word: slip.word, offset: slip.first.span.start }, + values: { word: slip.word, offset: slip.first.span.start, ...(slip.verb === undefined ? {} : { verb: slip.verb }) }, variant: slip.variant, })), ); diff --git a/text/packages/chaff/src/detectors/clause-shape.ts b/text/packages/chaff/src/detectors/clause-shape.ts index c7b897984..d453275b9 100644 --- a/text/packages/chaff/src/detectors/clause-shape.ts +++ b/text/packages/chaff/src/detectors/clause-shape.ts @@ -96,12 +96,14 @@ const runFinding = (run: readonly Ended[], limit: number): Finding => { /** * More than limit sentences in a row within one paragraph that end with the same words, unless they define different terms in one - * frame. A refrain (いい船でした。…いい船でした。) counts once. + * frame. A refrain (いい船でした。…いい船でした。) counts once. A paragraph that opens with a flattened table (its header row) holds + * the table's rows, cut at the stops inside their cells, not the writer's sentences, and is not read. */ export const endingRun: Detector = (doc, options): Finding[] => { const words = definitionWordsOf(options.lexicon); const eras = (doc.lexicons["calendar-era"] ?? []).map((entry) => entry.pattern); - return doc.paragraphs.flatMap((paragraph) => + const prose = doc.paragraphs.filter((paragraph) => !isFlattenedTable(paragraph.sentences[0]?.text ?? "", eras)); + return prose.flatMap((paragraph) => endingRuns(paragraph.sentences, eras) .map((run) => ({ run, sentences: run.map(({ sentence }) => sentence) })) .filter(({ sentences }) => beatsOf(sentences, patternsOf(options.lexicon, "being")) > options.limit && !isParallelDefinition(sentences, words)) diff --git a/text/packages/chaff/src/detectors/inline-triad.ts b/text/packages/chaff/src/detectors/inline-triad.ts new file mode 100644 index 000000000..16a65d9bc --- /dev/null +++ b/text/packages/chaff/src/detectors/inline-triad.ts @@ -0,0 +1,149 @@ +// inline-triad: three short phrases strung on commas with no and / or (the table, the conversation, the feeling of +// being cared for), counted per length of the document. Pure. A list joined by and / or is left out: human prose +// writes those as often as generated prose. The words that open a clause rather than an item, and the words that make +// two items parallel, come from the word list. +import type { Detector, Finding, Lexicon, ProseDocument, Sentence, Span } from "../plugin.ts"; +import { isWithinAny, QUOTATION_MARKS, quotedIn } from "../quoted-span.ts"; +import { rateOver } from "./lexicon.ts"; + +export type TriadWords = { + readonly heads: ReadonlySet; + readonly conjunctions: ReadonlySet; + readonly determiners: ReadonlySet; + readonly suffixes: readonly string[]; +}; +export type Triad = { readonly start: number; readonly end: number; readonly matched: string }; +type Part = { readonly text: string; readonly start: number }; +type Clause = { readonly parts: readonly Part[]; readonly afterColon: boolean }; + +/** The longest a middle item runs, and the last one, which may carry the rest of its clause. */ +const ITEM_MAX_WORDS = 5; +const LAST_ITEM_MAX_WORDS = 7; +/** Fewer than this many in a document, and one turn of phrase decides the density. */ +export const MIN_TRIADS = 3; +const THREE = 3; +const CLAUSE_BREAKS = /[;:—–()[\]"“”]/gu; +const OPENS_ITEMS = new Set([":", "—", "–"]); +const DIGIT = /\d/u; +const LOWER_START = /^\p{Ll}/u; +const CLOSING_MARKS: ReadonlySet = new Set([".", "!", "?", "…"]); + +const withoutClosingMarks = (text: string): string => (CLOSING_MARKS.has(text.at(-1) ?? "") ? withoutClosingMarks(text.slice(0, -1)) : text); + +const wordsIn = (text: string): string[] => + text + .trim() + .split(/\s+/u) + .filter((word) => word !== ""); +const firstWord = (text: string): string => (wordsIn(text)[0] ?? "").toLowerCase().replace(/[^\p{L}']/gu, ""); + +const partsOf = (text: string, start: number): Part[] => { + const pieces = text.split(","); + return pieces.map((piece, at) => ({ text: piece, start: start + pieces.slice(0, at).reduce((sum, before) => sum + before.length + 1, 0) })); +}; + +/** The clauses of a sentence, split at the marks that close a phrase, each with its comma-separated parts. */ +export const clausesOf = (text: string): Clause[] => { + const ends = [...[...text.matchAll(CLAUSE_BREAKS)].map((match) => match.index), text.length]; + return ends.map((end, at) => { + const start = at === 0 ? 0 : (ends[at - 1] ?? 0) + 1; + return { parts: partsOf(text.slice(start, end), start), afterColon: OPENS_ITEMS.has(text.charAt(start - 1)) }; + }); +}; + +/** A short phrase that can be an item: no figure (dates, amounts, addresses), no and / or, not a clause's opening word. */ +const isItem = (text: string, maxWords: number, words: TriadWords): boolean => { + const count = wordsIn(text).length; + return ( + count > 0 && + count <= maxWords && + !DIGIT.test(text) && + !wordsIn(text).some((word) => words.conjunctions.has(word.toLowerCase())) && + !words.heads.has(firstWord(text)) + ); +}; + +/** The items after the opening one start in lower case: a capitalised run is a name, a title or an address (Jane Roe, Director, GDS). */ +const isLaterItem = (text: string, maxWords: number, words: TriadWords): boolean => LOWER_START.test(text.trim()) && isItem(text, maxWords, words); + +/** How many items the run ending at parts[at] and the two after it has: a part too long or opening a clause holds the first item at its end. */ +const itemsBefore = (parts: readonly Part[], at: number, words: TriadWords): number => { + const part = parts[at]; + if (part === undefined || part.text.trim() === "" || DIGIT.test(part.text)) return 0; + return isItem(part.text, ITEM_MAX_WORDS, words) ? 1 + itemsBefore(parts, at - 1, words) : 1; +}; + +const hasSuffix = (word: string, suffixes: readonly string[]): boolean => suffixes.some((suffix) => word.length > suffix.length && word.endsWith(suffix)); + +/** Two items in the same form: the same first word, a determiner each, or the same ending (chopping, stirring). */ +const areParallel = (left: string, right: string, words: TriadWords): boolean => { + const [first, second] = [firstWord(left), firstWord(right)]; + if (first === second) return true; + if (words.determiners.has(first) && words.determiners.has(second)) return true; + return words.suffixes.some((suffix) => hasSuffix(first, [suffix]) && hasSuffix(second, [suffix])); +}; + +/** One word said again (an old, old, old fight; repeat, repeat, repeat): emphasis, not three items. */ +const repeatsOneWord = (opening: string, middle: string, last: string): boolean => { + const word = middle.trim().toLowerCase(); + return [wordsIn(opening).at(-1), wordsIn(last)[0]].some((other) => other !== undefined && withoutClosingMarks(other.toLowerCase()) === word); +}; + +const lastWordsOf = (text: string): string => wordsIn(text).slice(-ITEM_MAX_WORDS).join(" "); + +const triadOf = (clause: Clause, words: TriadWords): Triad | undefined => { + const { parts } = clause; + const [opening, middle, last] = parts.slice(-THREE); + if (parts.length < THREE || opening === undefined || middle === undefined || last === undefined) return undefined; + if (!isLaterItem(last.text, LAST_ITEM_MAX_WORDS, words) || !isLaterItem(middle.text, ITEM_MAX_WORDS, words)) return undefined; + if (repeatsOneWord(opening.text, middle.text, last.text) || itemsBefore(parts, parts.length - THREE, words) !== 1) return undefined; + const listOpened = clause.afterColon && parts.length === THREE && isItem(opening.text, ITEM_MAX_WORDS, words); + if (!listOpened && !areParallel(middle.text, last.text, words)) return undefined; + const first = lastWordsOf(opening.text); + const start = opening.start + opening.text.lastIndexOf(first); + return { start, end: last.start + last.text.trimEnd().length, matched: [first, middle.text.trim(), withoutClosingMarks(last.text.trim())].join(", ") }; +}; + +/** The triads in one sentence's text, with positions in that text. */ +export const inlineTriads = (text: string, words: TriadWords): Triad[] => + clausesOf(text).flatMap((clause) => { + const triad = triadOf(clause, words); + return triad === undefined ? [] : [triad]; + }); + +const patternsIn = (lexicon: Lexicon, group: string): string[] => lexicon.filter((entry) => entry.group === group).map((entry) => entry.pattern.toLowerCase()); + +export const triadWordsOf = (lexicon: Lexicon): TriadWords => ({ + heads: new Set(patternsIn(lexicon, "head")), + conjunctions: new Set(patternsIn(lexicon, "conjunction")), + determiners: new Set(patternsIn(lexicon, "determiner")), + suffixes: patternsIn(lexicon, "suffix"), +}); + +type Hit = { readonly sentence: Sentence; readonly triad: Triad; readonly offset: number }; + +const inList = (doc: ProseDocument, offset: number): boolean => doc.listSpans.some((span) => offset >= span.start && offset < span.end); + +const hitsIn = (doc: ProseDocument, sentence: Sentence, words: TriadWords): Hit[] => { + const quoted: readonly Span[] = quotedIn(sentence, QUOTATION_MARKS); + return inlineTriads(sentence.text, words) + .map((triad) => ({ sentence, triad, offset: sentence.span.start + triad.start })) + .filter((hit) => !inList(doc, hit.offset) && !isWithinAny(quoted, { start: hit.offset, end: sentence.span.start + hit.triad.end })); +}; + +const findingOf = (hit: Hit, count: number, density: number, limit: number): Finding => ({ + rule: "inline-triad", + severity: "info", + line: 0, + column: 0, + quote: hit.sentence.text.trim(), + values: { matched: hit.triad.matched, count, density, limit, offset: hit.offset }, +}); + +/** Every triad once the document holds enough of them, more per 1000 words than the limit. */ +export const inlineTriad: Detector = (doc, options): Finding[] => { + const words = triadWordsOf(doc.lexicons["inline-triad"] ?? []); + const hits = doc.sentences.filter((sentence) => sentence.embeddedLanguage === undefined).flatMap((sentence) => hitsIn(doc, sentence, words)); + const density = hits.length < MIN_TRIADS ? undefined : rateOver(doc, hits.length, options.limit); + return density === undefined ? [] : hits.map((hit) => findingOf(hit, hits.length, density, options.limit)); +}; diff --git a/text/packages/chaff/src/detectors/list-sequence-lead.ts b/text/packages/chaff/src/detectors/list-sequence-lead.ts new file mode 100644 index 000000000..9208819e9 --- /dev/null +++ b/text/packages/chaff/src/detectors/list-sequence-lead.ts @@ -0,0 +1,28 @@ +import { isClause, shapeOf } from "./list-item.ts"; +import type { ItemScope } from "./list-sentence.ts"; +import type { TokenRange } from "./token-column.ts"; + +/** The item after and / or without the sequence word that opens it (and then ride / and finally chop). */ +const withoutSequenceLead = (scope: ItemScope, item: TokenRange): TokenRange => { + const lead = scope.sentence.tokens[item.start]?.surface.toLowerCase() ?? ""; + const isSequence = scope.sentence.words.sequence?.has(lead) ?? false; + return item.end - item.start > 1 && isSequence ? { start: item.start + 1, end: item.end } : item; +}; + +/** + * The shape the last item and the item after and / or share, or undefined. A sequence word right after the conjunction + * marks a step, so the item is read by the word past it (We visited Paris, Rome, and then Berlin). Where the sequence + * word matches an adverb that opens the last item, the items are adverbs in a row (primarily by stage, secondarily by + * timebox, and finally by date), unless the words past it take the first item's shape: then the and / or goes on from + * the first item, past an aside (Take a bus to the station, easily spotted from afar, and then ride), and there is no list. + */ +export const sharedShape = (scope: ItemScope, first: TokenRange, last: TokenRange, afterItem: TokenRange): string | undefined => { + const shape = shapeOf(scope, last); + const rest = withoutSequenceLead(scope, afterItem); + // and then we rested: past the sequence word comes a clause of its own, not an item of the list. + const past = rest !== afterItem && isClause(scope, rest) ? undefined : shapeOf(scope, rest); + const asWritten = shapeOf(scope, afterItem); + if (shape === undefined) return undefined; + if (asWritten === shape) return past !== asWritten && past === shapeOf(scope, first) ? undefined : shape; + return past === shape ? shape : undefined; +}; diff --git a/text/packages/chaff/src/detectors/orthography.ts b/text/packages/chaff/src/detectors/orthography.ts index 5eb77811f..9cdda79f8 100644 --- a/text/packages/chaff/src/detectors/orthography.ts +++ b/text/packages/chaff/src/detectors/orthography.ts @@ -230,6 +230,7 @@ export const latinSpacing: Detector = (doc, options): Finding[] => { }; // 文書の最後の利用条件の断り書き(クリエイティブ・コモンズ 表示 4.0 国際)は、掲載先の書き方で書き手の空け方ではない。 const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []); + const accessLabels = patternList(doc, "access-date-label"); const located: Located[] = doc.sentences.flatMap((sentence) => { if (licence.has(sentence)) return []; // 「」『』のほか、“”で引いた題名(“パブリック・ドメイン・マーク 1.0 全世界コモンズ証”)も元の書き方。 @@ -243,7 +244,7 @@ export const latinSpacing: Detector = (doc, options): Finding[] => { return ( latinBoundaries(sentence.text, doc.source.slice(sentence.span.start, sentence.span.end)) .filter((boundary) => !isQuoted(quoted, boundary) && !isInsideLink(doc.links, sentence.span.start + boundary.offset)) - .filter((boundary) => !isCitedEntryLine(lineAt(doc.source, sentence.span.start + boundary.offset))) + .filter((boundary) => !isCitedEntryLine(lineAt(doc.source, sentence.span.start + boundary.offset), accessLabels)) // 変換で一続きになった数の表の、升の区切りの空白。 .filter((boundary) => !isNumberTableBoundary(sentence.text, boundary)) .filter((boundary) => isCounted(sentence, boundary, context, codes)) diff --git a/text/packages/chaff/src/detectors/oxford-comma.ts b/text/packages/chaff/src/detectors/oxford-comma.ts index c1cf72b4c..631cbc234 100644 --- a/text/packages/chaff/src/detectors/oxford-comma.ts +++ b/text/packages/chaff/src/detectors/oxford-comma.ts @@ -61,6 +61,7 @@ import { insideSentenceCaseTitle } from "./title-list.ts"; import { insideByline } from "./byline-list.ts"; import { withoutOpeningConjunction } from "./list-opening-conjunction.ts"; import { afterClauseBeforeInfinitives } from "./list-purpose-clause.ts"; +import { sharedShape } from "./list-sequence-lead.ts"; const EMPTY: TokenRange = { start: 0, end: 0 }; @@ -393,9 +394,8 @@ const listAt = (list: ItemList, at: number, walk: Walk): boolean | undefined => if (namesDivision(items) || qualifiesPrevious(items)) return undefined; const last = lastOf(items); if (last !== undefined && opensContrast(scope, last.item)) return undefined; - const shape = last === undefined ? undefined : shapeOf(scope, last.item); - if (sizeOf(items) < 2 || shape === undefined || shape !== shapeOf(scope, afterItem)) return undefined; - return itemsAgree(scope, items, afterItem, shape) ? commaBefore(scope, at) : undefined; + const shape = last === undefined || sizeOf(items) < 2 ? undefined : sharedShape(scope, firstOf(items)?.item ?? last.item, last.item, afterItem); + return shape !== undefined && itemsAgree(scope, items, afterItem, shape) ? commaBefore(scope, at) : undefined; }; const isJudgedConjunction = (token: Token, at: number): boolean => at > 0 && isListConjunction(token); diff --git a/text/packages/chaff/src/detectors/registry/inline-triad.ts b/text/packages/chaff/src/detectors/registry/inline-triad.ts new file mode 100644 index 000000000..0dff3d873 --- /dev/null +++ b/text/packages/chaff/src/detectors/registry/inline-triad.ts @@ -0,0 +1,4 @@ +import type { Detector } from "../../plugin.ts"; +import { inlineTriad } from "../inline-triad.ts"; + +export const detector: Detector = inlineTriad; diff --git a/text/packages/chaff/src/detectors/registry/section-reflection-ending.ts b/text/packages/chaff/src/detectors/registry/section-reflection-ending.ts new file mode 100644 index 000000000..5b3be2cec --- /dev/null +++ b/text/packages/chaff/src/detectors/registry/section-reflection-ending.ts @@ -0,0 +1,4 @@ +import type { Detector } from "../../plugin.ts"; +import { sectionReflectionEnding } from "../section-reflection-ending.ts"; + +export const detector: Detector = sectionReflectionEnding; diff --git a/text/packages/chaff/src/detectors/section-reflection-ending.ts b/text/packages/chaff/src/detectors/section-reflection-ending.ts new file mode 100644 index 000000000..fab2a4555 --- /dev/null +++ b/text/packages/chaff/src/detectors/section-reflection-ending.ts @@ -0,0 +1,50 @@ +import type { Detector, DetectorOptions, Finding, Lexicon, Paragraph, ProseDocument, Sentence } from "../plugin.ts"; +import { entryCloses, entryOpens } from "./lexicon-match.ts"; + +// 節を所感の文(〜と思います、〜と感じています、I think ...)で閉じる節が、節のうちどれだけあるか。語はどれも語彙表が持ち、 +// ここは組み方だけを知る。語彙表の group: +// end 文の終わりの語(と思います、かもしれない) +// open 文頭の語(I think、I feel) + +const END = "end"; +const OPEN = "open"; +const DEFAULT_MIN_SECTIONS = 4; +const PERCENT = 100; + +/** 文が所感の文なら、当たった語。 */ +export const reflectionIn = (sentence: Sentence, lexicon: Lexicon): string | undefined => + lexicon.find((entry) => (entry.group === OPEN ? entryOpens(sentence, entry) : entry.group === END && entryCloses(sentence, entry)))?.pattern; + +/** 節を閉じる文:節の中の最後の段落の、最後の文。段落の無い節(見出しと箇条書きだけ)は数えない。 */ +export const sectionClosers = (doc: Pick): Sentence[] => + doc.sections.flatMap((section) => { + const last = doc.paragraphs.filter((paragraph: Paragraph) => paragraph.span.start >= section.span.start && paragraph.span.start < section.span.end).at(-1); + const closer = last?.sentences.at(-1); + return closer === undefined ? [] : [closer]; + }); + +const minimumSections = (options: DetectorOptions): number => { + const value = options.settings?.["min_sections"]; + return typeof value === "number" ? value : DEFAULT_MIN_SECTIONS; +}; + +/** 所感で閉じる節の割合(%)が limit 以上なら、その文ごとに一つ。節が min_sections より少ない文書は測らない。 */ +export const sectionReflectionEnding: Detector = (doc, options): Finding[] => { + const lexicon = options.lexicon ?? []; + const closers = sectionClosers(doc); + if (closers.length < minimumSections(options)) return []; + const hits = closers.flatMap((sentence) => { + const matched = reflectionIn(sentence, lexicon); + return matched === undefined ? [] : [{ sentence, matched }]; + }); + const share = Math.round((hits.length * PERCENT) / closers.length); + if (hits.length === 0 || share < options.limit) return []; + return hits.map((hit) => ({ + rule: "", + severity: "info", + line: 0, + column: 0, + quote: hit.sentence.text.trim(), + values: { matched: hit.matched, count: hits.length, sections: closers.length, share, limit: options.limit, offset: hit.sentence.span.start }, + })); +}; diff --git a/text/packages/chaff/src/detectors/sentence-ending.ts b/text/packages/chaff/src/detectors/sentence-ending.ts index 3d9238fd4..30aca37a0 100644 --- a/text/packages/chaff/src/detectors/sentence-ending.ts +++ b/text/packages/chaff/src/detectors/sentence-ending.ts @@ -7,6 +7,7 @@ import { noticeSentences } from "./notice-paragraph.ts"; import { separatePartSentences, trailingPartSentences } from "./register-separate-part.ts"; import { askerSentences } from "./asker-voice.ts"; import { recordingCaptionSentences } from "../recording-title.ts"; +import { profileSentences } from "../profile-section.ts"; import { licenceNoticeSentences } from "./licence-notice.ts"; import { chronologyRows } from "../chronology-rows.ts"; import { isNeutralPlainShape } from "./register-neutral-shape.ts"; @@ -114,7 +115,11 @@ export const judgedSentences = (doc: ProseDocument, polite: readonly LexiconEntr const words = endingWords(doc, polite, genre); const lists = doc.lists.map((list) => list.span); const rows = chronologyRows(doc); - const asked = new Set([...askerSentences(doc.sections, doc.lexicons["asker-heading"] ?? []), ...recordingCaptionSentences(doc.sections)]); + const asked = new Set([ + ...askerSentences(doc.sections, doc.lexicons["asker-heading"] ?? []), + ...recordingCaptionSentences(doc.sections), + ...profileSentences(doc.sections, doc.lexicons["person-suffix"] ?? []), + ]); const licence = licenceNoticeSentences(doc, doc.lexicons["licence-word"] ?? []); const quoted = labelledQuoteSentences(doc.paragraphs, doc.source, doc.lexicons["quote-label"] ?? []); const fields = fieldValueSentences(doc.sentences, doc.source); diff --git a/text/packages/chaff/src/detectors/topic-predicate-distance.ts b/text/packages/chaff/src/detectors/topic-predicate-distance.ts index 55b98a7df..9fcfc135f 100644 --- a/text/packages/chaff/src/detectors/topic-predicate-distance.ts +++ b/text/packages/chaff/src/detectors/topic-predicate-distance.ts @@ -7,6 +7,7 @@ import { overLimit, ownTokens } from "./sentence-load.ts"; const CLOSER_LEXICON = "topic-clause-close"; const ARTICLE_LEXICON = "statute-article-opener"; const ADVERB_LEXICON = "topic-adverb"; +const PHRASE_PARTICLE_LEXICON = "topic-phrase-particle"; /** * Whether the sentence is an article of a statute quoted in another kind of document (第7条 … in a manual): the law's wording, @@ -21,7 +22,7 @@ const quotesArticle = (doc: ProseDocument, genre: string | undefined): ((sentenc /** The distance from the sentence's topic (〜は) to the end, where its predicate is. Needs the language's tokens. */ export const topicPredicateDistance: Detector = (doc, options) => { const patterns = (lexicon: string): string[] => (doc.lexicons[lexicon] ?? []).map((entry) => entry.pattern); - const words: TopicClauseWords = { closers: patterns(CLOSER_LEXICON), adverbs: patterns(ADVERB_LEXICON) }; + const words: TopicClauseWords = { closers: patterns(CLOSER_LEXICON), adverbs: patterns(ADVERB_LEXICON), phraseParticles: patterns(PHRASE_PARTICLE_LEXICON) }; const quoted = quotesArticle(doc, options.genre); return overLimit((sentence) => (sentence.tokens === undefined || quoted(sentence) ? undefined : topicDistance(ownTokens(sentence), words)))(doc, options); }; diff --git a/text/packages/chaff/src/latin-spacing-source.ts b/text/packages/chaff/src/latin-spacing-source.ts index 2519d1540..2b59e7304 100644 --- a/text/packages/chaff/src/latin-spacing-source.ts +++ b/text/packages/chaff/src/latin-spacing-source.ts @@ -11,7 +11,23 @@ import { hasGluedNumbers } from "./detectors/sentence-parts.ts"; const ENTRY_AUTHOR = /^[ \t]*[^.。.\n]{1,60}\.\s/u; const ENTRY_YEAR = /\.\s(?:1[89]|20)\d{2}[,,]/u; -export const isCitedEntryLine = (line: string): boolean => ENTRY_AUTHOR.test(line) && ENTRY_YEAR.test(line); +const URL_MARK = /https?:\/\//u; +/** 括弧書き((2024/3/12参照)、(閲覧日 2024年3月12日))の中身。 */ +const ASIDES = /[((]([^()()]*)[))]/gu; +const NUMERAL = /\d/u; + +/** 出典の後ろの参照日の括弧書き: 中身が参照日の語(語彙表 access-date-label)で始まるか終わる。 */ +const hasAccessDate = (line: string, accessLabels: readonly string[]): boolean => + [...line.matchAll(ASIDES)].some( + ([, inside = ""]) => NUMERAL.test(inside) && accessLabels.some((label) => inside.trim().startsWith(label) || inside.trim().endsWith(label)), + ); + +/** + * 文献の記載の行: SIST の書き方か、URL と参照日の括弧書きを書いた出典の行(注の「内閣府 ○○会議「題」,(2024/3/12参照)」)。 + * 出典の行の空白は発行元と会議の名前の区切りのような記載の区切りで、文の中の空け方ではない。 + */ +export const isCitedEntryLine = (line: string, accessLabels: readonly string[] = []): boolean => + (ENTRY_AUTHOR.test(line) && ENTRY_YEAR.test(line)) || (URL_MARK.test(line) && hasAccessDate(line, accessLabels)); /** at を含む行。 */ export const lineAt = (text: string, at: number): string => { diff --git a/text/packages/chaff/src/profile-section.ts b/text/packages/chaff/src/profile-section.ts new file mode 100644 index 000000000..674c0faa7 --- /dev/null +++ b/text/packages/chaff/src/profile-section.ts @@ -0,0 +1,24 @@ +import type { LexiconEntry, Section, Sentence, Token } from "./plugin.ts"; + +// A section headed by a person's name with an honorific (山田花子さん, 山田氏) that opens on the person's occupation alone +// (イラストレーター。) is a profile of a contributor. Profiles are written in the plain form by convention, whatever the register +// of the page around them, so their sentences are not compared with the page's. Pure. + +/** Parts of speech of a sentence that only names something (イラストレーター。, 料理研究家・管理栄養士。). */ +const NAMING_POS: ReadonlySet = new Set(["NOUN", "PROPN", "PUNCT", "SYM"]); + +const namesOnly = (tokens: readonly Token[] | undefined): boolean => + tokens !== undefined && tokens.some((token) => token.pos === "NOUN" || token.pos === "PROPN") && tokens.every((token) => NAMING_POS.has(token.pos)); + +const endsWithHonorific = (heading: string, suffixes: readonly LexiconEntry[]): boolean => { + const words = heading.trim(); + return suffixes.some((entry) => words.length > entry.pattern.length && words.endsWith(entry.pattern)); +}; + +/** Whether the section is a person's profile: its heading ends on an honorific and its first sentence only names an occupation. */ +export const isProfileSection = (section: Section, suffixes: readonly LexiconEntry[]): boolean => + endsWithHonorific(section.unlabeledHeading ?? section.heading, suffixes) && namesOnly(section.firstSentence?.tokens); + +/** The sentences of every profile section. suffixes is the person-suffix lexicon (さん, 氏). */ +export const profileSentences = (sections: readonly Section[], suffixes: readonly LexiconEntry[]): Set => + new Set(sections.filter((section) => isProfileSection(section, suffixes)).flatMap((section) => section.sentences)); diff --git a/text/packages/chaff/src/topic-clause.ts b/text/packages/chaff/src/topic-clause.ts index 18eac9256..a22801cd7 100644 --- a/text/packages/chaff/src/topic-clause.ts +++ b/text/packages/chaff/src/topic-clause.ts @@ -45,10 +45,18 @@ const isNarrowedPart = (tokens: readonly Token[], at: number): boolean => /** The word before at heads a subject of its own: a noun (法律は), or a part a の phrase narrows (処理のほとんどは). */ const headsSubject = (tokens: readonly Token[], at: number): boolean => isOwnNoun(tokens[at - 1]) || isNarrowedPart(tokens, at - 1); +/** は on a compound particle after a noun of its own (販売については, 販売に関しては): a topic of its own, as 販売は is. */ +const isPhraseTopicAt = (tokens: readonly Token[], at: number, phraseParticles: readonly string[]): boolean => { + const particle = tokens[at - 1]; + return particle?.pos === "ADP" && phraseParticles.includes(particle.surface) && isOwnNoun(tokens[at - 2]); +}; + /** A subject of its own at at: は on its head anywhere, or が on its head when lastComma is before it (-1 to take every が). */ -const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number): boolean => { +const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number, phraseParticles: readonly string[]): boolean => { const token = tokens[at]; - return token !== undefined && headsSubject(tokens, at) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma)); + if (token === undefined) return false; + if (isParticle(token, "は") && isPhraseTopicAt(tokens, at, phraseParticles)) return true; + return headsSubject(tokens, at) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma)); }; /** @@ -56,9 +64,9 @@ const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number) * noun with が that the final predicate takes (no comma after it: 動きが見られ始めている). A noun with が inside a condition * (債務者が請求した場合、) is not one. -1 when there is none. A clause has a subject of its own after it when this is past it. */ -const lastOwnSubject = (tokens: readonly Token[], last: number): number => { +const lastOwnSubject = (tokens: readonly Token[], last: number, phraseParticles: readonly string[]): number => { const lastComma = tokens.findLastIndex((token, at) => at < last && isComma(token)); - return tokens.findLastIndex((_, at) => at < last && isOwnSubjectAt(tokens, at, lastComma)); + return tokens.findLastIndex((_, at) => at < last && isOwnSubjectAt(tokens, at, lastComma, phraseParticles)); }; /** The words of the clause after a comma at from, up to the next clause stopped by a comma, or the sentence's last word. */ @@ -279,6 +287,8 @@ export type TopicClauseWords = { readonly closers: readonly string[]; /** Nouns that は makes an adverb of (最後は, in the end): the topic-adverb lexicon. Such a は is no topic. */ readonly adverbs?: readonly string[]; + /** Compound particles a topic stands on (について, に関して): the topic-phrase-particle lexicon. */ + readonly phraseParticles?: readonly string[]; }; const NO_WORDS: TopicClauseWords = { closers: [] }; @@ -347,7 +357,7 @@ const newNameTopicRunsToEnd = (tokens: readonly Token[], comma: number, last: nu const start = isNounPrefix(tokens[comma + 1]) ? comma + 2 : comma + 1; const topic = tokens.findIndex((token, index) => index >= start && !isNameWord(token)); const wa = tokens[topic]; - return topic > start && wa !== undefined && isParticle(wa, "は") && lastOwnSubject(tokens, last) <= topic; + return topic > start && wa !== undefined && isParticle(wa, "は") && lastOwnSubject(tokens, last, []) <= topic; }; /** @@ -438,7 +448,7 @@ const closesTopicInNounClause = (tokens: readonly Token[], topic: number, at: nu * topic's predicate is the one the sentence ends on. */ export const topicClauseEnd = (tokens: readonly Token[], topic: number, last: number, words: TopicClauseWords = NO_WORDS): number | undefined => { - const subject = lastOwnSubject(tokens, last); + const subject = lastOwnSubject(tokens, last, words.phraseParticles ?? []); const closes = (at: number): boolean => closesSurely(tokens, at, last) || (closesIfNewSubject(tokens, at) && (subject > at || requestAfter(tokens, at, last))) || diff --git a/text/packages/lang-en/lexicons/inline-triad.yaml b/text/packages/lang-en/lexicons/inline-triad.yaml new file mode 100644 index 000000000..095dd5243 --- /dev/null +++ b/text/packages/lang-en/lexicons/inline-triad.yaml @@ -0,0 +1,71 @@ +# The words inline-triad reads to tell three items strung on commas from a sentence broken by commas. +# head: a word that opens a clause or an aside, not an item ("Well, honestly, it works" holds no items; in "I was +# chopping, stirring, paying attention" the first item is the end of the clause "I was chopping"). +# conjunction: an item holding one of these is part of a list joined with and / or, which the rule leaves out. +# determiner: two items that each open with one of these are in the same form (the table, the conversation). +# suffix: two items whose first words share this ending are in the same form (chopping, stirring). +id: inline-triad +language: en +entries: + - { pattern: i, group: head } + - { pattern: you, group: head } + - { pattern: he, group: head } + - { pattern: she, group: head } + - { pattern: it, group: head } + - { pattern: we, group: head } + - { pattern: they, group: head } + - { pattern: there, group: head } + - { pattern: which, group: head } + - { pattern: who, group: head } + - { pattern: whom, group: head } + - { pattern: whose, group: head } + - { pattern: where, group: head } + - { pattern: when, group: head } + - { pattern: while, group: head } + - { pattern: if, group: head } + - { pattern: because, group: head } + - { pattern: although, group: head } + - { pattern: though, group: head } + - { pattern: since, group: head } + - { pattern: unless, group: head } + - { pattern: until, group: head } + - { pattern: so, group: head } + - { pattern: but, group: head } + - { pattern: yet, group: head } + - { pattern: however, group: head } + - { pattern: then, group: head } + - { pattern: yes, group: head } + - { pattern: well, group: head } + - { pattern: please, group: head } + - { pattern: thanks, group: head } + - { pattern: oh, group: head } + - { pattern: also, group: head } + - { pattern: instead, group: head } + - { pattern: otherwise, group: head } + - { pattern: meanwhile, group: head } + - { pattern: as, group: head } + - { pattern: etc, group: head } + - { pattern: e.g, group: head } + - { pattern: i.e, group: head } + - { pattern: and, group: conjunction } + - { pattern: or, group: conjunction } + - { pattern: nor, group: conjunction } + - { pattern: the, group: determiner } + - { pattern: a, group: determiner } + - { pattern: an, group: determiner } + - { pattern: some, group: determiner } + - { pattern: my, group: determiner } + - { pattern: your, group: determiner } + - { pattern: our, group: determiner } + - { pattern: their, group: determiner } + - { pattern: his, group: determiner } + - { pattern: her, group: determiner } + - { pattern: its, group: determiner } + - { pattern: this, group: determiner } + - { pattern: that, group: determiner } + - { pattern: these, group: determiner } + - { pattern: those, group: determiner } + - { pattern: every, group: determiner } + - { pattern: each, group: determiner } + - { pattern: no, group: determiner } + - { pattern: ing, group: suffix } diff --git a/text/packages/lang-en/lexicons/noun-for-verb.yaml b/text/packages/lang-en/lexicons/noun-for-verb.yaml new file mode 100644 index 000000000..4ca2bb23c --- /dev/null +++ b/text/packages/lang-en/lexicons/noun-for-verb.yaml @@ -0,0 +1,9 @@ +# Nouns made from a verb whose plain form is spelled differently, typed where the verb belongs: "to watch and +# photography wildlife" means "photograph". Read by agreement-slip only after "to", a verb and "and", with an object +# following, where the noun cannot stand; rewrite is the verb meant. Nouns that often modify another noun in a +# compound ("management team", "maintenance window") are left out: after "and" they may begin a second noun phrase. +id: noun-for-verb +language: en +entries: + - pattern: photography + rewrite: photograph diff --git a/text/packages/lang-en/lexicons/section-reflection-ending.yaml b/text/packages/lang-en/lexicons/section-reflection-ending.yaml new file mode 100644 index 000000000..d7fe2d769 --- /dev/null +++ b/text/packages/lang-en/lexicons/section-reflection-ending.yaml @@ -0,0 +1,24 @@ +# A sentence of personal reflection closing a section. Groups as section-reflection-ending.ts reads them: open, the +# sentence opens with the words ("I think ..."); end, it ends with them ("..., I think."). +# One is ordinary in an essay or a report; only many sections closing so are counted. +id: section-reflection-ending +language: en +entries: + - pattern: I think + group: open + - pattern: I feel + group: open + - pattern: I believe + group: open + - pattern: I suspect + group: open + - pattern: I'd say + group: open + - pattern: Personally + group: open + - pattern: I think + group: end + - pattern: I feel + group: end + - pattern: I believe + group: end diff --git a/text/packages/lang-ja/lexicons/section-reflection-ending.yaml b/text/packages/lang-ja/lexicons/section-reflection-ending.yaml new file mode 100644 index 000000000..70ffad44a --- /dev/null +++ b/text/packages/lang-ja/lexicons/section-reflection-ending.yaml @@ -0,0 +1,49 @@ +# 節を閉じる所感の文。group は section-reflection-ending.ts の組み方(end:文がこの語で終わる)。 +# 一つずつなら人の随筆や報告にも普通にある結び方で、節のうち多くがこれで閉じるときだけ数える。 +id: section-reflection-ending +language: ja +entries: + - pattern: と思います + group: end + - pattern: と思う + group: end + - pattern: と思いました + group: end + - pattern: と思った + group: end + - pattern: 思っています + group: end + - pattern: 思っている + group: end + - pattern: と感じます + group: end + - pattern: と感じる + group: end + - pattern: と感じています + group: end + - pattern: と感じている + group: end + - pattern: と感じました + group: end + - pattern: と感じた + group: end + - pattern: と考えます + group: end + - pattern: と考える + group: end + - pattern: と考えています + group: end + - pattern: と考えている + group: end + - pattern: 気がします + group: end + - pattern: 気がする + group: end + - pattern: 気がしています + group: end + - pattern: 気がしている + group: end + - pattern: かもしれません + group: end + - pattern: かもしれない + group: end diff --git a/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml b/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml new file mode 100644 index 000000000..892601fd6 --- /dev/null +++ b/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml @@ -0,0 +1,7 @@ +# 名詞の後ろで「は」と組んで主題を立てる複合の助詞(販売については、販売に関しては)。解析器は一語の助詞と読む。 +# topic-predicate-distance は、「〜については」を「〜は」と同じく後ろの節の主題として読む(〜を行っており、これらの販売については、…)。 +id: topic-phrase-particle +language: ja +entries: + - pattern: について + - pattern: に関して diff --git a/text/site/src/content/guide/en/ai-sounding-examples.md b/text/site/src/content/guide/en/ai-sounding-examples.md index 390e99f63..234363a03 100644 --- a/text/site/src/content/guide/en/ai-sounding-examples.md +++ b/text/site/src/content/guide/en/ai-sounding-examples.md @@ -434,7 +434,7 @@ The quick AI-likeness score (`ai-score`) compares the article before and after. $ npx chaffjs ai-score ai.md rewritten.md --genre blog/tech ai.md AI-likeness: high (more signs than human-written documents (Blog)) - 8 signs (of 32 compared, ones 90% of human documents do not show); medium from 3, high from 5 + 8 signs (of 33 compared, ones 90% of human documents do not show); medium from 3, high from 5 Not a verdict on whether AI wrote it: how many signs common in generated text show, compared with human documents. Wording and shape @@ -445,8 +445,8 @@ Wording and shape ✗ Too many contrast frames: 3 in 0 of 23 human-written documents (Blog) ✗ Everything comes in threes: 1 in 0 of 23 human-written documents (Blog) ✗ Several signals of generated text together: 6 of its signals (Phrasing common in generated text, Everything comes in threes, Cliched closing, Too many contrast frames, Too many sentences that announce before they say, Bold emphasis scattered through the text); from 2, its strict level, that is one more sign - · the other 19 did not show - not compared (no human baseline): Stock email courtesies piled up, Too many sweeping claims about people, Questions answered with a fragment + · the other 20 did not show + not compared (no human baseline): Stock email courtesies piled up, Threes strung on commas, Too many sweeping claims about people, Questions answered with a fragment Structure (against human articles) ✗ list items opening with a bold label: 3 higher than 95% of human articles @@ -454,12 +454,12 @@ Structure (against human articles) rewritten.md AI-likeness: low (about as many signs as human-written documents (Blog)) - 1 sign (of 31 compared, ones 90% of human documents do not show); medium from 3, high from 5 + 1 sign (of 32 compared, ones 90% of human documents do not show); medium from 3, high from 5 Not a verdict on whether AI wrote it: how many signs common in generated text show, compared with human documents. Wording and shape - · the other 25 did not show - not compared (no human baseline): Stock email courtesies piled up, Too many sweeping claims about people, Questions answered with a fragment + · the other 26 did not show + not compared (no human baseline): Stock email courtesies piled up, Threes strung on commas, Too many sweeping claims about people, Questions answered with a fragment Structure (against human articles) ✗ sections of one or two paragraphs: 100% (mean 1.3 paragraphs) higher than 90% of human articles diff --git a/text/site/src/content/guide/en/ai-sounding.md b/text/site/src/content/guide/en/ai-sounding.md index c913d3751..87acbda78 100644 --- a/text/site/src/content/guide/en/ai-sounding.md +++ b/text/site/src/content/guide/en/ai-sounding.md @@ -135,6 +135,7 @@ Legal documents, manuals, literature and transcripts are written differently, so | `email-stock-courtesy` | Two or more stock email courtesies in one email ("I hope this email finds you well", "I apologize for any inconvenience") (English documents only) | | `honesty-marker` | A sentence flagged as candid ("Honestly,", "if I'm being honest", "my honest take"); one is reported (blog posts and business documents only) | | `closing-exhortation` | A closing that cheers the reader on or promises the outcome, two or more times ("You've got this", "Happy baking!") | +| `section-reflection-ending` | Half or more of the sections closing on a personal reflection ("I think ...", "I feel ..."), in a document with at least 4 sections that hold a paragraph | | `cold-open` | An opening with no situation or example that piles a bare wish ("You want to ..."), a word of the previous sentence repeated in quotes ("That 'almost' is the problem") and a teaser ("Sounds simple. It isn't.") | | `chat-citation-residue` | Marks a pasted chat answer leaves: links ending in "?utm_source=chatgpt.com", "oaicite" | | `closing-cliche` | A stock closing ("In conclusion", "I hope this helps") | @@ -143,6 +144,7 @@ Legal documents, manuals, literature and transcripts are written differently, so | `no-em-dash` | Too many em dashes | | `sentence-rhythm` | Sentences that are all about the same length | | `rule-of-three` | Lists that almost all have three items | +| `inline-triad` | Three short phrases strung on commas with no "and", again and again ("the table, the conversation, the feeling of being cared for") (English only) | | `section-length-uniformity` | Every section filled to the same size, which is what a template does | | `paragraph-length-variance` | Paragraphs all of about the same length, as if poured into a mould | | `ai-structure` | An outline past 90% of human articles on several structure measures at once (heading density, headings split into three, bold labels, uniform sections, a closing that restates). In business documents, the textbook proposal outline (Summary, Current Situation, Proposed Solution, Expected Benefits, Costs, Risks and Mitigation…) counts as one more, and one more again when nearly every heading is one of its sections | diff --git a/text/site/src/content/guide/en/commands.md b/text/site/src/content/guide/en/commands.md index b196f5012..ceb5572d6 100644 --- a/text/site/src/content/guide/en/commands.md +++ b/text/site/src/content/guide/en/commands.md @@ -492,8 +492,8 @@ Three signs make "medium" and five make "high". It does not say whether AI wrote ``` $ npx chaffjs ai-score before.md after.md --compact -before.md: ai-score high 8/32 ai-tell announcing-opener bold-emphasis closing-cliche contrast-framing rule-of-three structure:bold-labels ai-generated-composite:strict -after.md: ai-score low 1/31 structure:short-sections +before.md: ai-score high 8/33 ai-tell announcing-opener bold-emphasis closing-cliche contrast-framing rule-of-three structure:bold-labels ai-generated-composite:strict +after.md: ai-score low 1/32 structure:short-sections ``` `before.md` and `after.md` are the articles the outline was measured on above. Each file gets one line: the level, the signs out of those compared, and the signs that counted. diff --git a/text/site/src/content/guide/ja/ai-sounding-examples.md b/text/site/src/content/guide/ja/ai-sounding-examples.md index cdb37ff9d..cc112efd2 100644 --- a/text/site/src/content/guide/ja/ai-sounding-examples.md +++ b/text/site/src/content/guide/ja/ai-sounding-examples.md @@ -453,7 +453,7 @@ AI らしさの簡易判定(`ai-score`)で、書き直す前と後を比べ $ npx chaffjs ai-score ai.md rewritten.md --genre blog/tech ai.md AI らしさ: 高(人が書いた文書(ブログ)と比べて目印が多い) - 目印 8 個(比べた 33 項目のうち、人の文書の 9 割には出ないもの)。中は 3 個から、高は 5 個から + 目印 8 個(比べた 34 項目のうち、人の文書の 9 割には出ないもの)。中は 3 個から、高は 5 個から ※ 書いたのが AI かどうかの判定ではありません。生成文に多い目印が、人の文書と比べてどれだけ出ているかです。 言い回しと形 @@ -464,7 +464,7 @@ AI らしさ: 高(人が書いた文書(ブログ)と比べて目印が多 ✗ 「正直」と前置きする: 1 件 人が書いた文書(ブログ)23 本のうち 0 本 ✗ 3 項目の箇条書きばかり: 1 件 人が書いた文書(ブログ)23 本のうち 0 本 ✗ 生成文の特徴がそろっている: 6 種(生成文にありがちな言い回し、「正直」と前置きする、3 項目の箇条書きばかり、定型の結び、対比の枠が多い、予告で始まる文が多い)。厳しめの段階の 2 種から、目印 1 個に数えます - · ほかの 20 項目は出ていません + · ほかの 21 項目は出ていません 構成(人の記事と比べて) ✗ 太字の見出しで始まる項目: 3 項目 人の記事の 95% より多い @@ -472,12 +472,12 @@ AI らしさ: 高(人が書いた文書(ブログ)と比べて目印が多 rewritten.md AI らしさ: 低(人が書いた文書(ブログ)と比べて同じくらい) - 目印 1 個(比べた 32 項目のうち、人の文書の 9 割には出ないもの)。中は 3 個から、高は 5 個から + 目印 1 個(比べた 33 項目のうち、人の文書の 9 割には出ないもの)。中は 3 個から、高は 5 個から ※ 書いたのが AI かどうかの判定ではありません。生成文に多い目印が、人の文書と比べてどれだけ出ているかです。 言い回しと形 ✗ 節の長さが揃いすぎている: 1 件 人が書いた文書(ブログ)23 本のうち 0 本 - · ほかの 25 項目は出ていません + · ほかの 26 項目は出ていません 構成(人の記事と比べて) ✗ 節の長さのばらつき: 32% 人の記事の 95% より揃っている(「節の長さが揃いすぎている」と同じ形なので 1 つに数えます) diff --git a/text/site/src/content/guide/ja/ai-sounding.md b/text/site/src/content/guide/ja/ai-sounding.md index 84870c718..e62270f41 100644 --- a/text/site/src/content/guide/ja/ai-sounding.md +++ b/text/site/src/content/guide/ja/ai-sounding.md @@ -135,6 +135,7 @@ Claude Code の skill(`npx chaffjs skill`)は、指摘より先に指針を | `email-stock-courtesy` | 「I hope this email finds you well」「I apologize for any inconvenience」のような英文メールの決まり文句が、一通のメールに 2 つ以上(英語の文書だけ) | | `honesty-marker` | 「正直、」「正直に言うと」のように本音だと前置きする言い回し。1 つでも言う(ブログと業務文書だけ) | | `closing-exhortation` | 「ぜひ〜してみてください」「きっと〜はずです」のように、結びで読み手を励ます・請け合う文が 2 つ以上 | +| `section-reflection-ending` | 「〜と思います」「〜と感じています」のように、節の半分以上が所感の文で閉じている文書(段落のある節が 4 つ以上) | | `cold-open` | 状況も例もないまま、短い願い(「〜に任せたい。」)、前の文の語の引き直し(この「だいたい」が)、難所の予告(「それだけのことに見えて」)が重なる書き出し | | `chat-citation-residue` | 「?utm_source=chatgpt.com」の付いたリンクや「oaicite」のような、チャットの答えを貼ったときに残る印 | | `closing-cliche` | 「いかがでしたでしょうか」で締める終わり方 | @@ -143,6 +144,7 @@ Claude Code の skill(`npx chaffjs skill`)は、指摘より先に指針を | `no-em-dash` | ダッシュ(——)の多さ | | `sentence-rhythm` | 文の長さが揃いすぎている所 | | `rule-of-three` | 箇条書きがどれも 3 項目の所 | +| `inline-triad` | 「the table, the conversation, the feeling of being cared for」のように、短い句を三つ、and を入れずにカンマだけで並べる形が何度も出る所(英語の文書だけ) | | `section-length-uniformity` | どの節もほぼ同じ長さに埋めてあり、ひな形を埋めたように見える所 | | `paragraph-length-variance` | どの段落もほぼ同じ長さで、型に流しこんだように見える所 | | `ai-structure` | 構成の項目(見出しの多さ、3 つに分けた小見出し、太字の札、節の長さの揃い方、本文を言い直すまとめなど)のいくつもが、人の記事の 9 割を超えた文書。ビジネス文書では、教科書どおりの提案書の見出し(背景、現状と課題、提案内容、期待される効果、費用、リスクと対策…)も 1 項目に数え、見出しのほとんどがその定型ならもう 1 項目に数えます | diff --git a/text/site/src/content/guide/ja/commands.md b/text/site/src/content/guide/ja/commands.md index 0749a0077..69ad1ddeb 100644 --- a/text/site/src/content/guide/ja/commands.md +++ b/text/site/src/content/guide/ja/commands.md @@ -477,8 +477,8 @@ after.md の構成: 見出し 5、節の平均 101 字、箇条書き 0%、太 ``` $ npx chaffjs ai-score before.md after.md --compact -before.md: ai-score high 8/33 ai-tell announcing-opener closing-cliche contrast-framing honesty-marker rule-of-three structure:bold-labels ai-generated-composite:strict -after.md: ai-score low 1/32 section-length-uniformity +before.md: ai-score high 8/34 ai-tell announcing-opener closing-cliche contrast-framing honesty-marker rule-of-three structure:bold-labels ai-generated-composite:strict +after.md: ai-score low 1/33 section-length-uniformity ``` 上の `before.md` と `after.md` は、前の節で構成を測った記事です。1 ファイル 1 行で、段階、目印の数と比べた項目の数、数えた目印を出します。 diff --git a/text/test/fixtures/ai-samples/paired/expected.txt b/text/test/fixtures/ai-samples/paired/expected.txt index 3175cf0a4..6c3f435dc 100644 --- a/text/test/fixtures/ai-samples/paired/expected.txt +++ b/text/test/fixtures/ai-samples/paired/expected.txt @@ -19,6 +19,7 @@ emoji-density 0/3 0/3 0/3 0/ emoji-heading 0/3 0/3 0/3 0/63 figurative-density 0/3 0/3 0/3 0/63 honesty-marker 2/3 0/3 0/3 0/63 +inline-triad 0/3 0/3 0/3 0/63 no-em-dash 0/3 0/3 0/3 0/63 over-general-claim 0/3 0/3 0/3 0/63 padded-intro 1/3 0/3 0/3 0/63 @@ -26,6 +27,7 @@ paragraph-length-variance 0/3 0/3 0/3 0/ q-fragment-answer 0/3 0/3 0/3 0/63 rule-of-three 2/3 0/3 0/3 0/63 section-length-uniformity 1/3 0/3 1/3 0/63 +section-reflection-ending 0/3 0/3 0/3 0/63 sentence-rhythm 0/3 0/3 0/3 0/63 stock-transition 0/3 0/3 0/3 0/63 translationese-density 0/3 0/3 0/3 0/63 @@ -53,6 +55,7 @@ emoji-density 0/3 0/3 0/3 0/ emoji-heading 0/3 0/3 0/3 0/74 figurative-density 0/3 0/3 0/3 0/74 honesty-marker 1/3 0/3 0/3 0/74 +inline-triad 0/3 0/3 0/3 0/74 no-em-dash 0/3 0/3 0/3 2/74 over-general-claim 0/3 0/3 0/3 0/74 padded-intro 0/3 0/3 0/3 0/74 @@ -60,6 +63,7 @@ paragraph-length-variance 0/3 0/3 0/3 0/ q-fragment-answer 0/3 0/3 0/3 0/74 rule-of-three 2/3 0/3 0/3 0/74 section-length-uniformity 1/3 0/3 0/3 0/74 +section-reflection-ending 0/3 0/3 0/3 0/74 sentence-rhythm 0/3 0/3 0/3 0/74 stock-transition 1/3 0/3 0/3 0/74 translationese-density 0/3 0/3 0/3 0/74 diff --git a/text/test/fixtures/bench/plants/inline-triad.yaml b/text/test/fixtures/bench/plants/inline-triad.yaml new file mode 100644 index 000000000..23588502b --- /dev/null +++ b/text/test/fixtures/bench/plants/inline-triad.yaml @@ -0,0 +1 @@ +not_planted: a density over the whole document diff --git a/text/test/fixtures/bench/plants/section-reflection-ending.yaml b/text/test/fixtures/bench/plants/section-reflection-ending.yaml new file mode 100644 index 000000000..c2a8f0178 --- /dev/null +++ b/text/test/fixtures/bench/plants/section-reflection-ending.yaml @@ -0,0 +1 @@ +not_planted: the share of sections that close the same way, across the whole document diff --git a/text/test/fixtures/limits/en.md b/text/test/fixtures/limits/en.md index c0d1405a1..eb40adc8e 100644 --- a/text/test/fixtures/limits/en.md +++ b/text/test/fixtures/limits/en.md @@ -92,7 +92,9 @@ The day goes like this: ## 🚀 Before -Bring the key. +We packed for the trip: maps, ropes, lamps. At camp we were cooking, washing, resting. They came for the view, the quiet, the company. + +Bring the key. I think that is enough. ## ✅ After diff --git a/text/test/fixtures/limits/ja.md b/text/test/fixtures/limits/ja.md index 35197f6a7..643ed2acc 100644 --- a/text/test/fixtures/limits/ja.md +++ b/text/test/fixtures/limits/ja.md @@ -91,7 +91,7 @@ ## ✅ 片付け -鍵を返します。 +鍵を返します。それで足りると思います。 ## 役割 - **司会**:田中さんです。 diff --git a/text/test/test_agreement_slip.ts b/text/test/test_agreement_slip.ts index a5e28fb82..58ad76e12 100644 --- a/text/test/test_agreement_slip.ts +++ b/text/test/test_agreement_slip.ts @@ -392,3 +392,31 @@ describe("agreement-slip — ファイル名とパス", () => { assert.deepEqual(findingsOf("These new version is out."), ["1:1 These new version"]); }); }); + +describe("agreement-slip — 動詞を並べる所の名詞", () => { + before(async () => { + await en.prepare?.({ pos: true }); + }); + + it("invalid: to と動詞と and の後ろの、目的語を取る派生名詞(to watch and photography wildlife)", () => { + assert.deepEqual(findingsOf("Learn how to safely watch and photography birds on the shore."), ["1:11 to safely watch and photography"]); + assert.deepEqual(findingsOf("We went out to find and photography the owls."), ["1:13 to find and photography"]); + }); + + it("valid: 目的語の無い名詞、動詞の photograph、名詞を並べた文", () => { + const valid = [ + "We love to hike and photography.", + "Learn how to watch and photograph birds.", + "She wanted to travel, and photography gave her a reason.", + "Tips on how to hike and photography for beginners.", + ]; + valid.forEach((text) => assert.deepEqual(findingsOf(text), [], text)); + }); + + it("names the verb meant in the message", () => { + const document = buildDocument("t.md", "Come to watch and photography the herd.", en); + const finding = runRules(document, RULES.en, {}, true, "business/report").findings.find((item) => item.rule === "agreement-slip"); + assert.equal(finding?.values["verb"], "photograph"); + assert.equal(finding?.variant, "conjunct"); + }); +}); diff --git a/text/test/test_desumasu_profile.ts b/text/test/test_desumasu_profile.ts new file mode 100644 index 000000000..e89b29099 --- /dev/null +++ b/text/test/test_desumasu_profile.ts @@ -0,0 +1,32 @@ +import { before, describe, it } from "node:test"; +import assert from "node:assert/strict"; +import { namedRuleRun } from "./rule-run.ts"; +import { adapter as ja } from "../packages/lang-ja/src/index.ts"; + +// 敬称の付いた人の名前を見出しにし、職業だけの文で始まる節(### 山田花子さん / 写真家。…)は寄稿者の紹介で、 +// 紹介は常体で書くのが慣例なので、文末の調子をページと比べない。例文はすべて自作。 + +const findingsOf = (source: string): readonly string[] => namedRuleRun("no-mixed-desumasu", source, ja, "a.md", "blog/owned-media").findings; + +const page = ["## 今月の特集", "", "梅雨の季節になりました。雨の日の備えを確かめましょう。窓口では相談も受け付けています。お気軽にお越しください。", ""].join( + "\n", +); + +const profile = (heading: string, opening: string): string => + [`### ${heading}`, "", `${opening}街の風景を撮り続け、国内外の写真展で高い評価を得ている。雑誌の表紙も手がける。`, ""].join("\n"); + +describe("no-mixed-desumasu: 寄稿者の紹介の節", () => { + before(async () => { + await ja.prepare?.({ pos: true }); + }); + + it("敬称の付いた名前の見出しの下で、職業だけの文で始まる紹介は比べない", () => { + assert.deepEqual(findingsOf(`${profile("山田花子(やまだ はなこ)さん", "写真家。")}\n${page}`), []); + assert.deepEqual(findingsOf(`${profile("山田花子氏", "写真家。")}\n${page}`), []); + }); + + it("敬称の無い見出しや、職業で始まらない節の同じ文は、これまでどおり指す", () => { + assert.equal(findingsOf(`${profile("今月の写真", "写真家。")}\n${page}`).length, 2); + assert.equal(findingsOf(`${profile("山田花子さん", "")}\n${page}`).length, 2); + }); +}); diff --git a/text/test/test_inline_triad.ts b/text/test/test_inline_triad.ts new file mode 100644 index 000000000..53fee967e --- /dev/null +++ b/text/test/test_inline_triad.ts @@ -0,0 +1,105 @@ +import { describe, it } from "node:test"; +import assert from "node:assert/strict"; +import { namedRuleRun } from "./rule-run.ts"; +import { buildDocument } from "../packages/chaff/src/document.ts"; +import { inlineTriads, triadWordsOf } from "../packages/chaff/src/detectors/inline-triad.ts"; +import { adapter as en } from "../packages/lang-en/src/index.ts"; + +// inline-triad: three short phrases strung on commas with no and / or, counted per 1000 words. Every sentence here is self-written. + +const RULE = "inline-triad"; +const WORDS = triadWordsOf(buildDocument("w.md", "# W\n\nA line.\n", en).lexicons[RULE] ?? []); + +const matched = (sentence: string): string[] => inlineTriads(sentence, WORDS).map((triad) => triad.matched); + +/** Plain sentences with no run of three, so a document reaches the length the rule measures. */ +const FILLER = Array.from({ length: 30 }, (_, at) => `Line ${String(at + 1)} says one plain thing about the weekly plan.`).join(" "); + +const findingsOf = (body: string): readonly string[] => namedRuleRun(RULE, `# Notes\n\n${body}\n\n${FILLER}\n`, en, "a.md", "blog/essay").findings; + +const TRIADS = [ + "I started with simple things: scrambled eggs, roasted vegetables, a basic tomato soup.", + "Most dishes start the same way: an onion, some garlic, a little oil.", + "In the evenings I was chopping, stirring, paying attention.", + "People come for the table, the conversation, the feeling of being cared for.", +].join(" "); + +describe("inlineTriads", () => { + it("finds three parallel phrases strung on commas", () => { + assert.deepEqual(matched("They come for the table, the conversation, the feeling of being cared for."), [ + "They come for the table, the conversation, the feeling of being cared for", + ]); + assert.deepEqual(matched("I was chopping, stirring, paying attention."), ["I was chopping, stirring, paying attention"]); + }); + + it("finds three short items opened by a colon, parallel or not", () => { + assert.deepEqual(matched("I started with simple things: scrambled eggs, roasted vegetables, a basic tomato soup."), [ + "scrambled eggs, roasted vegetables, a basic tomato soup", + ]); + }); + + it("gives the position of the run in the sentence", () => { + const sentence = "We packed: maps, ropes, lamps."; + const [triad] = inlineTriads(sentence, WORDS); + assert.ok(triad !== undefined); + assert.equal(sentence.slice(triad.start, triad.end), "maps, ropes, lamps."); + }); + + it("leaves a list joined with and / or", () => { + assert.deepEqual(matched("It was fast, simple, and reliable."), []); + assert.deepEqual(matched("Bring the map, the rope or the lamp."), []); + }); + + it("leaves a run of four or more", () => { + assert.deepEqual(matched("We packed: maps, ropes, lamps, tents."), []); + assert.deepEqual(matched("She bought the bread, the milk, the eggs, the tea."), []); + }); + + it("leaves commas that break a sentence rather than list items", () => { + assert.deepEqual(matched("Well, honestly, it works."), []); + assert.deepEqual(matched("However, in practice, the plan held."), []); + assert.deepEqual(matched("The plan, which we wrote, held up."), []); + }); + + it("leaves names, titles, places and figures", () => { + assert.deepEqual(matched("Signed by Jane Roe, Director, Digital Service."), []); + assert.deepEqual(matched("The office is in Leeds, West Yorkshire, England."), []); + assert.deepEqual(matched("It opened on Monday, 3 March, 2025."), []); + }); + + it("leaves one word said again", () => { + assert.deepEqual(matched("This is an old, old, old fight."), []); + }); + + it("leaves two phrases in different forms without a colon", () => { + assert.deepEqual(matched("After lunch, the team, quite tired, went home."), []); + }); + + it("reads nothing from an empty sentence or one with no comma", () => { + assert.deepEqual(matched(""), []); + assert.deepEqual(matched("No commas here."), []); + assert.deepEqual(matched(", , ,"), []); + }); +}); + +describe("inline-triad", () => { + it("reports every run once a long document holds enough of them", () => { + const findings = findingsOf(TRIADS); + assert.equal(findings.length, 4); + assert.match(findings[0] ?? "", /scrambled eggs, roasted vegetables, a basic tomato soup" and other threes strung on commas: \d+ per 1000 words/u); + }); + + it("does not report fewer than three runs", () => { + assert.deepEqual(findingsOf("In the evenings I was chopping, stirring, paying attention. People come for the table, the conversation, the company."), []); + }); + + it("does not report a run inside a list item or inside quotation marks", () => { + const listed = ["- maps, ropes, lamps", "- the bread, the milk, the eggs", "- chopping, stirring, tasting"].join("\n"); + assert.deepEqual(findingsOf(`${listed}\n\nShe said "the bread, the milk, the eggs" twice.`), []); + }); + + it("does not report a short document", () => { + const short = namedRuleRun(RULE, `# Notes\n\n${TRIADS}\n`, en, "a.md", "blog/essay").findings; + assert.deepEqual(short, []); + }); +}); diff --git a/text/test/test_ja_clause_shape.ts b/text/test/test_ja_clause_shape.ts index 79c207eb9..2edb555f7 100644 --- a/text/test/test_ja_clause_shape.ts +++ b/text/test/test_ja_clause_shape.ts @@ -104,6 +104,12 @@ describe("repeated-sentence-ending", () => { "「〜であります」で終わる文が 3 文続いています(2 文まで)", ]); }); + + it("見出しの行が単位の括弧で閉じる表を平らにした段落は、行のセルの文を続きと見ない(自作)", () => { + const table = + "【関係会社の状況】名称住所資本金(千円)議決権の所有割合(%)役員の兼任等(名)関係内容北海運送株式会社札幌市10,000物流事業90.001当社の荷物の運送を行っております。当社より倉庫の賃貸を受けております。南海不動産株式会社福岡市30,000不動産事業100.002当社の建物の管理を行っております。(注) 主要な事業の内容欄には、セグメントの名称を記載しております。\n"; + assert.deepEqual(findingsOf(RULE, table), []); + }); }); describe("endingRuns", () => { diff --git a/text/test/test_latin_spacing_source.ts b/text/test/test_latin_spacing_source.ts index 889ef2b78..b998dae1f 100644 --- a/text/test/test_latin_spacing_source.ts +++ b/text/test/test_latin_spacing_source.ts @@ -80,6 +80,17 @@ describe("文献の記載の行", () => { assert.deepEqual(spacing(withBody("図書館の夢を見るか LRG編を読みました。")), ["英字:空けています"]); }); + it("URL と参照日の括弧書き((2024/3/12参照))を書いた行も、出典の記載と読む", () => { + const labels = ["参照", "閲覧"]; + const footnote = "12 架空県 DX推進会議「地域の計画」,(2024/3/12参照)"; + assert.equal(isCitedEntryLine(footnote, labels), true); + assert.equal(isCitedEntryLine("架空県 DX推進会議の資料は https://example.com/plan.pdf にあります(閲覧日 2024年3月12日)", labels), true); + assert.equal(isCitedEntryLine("架空県 DX推進会議の資料は https://example.com/plan.pdf にあります。", labels), false); + assert.equal(isCitedEntryLine("架空県 DX推進会議の資料を参照してください(2024/3/12参照)", labels), false); + assert.equal(isCitedEntryLine(footnote), false); + assert.deepEqual(spacing(withBody(footnote)), []); + }); + it("lineAt は位置を含む行", () => { assert.equal(lineAt("一\n二三\n四", 3), "二三"); assert.equal(lineAt("一\n二三\n四", 0), "一"); diff --git a/text/test/test_oxford_not_a_list.ts b/text/test/test_oxford_not_a_list.ts index 03697b8fe..ed41b1cd0 100644 --- a/text/test/test_oxford_not_a_list.ts +++ b/text/test/test_oxford_not_a_list.ts @@ -139,6 +139,14 @@ describe("oxford-comma-consistency: what is not a list", () => { assert.equal(reportedWith("I.e., the posters and the cards stay in stock."), false); assert.equal(reportedWith("E.g., posters, cards and calendars sell well."), true); }); + + it("reads the item after and then by the word past then, so an aside opened by an adverb is no item", () => { + assert.equal(reportedWithout("Take a bus to the station, easily spotted from afar, and then ride the lift."), false); + assert.equal(reportedWith("Take a bus to the station, easily spotted from afar, and then ride the lift."), false); + assert.equal(reportedWithout("We visited Paris, Rome, and then Berlin."), true); + assert.equal(reportedWith("We visited Paris, Rome and finally Berlin."), true); + assert.equal(reportedWithout("Items are sorted primarily by stage, secondarily by size, and finally by date."), true); + }); }); describe("excerptSpans", () => { diff --git a/text/test/test_rule_rewrite.ts b/text/test/test_rule_rewrite.ts index 6aa830b7e..d83488e0c 100644 --- a/text/test/test_rule_rewrite.ts +++ b/text/test/test_rule_rewrite.ts @@ -51,8 +51,8 @@ const LISTS_ITS_CONTEXT: ReadonlySet = new Set([ "contrast-framing", ]); -/** Word lists a rule reads around a finding (便利な's な) or passes over (the very first), not phrases it flags. */ -const UNFLAGGED_LISTS: ReadonlySet = new Set(["very-copula", "very-exception", "negation-word"]); +/** Word lists a rule reads around a finding (便利な's な, the words that pair two items in a run of three) or passes over (the very first), not phrases it flags. */ +const UNFLAGGED_LISTS: ReadonlySet = new Set(["very-copula", "very-exception", "negation-word", "inline-triad"]); const MIN_PAIRS = 2; const MAX_PAIRS = 3; diff --git a/text/test/test_section_reflection_ending.ts b/text/test/test_section_reflection_ending.ts new file mode 100644 index 000000000..78b11f5fe --- /dev/null +++ b/text/test/test_section_reflection_ending.ts @@ -0,0 +1,130 @@ +import { describe, it, before } from "node:test"; +import assert from "node:assert/strict"; +import { buildDocument } from "../packages/chaff/src/document.ts"; +import { loadRules } from "../packages/chaff/src/rule-load.ts"; +import { runRules } from "../packages/chaff/src/run.ts"; +import { reflectionIn, sectionClosers } from "../packages/chaff/src/detectors/section-reflection-ending.ts"; +import { tokenizedLexicons } from "../packages/chaff/src/lexicon-tokens.ts"; +import { adapter as en } from "../packages/lang-en/src/index.ts"; +import { adapter as ja } from "../packages/lang-ja/src/index.ts"; +import type { LanguageAdapter, Level } from "../packages/chaff/src/plugin.ts"; + +// section-reflection-ending: nearly every section closes on a personal reflection (と思います, I think). One is +// ordinary; most sections closing so is the shape. Self-written samples. + +const RULE = "section-reflection-ending"; + +before(async () => { + await en.prepare?.({ pos: true }); + await ja.prepare?.({ pos: true }); +}); + +const findings = (source: string, adapter: LanguageAdapter, level?: Level, genre = "blog/essay") => + runRules(buildDocument("t.md", source, adapter), loadRules(adapter.id), level === undefined ? {} : { [RULE]: level }, true, genre).findings.filter( + (finding) => finding.rule === RULE, + ); + +const sentenceOf = (adapter: LanguageAdapter, text: string) => { + const sentence = buildDocument("t.md", text, adapter).sentences[0]; + assert.ok(sentence !== undefined); + return sentence; +}; + +const lexiconOf = (adapter: LanguageAdapter) => tokenizedLexicons(adapter.lexicons, adapter)[RULE] ?? []; + +const sections = (closings: readonly string[]): string => + ["# 題", "", ...closings.flatMap((closing, index) => [`## 節${String(index + 1)}`, "", `駅まで十分ほど歩きます。${closing}`, ""])].join("\n"); + +const sectionsEn = (closings: readonly string[]): string => + ["# Title", "", ...closings.flatMap((closing, index) => [`## Part ${String(index + 1)}`, "", `The walk takes ten minutes. ${closing}`, ""])].join("\n"); + +describe("reflectionIn", () => { + const reflective: ReadonlyArray = [ + [ja, "続けてよかったと思います。"], + [ja, "その場で課題を伺えたことが大きかったと感じています。"], + [ja, "準備しておくべきだと考えています。"], + [ja, "それでも、始めてよかったと心から思っている。"], + [ja, "いちばん頭がすっきりしている時間かもしれない。"], + [en, "I think the fresh air is the best part."], + [en, "That was the right call, I think."], + [en, "Personally, I would start earlier."], + ]; + reflective.forEach(([adapter, text]) => { + it(`finds 「${text}」`, () => assert.notEqual(reflectionIn(sentenceOf(adapter, text), lexiconOf(adapter)), undefined)); + }); + + const plain: ReadonlyArray = [ + [ja, "名刺交換は287件でした。"], + [ja, "思うところを三つ書きます。"], + [ja, "と思いますか、と聞かれました。"], + [ja, ""], + [en, "We thinks it through."], + [en, "They think it works."], + [en, "The team felt it was late."], + ]; + plain.forEach(([adapter, text]) => { + it(`does not find 「${text}」`, () => { + const sentence = buildDocument("t.md", text, adapter).sentences[0]; + assert.equal(sentence === undefined ? undefined : reflectionIn(sentence, lexiconOf(adapter)), undefined); + }); + }); + + it("finds nothing with an empty lexicon", () => assert.equal(reflectionIn(sentenceOf(ja, "よかったと思います。"), []), undefined)); +}); + +describe("sectionClosers", () => { + it("takes the last sentence of each section's last paragraph", () => { + const doc = buildDocument("t.md", "## 一\n\n最初です。\n\n次です。終わりです。\n\n## 二\n\n二つ目です。\n", ja); + assert.deepEqual( + sectionClosers(doc).map((sentence) => sentence.text.trim()), + ["終わりです。", "二つ目です。"], + ); + }); + + it("skips a section with no paragraph", () => { + const doc = buildDocument("t.md", "# 題\n\n## 一\n\n- 項目\n- 項目\n\n## 二\n\n本文です。\n", ja); + assert.deepEqual( + sectionClosers(doc).map((sentence) => sentence.text.trim()), + ["本文です。"], + ); + }); + + it("gives nothing for an empty document", () => assert.deepEqual(sectionClosers(buildDocument("t.md", "", ja)), [])); +}); + +describe(RULE, () => { + it("reports every reflective closing when most sections close on one", () => { + const found = findings(sections(["よかったと思います。", "いい運動になっていると感じています。", "こつかもしれません。", "名刺交換は287件でした。"]), ja); + assert.equal(found.length, 3); + assert.equal(found[0]?.values?.["share"], 75); + }); + + it("reports an English document whose sections open their closing with I think", () => { + const found = findings(sectionsEn(["I think it is the best part.", "I feel it helps.", "I believe it lasts.", "It rained twice."]), en); + assert.equal(found.length, 3); + }); + + it("does not report one reflective closing among several sections", () => { + assert.deepEqual(findings(sections(["よかったと思います。", "八千円浮きました。", "六日が雨でした。", "十分かかります。"]), ja), []); + }); + + it("does not report a share below the limit", () => { + const closings = ["よかったと思います。", "八千円浮きました。", "六日が雨でした。", "十分かかります。", "楽しいと感じています。"]; + assert.deepEqual(findings(sections(closings), ja), []); + assert.equal(findings(sections(closings), ja, "strict").length, 2); + }); + + it("does not measure a document with fewer sections than min_sections", () => { + assert.deepEqual(findings(sections(["よかったと思います。", "楽しいと感じています。", "こつかもしれません。"]), ja), []); + }); + + it("does not count a reflection in the middle of a closing paragraph", () => { + const middle = ["よかったと思います。名刺は十枚でした。", "楽しいと感じています。雨は六日でした。", "こつかもしれません。八千円です。", "十分かかります。"]; + assert.deepEqual(findings(sections(middle), ja), []); + }); + + it("runs at the genre's own level when no level is set", () => { + const closings = ["よかったと思います。", "楽しいと感じています。", "こつかもしれません。", "大きいと思います。"]; + assert.equal(findings(sections(closings), ja, undefined, "blog/essay").length, 4); + }); +}); diff --git a/text/test/test_topic_predicate_distance.ts b/text/test/test_topic_predicate_distance.ts index 3ec674469..966502778 100644 --- a/text/test/test_topic_predicate_distance.ts +++ b/text/test/test_topic_predicate_distance.ts @@ -153,6 +153,18 @@ describe("topic-predicate-distance: 述語のすぐ後ろで閉じる節(topic }); describe("topic-predicate-distance: 後ろの節の主語", () => { + it("「〜ており、」の後ろの「〜については」「〜に関しては」も後ろの節の主題として読む(自作)", () => { + const about = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品の販売については、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.deepEqual(distances(about), []); + const regarding = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品の販売に関しては、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.deepEqual(distances(regarding), []); + const same = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品を販売する際には、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.equal(distances(same).length, 1); + }); + it("「〜の大半は」「〜のほとんどは」も後ろの節の主語として読む(自作)", () => { const narrowed = "この装置は古い型であるため、これらの部品のほとんどはもう製造元では作られておらず、修理のたびに中古の市場で探すか、同じ働きをする別の部品を取り寄せて、一つずつ合うかどうかを確かめながら長く使い続けています。";