chaffjs 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composite-signals.d.ts +6 -0
- package/dist/composite-signals.d.ts.map +1 -0
- package/dist/composite-signals.js +23 -0
- package/dist/composite-signals.js.map +1 -0
- package/dist/detectors/acronym-context.d.ts +4 -0
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +45 -0
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-series.d.ts +5 -0
- package/dist/detectors/acronym-series.d.ts.map +1 -1
- package/dist/detectors/acronym-series.js +18 -3
- package/dist/detectors/acronym-series.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +7 -1
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/ai-structure.d.ts.map +1 -1
- package/dist/detectors/ai-structure.js +6 -2
- package/dist/detectors/ai-structure.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts.map +1 -1
- package/dist/detectors/contraction-mix.js +8 -1
- package/dist/detectors/contraction-mix.js.map +1 -1
- package/dist/detectors/contraction-set-apart.d.ts +14 -0
- package/dist/detectors/contraction-set-apart.d.ts.map +1 -0
- package/dist/detectors/contraction-set-apart.js +42 -0
- package/dist/detectors/contraction-set-apart.js.map +1 -0
- package/dist/detectors/densest-stretch.d.ts +11 -0
- package/dist/detectors/densest-stretch.d.ts.map +1 -0
- package/dist/detectors/densest-stretch.js +14 -0
- package/dist/detectors/densest-stretch.js.map +1 -0
- package/dist/detectors/doubled-word.d.ts.map +1 -1
- package/dist/detectors/doubled-word.js +8 -4
- package/dist/detectors/doubled-word.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts +3 -0
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +11 -2
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/gram-furniture.d.ts +8 -5
- package/dist/detectors/gram-furniture.d.ts.map +1 -1
- package/dist/detectors/gram-furniture.js +23 -13
- package/dist/detectors/gram-furniture.js.map +1 -1
- package/dist/detectors/gram-openers.d.ts +11 -0
- package/dist/detectors/gram-openers.d.ts.map +1 -1
- package/dist/detectors/gram-openers.js +42 -1
- package/dist/detectors/gram-openers.js.map +1 -1
- package/dist/detectors/gram-repetition.d.ts.map +1 -1
- package/dist/detectors/gram-repetition.js +18 -7
- package/dist/detectors/gram-repetition.js.map +1 -1
- package/dist/detectors/known-correction.d.ts.map +1 -1
- package/dist/detectors/known-correction.js +11 -9
- package/dist/detectors/known-correction.js.map +1 -1
- package/dist/detectors/lexicon.d.ts +2 -2
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +15 -5
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +18 -8
- package/dist/detectors/list-lead-in.js.map +1 -1
- package/dist/detectors/list-run.d.ts.map +1 -1
- package/dist/detectors/list-run.js +16 -2
- package/dist/detectors/list-run.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +17 -2
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +3 -2
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/quoted-pattern.d.ts +2 -0
- package/dist/detectors/quoted-pattern.d.ts.map +1 -0
- package/dist/detectors/quoted-pattern.js +13 -0
- package/dist/detectors/quoted-pattern.js.map +1 -0
- package/dist/detectors/reference-entry.d.ts +5 -0
- package/dist/detectors/reference-entry.d.ts.map +1 -1
- package/dist/detectors/reference-entry.js +6 -1
- package/dist/detectors/reference-entry.js.map +1 -1
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
- package/dist/detectors/relative-pronoun-mix.js +7 -3
- package/dist/detectors/relative-pronoun-mix.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +5 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -1
- package/dist/detectors/sentence-parts.js +8 -0
- package/dist/detectors/sentence-parts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +25 -3
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/superlative-context.d.ts +2 -1
- package/dist/detectors/superlative-context.d.ts.map +1 -1
- package/dist/detectors/superlative-context.js +9 -2
- package/dist/detectors/superlative-context.js.map +1 -1
- package/dist/detectors/title-list.d.ts +7 -0
- package/dist/detectors/title-list.d.ts.map +1 -0
- package/dist/detectors/title-list.js +14 -0
- package/dist/detectors/title-list.js.map +1 -0
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +5 -1
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +2 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -1
- package/dist/detectors/unknown-word-context.js +4 -0
- package/dist/detectors/unknown-word-context.js.map +1 -1
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +10 -3
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -2
- package/dist/run.js.map +1 -1
- package/dist/structure-shape/faq-sections.d.ts +7 -0
- package/dist/structure-shape/faq-sections.d.ts.map +1 -0
- package/dist/structure-shape/faq-sections.js +14 -0
- package/dist/structure-shape/faq-sections.js.map +1 -0
- package/dist/structure-shape/features.d.ts.map +1 -1
- package/dist/structure-shape/features.js +5 -3
- package/dist/structure-shape/features.js.map +1 -1
- package/package.json +3 -3
- package/rules/ai-generated-composite.yaml +2 -2
- package/rules/ai-structure.yaml +2 -2
- package/rules/ai-tell.yaml +2 -2
- package/rules/colon-lead-in.yaml +2 -2
- package/rules/contraction-consistency.yaml +4 -2
- package/rules/contrast-framing.yaml +3 -3
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +2 -2
- package/rules/undefined-acronym.yaml +4 -2
- package/rules/unknown-word.yaml +2 -2
- package/rules/unqualified-superlative.yaml +1 -1
- package/src/composite-signals.ts +27 -0
- package/src/detectors/acronym-context.ts +58 -0
- package/src/detectors/acronym-series.ts +22 -3
- package/src/detectors/ai-phrasing.ts +7 -1
- package/src/detectors/ai-structure.ts +6 -2
- package/src/detectors/contraction-mix.ts +11 -1
- package/src/detectors/contraction-set-apart.ts +52 -0
- package/src/detectors/densest-stretch.ts +21 -0
- package/src/detectors/doubled-word.ts +10 -10
- package/src/detectors/fullwidth-alnum.ts +19 -3
- package/src/detectors/gram-furniture.ts +27 -13
- package/src/detectors/gram-openers.ts +54 -1
- package/src/detectors/gram-repetition.ts +21 -7
- package/src/detectors/known-correction.ts +15 -8
- package/src/detectors/lexicon.ts +17 -5
- package/src/detectors/list-lead-in.ts +23 -8
- package/src/detectors/list-run.ts +16 -2
- package/src/detectors/oxford-comma.ts +17 -2
- package/src/detectors/phrase-match.ts +3 -2
- package/src/detectors/quoted-pattern.ts +14 -0
- package/src/detectors/reference-entry.ts +8 -1
- package/src/detectors/relative-pronoun-mix.ts +5 -3
- package/src/detectors/sentence-parts.ts +15 -0
- package/src/detectors/signals.ts +28 -3
- package/src/detectors/superlative-context.ts +10 -2
- package/src/detectors/title-list.ts +21 -0
- package/src/detectors/token-shape.ts +20 -16
- package/src/detectors/unknown-word-context.ts +6 -0
- package/src/detectors/unknown-word.ts +10 -2
- package/src/plugin.ts +2 -0
- package/src/run.ts +4 -2
- package/src/structure-shape/faq-sections.ts +24 -0
- package/src/structure-shape/features.ts +5 -3
|
@@ -35,7 +35,9 @@ extra_word_lists:
|
|
|
35
35
|
case-party-joiner,
|
|
36
36
|
citation-author-joiner,
|
|
37
37
|
text-message-verb,
|
|
38
|
+
opening-conjunction,
|
|
38
39
|
product-name,
|
|
40
|
+
phone-label,
|
|
39
41
|
]
|
|
40
42
|
uses: [pos]
|
|
41
43
|
severity: info
|
|
@@ -88,8 +90,8 @@ example:
|
|
|
88
90
|
after: Our key goal indicator (KGI) this term is to reach product-market fit (PMF).
|
|
89
91
|
|
|
90
92
|
not_flagged:
|
|
91
|
-
ja: 誰でも知っている略語(URL、PDF など)と、前後の括弧で説明した略語、会社の名前の中の英字(㈱ADEKA、CO.,LTD.)は指しません。ひな形の名前の置き場所(OOOO、XX 月)と、外のページへのリンクを並べた一覧の題名の中の略語も指しません(題名の略語は数には入れます)。大文字の違うだけの書き方で説明した略語(TCoP と TCOP)、略語を話題にする文で語に書き出した略語(略語の DOB … date of birth)、一覧で語のすぐ下にその語を名指すリンクを入れ子にした語(- GPL の下の GNU General Public License)も指しません。判例の引用の中の当事者と裁判所の名前(Ashwander v. TVA, 297 U.S. 288、MCI Telecomms. Corp. v. AT&T、(SDNY 1952))、引用の中の行政機関の事件番号(NOV/CFA 01-01)も指しません(引用の略語は数には入れます)。判決の頭の MR. JUSTICE も指しません。括弧の中で略語に「or」で別の呼び名を添えたもの(Department of Health and Human Services (HHS or the Department))、ハイフンで繋いだ字まで名前と揃うもの(Agency for Health (ARPA-H))は説明したと読み、メールアドレスの中の英字(OASH-RFI@hhs.gov)は略語と読みません。文書の中に書いた ABNF の文法の規則の名前と値(CRLF、%x0D)、等級の並び(A と AA)、番号で引く官報や判例集(80 FR 66128、2022 WL 4447293)、日付の付いた識別子の前の種類(WD WD-ABC1-20200101)、PO Box の PO も指しません。文献を引いて始まる注(1. See L. Summers (2015), "…," IMF Economic Review)の中の略語は、引いた文献の題名や誌名の書き方なので指しません(数には入れます)。角括弧の見出しで始まる文献の項目([FETCH] WHATWG, …)の中の略語も同じです。2 つ以上の番号で引く続き物の名前(BCP 78 と BCP 14、DR 4339 と DR 4340)、同じ文の前のほうで名前を書き出した略語(U.S. Small Business Administration … SBA)、肩書きの後ろの判事の姓(Lord HOLT、Mr. Justice BULLER)、商標の印の付いた名前(Acrobat DC®)、条で引く法令集(44 USC. 3502、15 USCA § 709)と、編と区分で引く法令集(21 CFR subpart J)も指しません。ショートメッセージで送るキーワード(texting GNPCGS to 333111)、名前のまま書いた製品の版(Adobe Acrobat Reader DC)、頭だけ大文字の語に繋いだ名前の中の大文字(NITE SAFE-Lite)も指しません。同じ文の前のほうで、同じ名詞の前に小文字で書き出した略語(incident response plan … IR plans)と、括弧の中で小文字の語を添えた略語の名前の頭の頭文字が揃うもの(… Partnerships to Stimulate Cybersecurity Education (RAMPS program))は説明したと読みます。貼り付けたチャットの発言(<jinxer-wm> FIRING …)の中の略語は、発言した人やボットの言葉なので指しません(数には入れます)。番地から州と郵便番号まで揃った所在地の中の大文字(1600 Elm Rd. NE, MS K12-3, Springfield, GA 30329 の NE と MS)、SQL のキーワード(VIEW、WHERE)、文の中で頭だけ大文字の語にも書いた名前を大文字で書いたもの(a hotel / Airbnb と書いた文書の AIRBNB)も指しません。
|
|
92
|
-
en: Common acronyms (URL, PDF), acronyms spelled out in brackets next to them, and the letters of a company name (㈱ADEKA, CO.,LTD.) are not reported. Neither are a template's placeholders (OOOO, XX 月) or an acronym in the title of a page in a list of links (it still counts towards the limit). Nor are an acronym explained under another capitalisation (TCoP, then TCOP), one a sentence about the abbreviation writes out (the abbreviation DOB … date of birth), or a term in a list whose nested link names it (- GPL above GNU General Public License). Nor are the parties and courts of a case citation (Ashwander v. TVA, 297 U.S. 288; MCI Telecomms. Corp. v. AT&T; (SDNY 1952)), an agency's docket number in a citation (NOV/CFA 01-01); a citation's acronyms still count towards the limit. Nor is the MR. JUSTICE that opens a line of an opinion. An acronym given another name after "or" in its parenthesis (Department of Health and Human Services (HHS or the Department)) or spelled out with its hyphened letter (Agency for Health (ARPA-H)) counts as expanded, and the letters of an email address (OASH-RFI@hhs.gov) are not an acronym. Nor are the rule names and values of an ABNF grammar in the text (CRLF, %x0D), the rungs of a grade ladder (A and AA), a register or reporter cited by number (80 FR 66128, 2022 WL 4447293), the kind written before a dated identifier (WD WD-ABC1-20200101), or the PO of a PO Box. A note that opens with a citation (1. See L. Summers (2015), "…," IMF Economic Review) is written in the cited work's words, and its acronyms are not reported (they still count towards the limit); so is an entry of a reference list keyed by a bracketed label ([FETCH] WHATWG, …). Nor are capitals the document cites by two or more numbers (BCP 78 and BCP 14, DR 4339 and DR 4340), an acronym whose name the same sentence writes out before it (U.S. Small Business Administration … SBA), a judge's surname after his title (Lord HOLT, Mr. Justice BULLER), a name marked as a trademark (Acrobat DC®), a code cited by section (44 USC. 3502, 15 USCA § 709), or a code cited by title and division (21 CFR subpart J). Nor are a keyword to send by text message (texting GNPCGS to 333111), a product's edition written with the product's name (Adobe Acrobat Reader DC), or capitals joined to a capitalised word in a name (NITE SAFE-Lite). An acronym the same sentence writes out in lower case before the same noun (incident response plan … IR plans), and one bracketed with a word in lower case after a name whose head gives its letters (… Partnerships to Stimulate Cybersecurity Education (RAMPS program)), count as expanded. An acronym in a pasted chat line (<jinxer-wm> FIRING …) is the speaker's or the bot's words, and is not reported (it still counts towards the limit). Nor are the capitals inside a postal address that runs from a street number to a state and ZIP code (the NE and MS of 1600 Elm Rd. NE, MS K12-3, Springfield, GA 30329), a keyword of SQL (VIEW, WHERE), or a name in capitals that the document also writes inside a sentence with only its first letter a capital (AIRBNB in a text that writes a hotel / Airbnb).
|
|
93
|
+
ja: 誰でも知っている略語(URL、PDF など)と、前後の括弧で説明した略語、会社の名前の中の英字(㈱ADEKA、CO.,LTD.)は指しません。ひな形の名前の置き場所(OOOO、XX 月)と、外のページへのリンクを並べた一覧の題名の中の略語も指しません(題名の略語は数には入れます)。大文字の違うだけの書き方で説明した略語(TCoP と TCOP)、略語を話題にする文で語に書き出した略語(略語の DOB … date of birth)、一覧で語のすぐ下にその語を名指すリンクを入れ子にした語(- GPL の下の GNU General Public License)も指しません。判例の引用の中の当事者と裁判所の名前(Ashwander v. TVA, 297 U.S. 288、MCI Telecomms. Corp. v. AT&T、(SDNY 1952))、引用の中の行政機関の事件番号(NOV/CFA 01-01)も指しません(引用の略語は数には入れます)。判決の頭の MR. JUSTICE も指しません。括弧の中で略語に「or」で別の呼び名を添えたもの(Department of Health and Human Services (HHS or the Department))、ハイフンで繋いだ字まで名前と揃うもの(Agency for Health (ARPA-H))は説明したと読み、メールアドレスの中の英字(OASH-RFI@hhs.gov)は略語と読みません。文書の中に書いた ABNF の文法の規則の名前と値(CRLF、%x0D)、等級の並び(A と AA)、番号で引く官報や判例集(80 FR 66128、2022 WL 4447293)、日付の付いた識別子の前の種類(WD WD-ABC1-20200101)、PO Box の PO も指しません。文献を引いて始まる注(1. See L. Summers (2015), "…," IMF Economic Review)の中の略語は、引いた文献の題名や誌名の書き方なので指しません(数には入れます)。角括弧の見出しで始まる文献の項目([FETCH] WHATWG, …)の中の略語も同じです。2 つ以上の番号で引く続き物の名前(BCP 78 と BCP 14、DR 4339 と DR 4340)、同じ文の前のほうで名前を書き出した略語(U.S. Small Business Administration … SBA)、肩書きの後ろの判事の姓(Lord HOLT、Mr. Justice BULLER)、商標の印の付いた名前(Acrobat DC®)、条で引く法令集(44 USC. 3502、15 USCA § 709)と、編と区分で引く法令集(21 CFR subpart J)も指しません。ショートメッセージで送るキーワード(texting GNPCGS to 333111)、名前のまま書いた製品の版(Adobe Acrobat Reader DC)、頭だけ大文字の語に繋いだ名前の中の大文字(NITE SAFE-Lite)も指しません。同じ文の前のほうで、同じ名詞の前に小文字で書き出した略語(incident response plan … IR plans)と、括弧の中で小文字の語を添えた略語の名前の頭の頭文字が揃うもの(… Partnerships to Stimulate Cybersecurity Education (RAMPS program))は説明したと読みます。貼り付けたチャットの発言(<jinxer-wm> FIRING …)の中の略語は、発言した人やボットの言葉なので指しません(数には入れます)。番地から州と郵便番号まで揃った所在地の中の大文字(1600 Elm Rd. NE, MS K12-3, Springfield, GA 30329 の NE と MS)、SQL のキーワード(VIEW、WHERE)、文の中で頭だけ大文字の語にも書いた名前を大文字で書いたもの(a hotel / Airbnb と書いた文書の AIRBNB)も指しません。行の頭に大文字で書いた接続詞(OR, Skip to …、二つの選択肢の間に一行で置いた OR)も指しません。
|
|
94
|
+
en: Common acronyms (URL, PDF), acronyms spelled out in brackets next to them, and the letters of a company name (㈱ADEKA, CO.,LTD.) are not reported. Neither are a template's placeholders (OOOO, XX 月) or an acronym in the title of a page in a list of links (it still counts towards the limit). Nor are an acronym explained under another capitalisation (TCoP, then TCOP), one a sentence about the abbreviation writes out (the abbreviation DOB … date of birth), or a term in a list whose nested link names it (- GPL above GNU General Public License). Nor are the parties and courts of a case citation (Ashwander v. TVA, 297 U.S. 288; MCI Telecomms. Corp. v. AT&T; (SDNY 1952)), an agency's docket number in a citation (NOV/CFA 01-01); a citation's acronyms still count towards the limit. Nor is the MR. JUSTICE that opens a line of an opinion. An acronym given another name after "or" in its parenthesis (Department of Health and Human Services (HHS or the Department)) or spelled out with its hyphened letter (Agency for Health (ARPA-H)) counts as expanded, and the letters of an email address (OASH-RFI@hhs.gov) are not an acronym. Nor are the rule names and values of an ABNF grammar in the text (CRLF, %x0D), the rungs of a grade ladder (A and AA), a register or reporter cited by number (80 FR 66128, 2022 WL 4447293), the kind written before a dated identifier (WD WD-ABC1-20200101), or the PO of a PO Box. A note that opens with a citation (1. See L. Summers (2015), "…," IMF Economic Review) is written in the cited work's words, and its acronyms are not reported (they still count towards the limit); so is an entry of a reference list keyed by a bracketed label ([FETCH] WHATWG, …). Nor are capitals the document cites by two or more numbers (BCP 78 and BCP 14, DR 4339 and DR 4340), an acronym whose name the same sentence writes out before it (U.S. Small Business Administration … SBA), a judge's surname after his title (Lord HOLT, Mr. Justice BULLER), a name marked as a trademark (Acrobat DC®), a code cited by section (44 USC. 3502, 15 USCA § 709), or a code cited by title and division (21 CFR subpart J). Nor are a keyword to send by text message (texting GNPCGS to 333111), a product's edition written with the product's name (Adobe Acrobat Reader DC), or capitals joined to a capitalised word in a name (NITE SAFE-Lite). An acronym the same sentence writes out in lower case before the same noun (incident response plan … IR plans), and one bracketed with a word in lower case after a name whose head gives its letters (… Partnerships to Stimulate Cybersecurity Education (RAMPS program)), count as expanded. An acronym in a pasted chat line (<jinxer-wm> FIRING …) is the speaker's or the bot's words, and is not reported (it still counts towards the limit). Nor are the capitals inside a postal address that runs from a street number to a state and ZIP code (the NE and MS of 1600 Elm Rd. NE, MS K12-3, Springfield, GA 30329), a keyword of SQL (VIEW, WHERE), or a name in capitals that the document also writes inside a sentence with only its first letter a capital (AIRBNB in a text that writes a hotel / Airbnb). Nor is a conjunction written in capitals at the head of a line (OR, Skip to …; an OR alone between two options).
|
|
93
95
|
level_meaning:
|
|
94
96
|
ja: 説明のない略語が {limit} 種類あれば指摘。文書が自分で略語を {limit} 個展開していれば、1 つの抜けから指摘
|
|
95
97
|
en: reported once {limit} different acronyms go unexplained, or from the first one when the document itself spells out {limit} others
|
package/rules/unknown-word.yaml
CHANGED
|
@@ -47,8 +47,8 @@ example:
|
|
|
47
47
|
The report is attached to this email.
|
|
48
48
|
|
|
49
49
|
not_flagged:
|
|
50
|
-
ja: 大文字を含む語、四字より短い語、コード・URL・メールアドレスの中の語、強調や角括弧で頭の字を分けた語の残り(**G**lobally の lobally、[e]xpressions の xpressions)、文書で二度以上使う語、一字違いの辞書の語が無い語、chaff.yaml の names に並べた語、語彙表 known-misspelling が別に言う語は指しません。同じ文書がコード(`tidyq check` やコードの区画)にも書いた語も、その文書の名前なので指しません。検索の語の後に * を付けた形(vaccin*)と、それと同じ行に並べた検索の語も、語ではないので指しません。文書がほかの語尾で使う語(rightsize と rightsized)、引用符や括弧の中に一語だけ書いた語("mailto"、(jchaplin))、文書が URL にも書いた語、他の言語の語の隣の語(bête noire)、角括弧や括弧の字を続けた語(handl[e]、neuro(a)typicality)、= の前の変数の名(nboot=2,000)、四字以上の辞書の語二つを続けた語(crowdwork)、薬の国際一般名の語幹で終わる語(paroxetine の -oxetine)、版の番号の前の語(golang 1.21.5)、辞書に無い別の語と一字だけ違う語(pthread と bthread、同じ作りの名前)も指しません。
|
|
51
|
-
en: Words with a capital letter, words shorter than four letters, words in code, URLs and email addresses, the rest of a word whose first letter is set apart by emphasis or brackets (lobally in **G**lobally, xpressions in [e]xpressions), words used twice or more in the document, words with no dictionary word one letter away, words listed under names in chaff.yaml, and the misspellings known-misspelling reports are not reported. Nor is a word the document also writes in code (`tidyq check`, a code block), since it is a name the document uses. Nor is a search stem ending in a wildcard (vaccin*), or any search term on the same line. Nor is a word the document uses with another ending (rightsize and rightsized), a word alone in quotes or brackets ("mailto", (jchaplin)), a word the document also writes in a URL, a word beside a word of another language (bête noire), a word joined to a bracketed letter (handl[e], neuro(a)typicality), a variable name before = (nboot=2,000), two dictionary words of four letters or more written as one (crowdwork), a word ending in the stem of a drug's international name (-oxetine in paroxetine), a word before a release number (golang 1.21.5), or a word one letter from another word of the document the dictionary does not know either (pthread and bthread, names on one scheme).
|
|
50
|
+
ja: 大文字を含む語、四字より短い語、コード・URL・メールアドレスの中の語、強調や角括弧で頭の字を分けた語の残り(**G**lobally の lobally、[e]xpressions の xpressions)、文書で二度以上使う語、一字違いの辞書の語が無い語、chaff.yaml の names に並べた語、語彙表 known-misspelling が別に言う語は指しません。同じ文書がコード(`tidyq check` やコードの区画)にも書いた語も、その文書の名前なので指しません。検索の語の後に * を付けた形(vaccin*)と、それと同じ行に並べた検索の語も、語ではないので指しません。文書がほかの語尾で使う語(rightsize と rightsized)、引用符や括弧の中に一語だけ書いた語("mailto"、(jchaplin))、文書が URL にも書いた語、他の言語の語の隣の語(bête noire)、角括弧や括弧の字を続けた語(handl[e]、neuro(a)typicality)、= の前の変数の名(nboot=2,000)、四字以上の辞書の語二つを続けた語(crowdwork)、薬の国際一般名の語幹で終わる語(paroxetine の -oxetine)、版の番号の前の語(golang 1.21.5)、誌の巻と号の前の語(Biochemia medica 22 (3) の medica)、辞書に無い別の語と一字だけ違う語(pthread と bthread、同じ作りの名前)も指しません。
|
|
51
|
+
en: Words with a capital letter, words shorter than four letters, words in code, URLs and email addresses, the rest of a word whose first letter is set apart by emphasis or brackets (lobally in **G**lobally, xpressions in [e]xpressions), words used twice or more in the document, words with no dictionary word one letter away, words listed under names in chaff.yaml, and the misspellings known-misspelling reports are not reported. Nor is a word the document also writes in code (`tidyq check`, a code block), since it is a name the document uses. Nor is a search stem ending in a wildcard (vaccin*), or any search term on the same line. Nor is a word the document uses with another ending (rightsize and rightsized), a word alone in quotes or brackets ("mailto", (jchaplin)), a word the document also writes in a URL, a word beside a word of another language (bête noire), a word joined to a bracketed letter (handl[e], neuro(a)typicality), a variable name before = (nboot=2,000), two dictionary words of four letters or more written as one (crowdwork), a word ending in the stem of a drug's international name (-oxetine in paroxetine), a word before a release number (golang 1.21.5), a word before a journal's volume and issue (medica in Biochemia medica 22 (3)), or a word one letter from another word of the document the dictionary does not know either (pthread and bthread, names on one scheme).
|
|
52
52
|
rewrite:
|
|
53
53
|
depth: light
|
|
54
54
|
en:
|
|
@@ -53,7 +53,7 @@ example:
|
|
|
53
53
|
|
|
54
54
|
not_flagged:
|
|
55
55
|
ja: 「当社比」「〜の中で」「〜のほうが」のように、比べる相手や範囲が同じ文にあれば指しません。「SES との最大の違い」のように、最上級のすぐ前に相手があるときも同じです。「国内最大」「業界最速」のように名詞がじかに付いた最上級と、「日本で最も」のように名前と「で」が前にある最上級は、範囲を言っているので指しません。「バグを検出できる唯一のルール」のように、動詞で終わる節が最上級のすぐ前にあって範囲を決めているときも同じです。「」や引用符で引いた言葉の中の最上級は、書き手の主張ではないので指しません。「最大化する」のように接尾辞が付いて別の語になったものも指しません。「芭蕉の最も有名な句」のように名前と「の」がすぐ前にある最上級、「最高裁判所」「最も近い駅」のような決まった言い方、「最大5億ドル」のように数のある文の最上級も指しません。「世界で唯一の」のように場や分野の名詞と「で」が前にある最上級、「俺にとって最高の日」のように誰にとってなのかが同じ節にある最上級、「最高の規律が求められる」「最高の栄誉が与えられるべき」のように求めるもの・あるべき姿として述べた最上級、「最も重要なことは」のように話の順を示す言い方、問いの文(?で終わる文)の最上級も指しません。
|
|
56
|
-
en: A superlative with its comparison or scope in the same sentence ("in our range", "than last year", "the fastest in the industry") is not reported, nor is one limited by a clause ("the best we have measured"), nor one inside quotation marks, which are someone else's words, nor one inside a set phrase ("even the best", "in the best case", "make the most of", "the most recent", "the most common"), nor one in a question. A superlative that is sought or chosen rather than claimed ("to achieve the best results", "before deciding the best way", "start with the most important tasks") is not reported, nor one whose predicate points at a member of a set ("the best plan is the one you keep"), nor one whose noun names a part of a whole ("the most important part", "the most important role"), nor one whose set follows its noun ("the best thing about this event", "the most common form of debunking", "the most important tool for creating the culture").
|
|
56
|
+
en: A superlative with its comparison or scope in the same sentence ("in our range", "than last year", "the fastest in the industry") is not reported, nor is one limited by a clause ("the best we have measured"), nor one inside quotation marks, which are someone else's words, nor one inside a set phrase ("even the best", "in the best case", "make the most of", "the most recent", "the most common"), nor one in a question. A superlative that is sought or chosen rather than claimed ("to achieve the best results", "before deciding the best way", "start with the most important tasks") is not reported, nor one whose predicate points at a member of a set ("the best plan is the one you keep") or puts it in an order ("the most critical vulnerabilities are addressed first"), nor one whose noun names a part of a whole ("the most important part", "the most important role"), nor one whose set follows its noun ("the best thing about this event", "the most common form of debunking", "the most important tool for creating the culture").
|
|
57
57
|
level_meaning:
|
|
58
58
|
ja: 比べる相手のない最上級が {limit} 箇所あれば指摘
|
|
59
59
|
en: reported once there are {limit} such claims
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Finding } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
/** A finding that adds up measures names here the rules that read the same shapes as some of them (ai-structure). */
|
|
4
|
+
export const SAME_SHAPE_VALUE = "same_shape_rules";
|
|
5
|
+
|
|
6
|
+
const sameShapeRules = (finding: Finding): string[] =>
|
|
7
|
+
String(finding.values[SAME_SHAPE_VALUE] ?? "")
|
|
8
|
+
.split(",")
|
|
9
|
+
.filter((id) => id !== "");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whether a finding still reaches its own limit once the measures already counted by their own rule are taken out:
|
|
13
|
+
* section length variation and section-length-uniformity are one sign, and a composite would count it twice.
|
|
14
|
+
*/
|
|
15
|
+
const countsOnItsOwn = (finding: Finding, fired: readonly string[]): boolean => {
|
|
16
|
+
const shared = sameShapeRules(finding).filter((id) => fired.includes(id)).length;
|
|
17
|
+
const count = finding.values["count"];
|
|
18
|
+
const limit = finding.values["limit"];
|
|
19
|
+
if (shared === 0 || typeof count !== "number" || typeof limit !== "number") return true;
|
|
20
|
+
return count - shared >= limit;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** The signals of `from` a composite counts: each one that fired, and one sign only once. */
|
|
24
|
+
export const compositeSignals = (from: readonly string[], found: readonly Finding[]): string[] => {
|
|
25
|
+
const fired = from.filter((id) => found.some((finding) => finding.rule === id));
|
|
26
|
+
return fired.filter((id) => found.some((finding) => finding.rule === id && countsOnItsOwn(finding, fired)));
|
|
27
|
+
};
|
|
@@ -43,6 +43,10 @@ export type NotationWords = {
|
|
|
43
43
|
readonly dateTimeUnits: readonly string[];
|
|
44
44
|
/** ショートメッセージでキーワードを送る動詞(text GNPCGS to 333111 の text)。 */
|
|
45
45
|
readonly textMessageVerbs?: readonly string[];
|
|
46
|
+
/** 行の頭に大文字で書く接続詞(OR, Skip to …)。略語でもある語(OR は Oregon)なので、行の頭で読点と名前の形か行の終わりが続くときだけ。 */
|
|
47
|
+
readonly openingConjunctions?: readonly string[];
|
|
48
|
+
/** 電話番号の前に置く語(TEL、FAX)。大文字で書いた形だけを、番号のすぐ前でだけ外す。 */
|
|
49
|
+
readonly phoneLabels?: readonly string[];
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
const MINUTES = String.raw`:[0-5]\d`;
|
|
@@ -107,9 +111,45 @@ const placeAndState = (states: string): RegExp =>
|
|
|
107
111
|
const textMessageKeyword = (verbs: readonly string[]): RegExp =>
|
|
108
112
|
new RegExp(String.raw`(?<![\p{L}\p{N}_])${oneOf(verbs)}\s+["“']?[A-Z][A-Z0-9]+["”']?\s+to\s+\d{4,6}(?!\d)`, "giu");
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* 行の頭に大文字で書いた接続詞(OR, Skip to the topics …、選択肢の間に一行で置いた OR)。読点の後ろに頭だけ大文字の語が続くか、
|
|
116
|
+
* その行がそこで終わるときだけ。州の並び(OR, WA and ID)や文の途中の OR(the OR staff)は略語のまま数える。
|
|
117
|
+
*/
|
|
118
|
+
const openingConjunction = (words: readonly string[]): RegExp =>
|
|
119
|
+
new RegExp(String.raw`(?<=(?:^|\n)[ \t]*)${oneOf(words)}(?=,[ \t]+\p{Lu}\p{Ll}|[ \t]*(?:\r?\n|$))`, "gu");
|
|
120
|
+
|
|
110
121
|
/** メールアドレス(OASH-RFI@hhs.gov)。@ の前の大文字は宛先の名前で、略語ではない。 */
|
|
111
122
|
const EMAIL_ADDRESS = /(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}._%+-]+@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/gu;
|
|
112
123
|
|
|
124
|
+
/** SNS のアカウント名(follow us at @USGSA)。@ のすぐ後ろの大文字はアカウントの綴りで、略語ではない。 */
|
|
125
|
+
const SOCIAL_HANDLE = /(?<![\p{L}\p{N}_.%+-])[@@]\w+/gu;
|
|
126
|
+
|
|
127
|
+
/** 『』で囲んだ大文字だけの名前(中期計画『SHIFT』)。日本語の文が計画や作品の名前に付ける括弧で、中身は名前。 */
|
|
128
|
+
const HOOKED_NAME = /『[A-Z][A-Z0-9&.・ -]*』/gu;
|
|
129
|
+
|
|
130
|
+
/** 電話番号の桁。全角の数字と区切り、雛形の伏せ字(03-〇〇〇〇-〇〇〇〇)も数える。 */
|
|
131
|
+
const PHONE_DIGIT = String.raw`[\d0-9〇○]`;
|
|
132
|
+
const PHONE_CHARACTER = String.raw`[\d0-9〇○()()++\-‐-ー.\s]`;
|
|
133
|
+
const MIN_PHONE_DIGITS = 7;
|
|
134
|
+
const DIGIT = new RegExp(PHONE_DIGIT, "gu");
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 電話番号の前の大文字の札(TEL 03-3222-1061、FAX: (202) 555-0100)。札は語彙表 phone-label の語を大文字にした形で、
|
|
138
|
+
* すぐ後ろに 7 桁以上の番号が続くときだけ外す。番号の無い TEL や FAX(the FAX machine)は略語のまま数える。
|
|
139
|
+
*/
|
|
140
|
+
const phoneLabelSpans = (labels: readonly string[]): ((text: string) => Span[]) => {
|
|
141
|
+
const capitals = [...new Set(labels.filter((label) => /^[A-Za-z]{2,6}$/u.test(label)).map((label) => label.toUpperCase()))];
|
|
142
|
+
if (capitals.length === 0) return () => [];
|
|
143
|
+
const pattern = new RegExp(
|
|
144
|
+
String.raw`(?<![\p{L}\p{N}_])${oneOf(capitals)}[ \t]*[.::]?[ \t\u3000]*(?<number>[((++]?${PHONE_DIGIT}${PHONE_CHARACTER}*${PHONE_DIGIT})`,
|
|
145
|
+
"gu",
|
|
146
|
+
);
|
|
147
|
+
return (text) =>
|
|
148
|
+
[...text.matchAll(pattern)]
|
|
149
|
+
.filter((match) => ((match.groups?.["number"] ?? "").match(DIGIT) ?? []).length >= MIN_PHONE_DIGITS)
|
|
150
|
+
.map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
151
|
+
};
|
|
152
|
+
|
|
113
153
|
// 強調の記号は空白に置き換えてある(**3:30** PM)ので、部品の間の空白は数を問わない。
|
|
114
154
|
const patternsOf = (words: NotationWords): readonly RegExp[] => [
|
|
115
155
|
new RegExp(String.raw`${CLOCK_12}\s*${oneOf(words.meridiem)}`, "gu"),
|
|
@@ -124,7 +164,10 @@ const patternsOf = (words: NotationWords): readonly RegExp[] => [
|
|
|
124
164
|
capitalHonorific(words.honorifics),
|
|
125
165
|
...titledName(oneOf(words.titles)),
|
|
126
166
|
textMessageKeyword(words.textMessageVerbs ?? []),
|
|
167
|
+
openingConjunction(words.openingConjunctions ?? []),
|
|
127
168
|
EMAIL_ADDRESS,
|
|
169
|
+
SOCIAL_HANDLE,
|
|
170
|
+
HOOKED_NAME,
|
|
128
171
|
];
|
|
129
172
|
|
|
130
173
|
export type NotAcronymSpans = (text: string) => Span[];
|
|
@@ -135,7 +178,9 @@ export type NotAcronymSpans = (text: string) => Span[];
|
|
|
135
178
|
*/
|
|
136
179
|
export const notAcronymSpansOf = (words: NotationWords): NotAcronymSpans => {
|
|
137
180
|
const patterns = patternsOf(words);
|
|
181
|
+
const phoneLabels = phoneLabelSpans(words.phoneLabels ?? []);
|
|
138
182
|
return (text) => [
|
|
183
|
+
...phoneLabels(text),
|
|
139
184
|
...patterns.flatMap((pattern) => [...text.matchAll(pattern)].map((match) => ({ start: match.index, end: match.index + match[0].length }))),
|
|
140
185
|
...citationKeySpans(text),
|
|
141
186
|
...dottedNameSpans(text),
|
|
@@ -165,6 +210,8 @@ export const lexiconNotationOf = (wordsOf: (id: string) => string[]): NotAcronym
|
|
|
165
210
|
titles: wordsOf("name-title"),
|
|
166
211
|
dateTimeUnits: wordsOf("date-time-unit"),
|
|
167
212
|
textMessageVerbs: wordsOf("text-message-verb"),
|
|
213
|
+
openingConjunctions: wordsOf("opening-conjunction"),
|
|
214
|
+
phoneLabels: wordsOf("phone-label"),
|
|
168
215
|
});
|
|
169
216
|
const names = nameSpansOf({
|
|
170
217
|
legalForms: wordsOf("legal-form"),
|
|
@@ -180,12 +227,23 @@ export const lexiconNotationOf = (wordsOf: (id: string) => string[]): NotAcronym
|
|
|
180
227
|
return (text) => [...notation(text), ...names(text)];
|
|
181
228
|
};
|
|
182
229
|
|
|
230
|
+
/**
|
|
231
|
+
* 午前・午後の点の後ろで文が切れた時刻と時間帯(between 8 a.m. and 8 p.m. ET, Monday …)。文分けは p.m. の点で文を切るので、
|
|
232
|
+
* 時間帯は次の文の頭に来る。文の中で見る組み立てと同じものを、文書の上で見る。強調の記号(**8 p.m.** ET)も挟んでよい。
|
|
233
|
+
*/
|
|
234
|
+
const clockZoneSpans = (source: string, timeZones: readonly string[]): Span[] => {
|
|
235
|
+
if (timeZones.length === 0) return [];
|
|
236
|
+
const pattern = new RegExp(String.raw`${CLOCK_12}\s*${ANY_MERIDIEM}[\s*_]*${oneOf(timeZones)}(?![\p{L}\p{N}_&])`, "gu");
|
|
237
|
+
return [...source.matchAll(pattern)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
238
|
+
};
|
|
239
|
+
|
|
183
240
|
/** 文書全体で読む、略語として数えない範囲。文献一覧の誌名や会議名、番号の付いた区切りの見出し、ABNF の文法、文に切れ目の入る所在地(Rd. NE)。 */
|
|
184
241
|
export const sourceNotAcronymSpans = (source: string, wordsOf: (id: string) => string[]): Span[] => [
|
|
185
242
|
...postalAddressSpans(source, wordsOf("street-suffix"), wordsOf("us-state-code")),
|
|
186
243
|
...referenceListSpans(source, wordsOf("reference-list-heading")),
|
|
187
244
|
...outlineLabelSpans(source, wordsOf("numbered-division")),
|
|
188
245
|
...grammarSpans(source),
|
|
246
|
+
...clockZoneSpans(source, wordsOf("time-zone")),
|
|
189
247
|
];
|
|
190
248
|
|
|
191
249
|
/**
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
// Capitals a document uses as the name of a numbered series (RFC 5785 and RFC 7230, BCP 78 and BCP 14, DR 4339 and
|
|
2
2
|
// DR 4340). Pure.
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Capitals, a space, and a whole number that is not part of a decimal, a range or a longer identifier. A letter's number
|
|
6
|
+
* (SR 24-2, CA 21-13) is a two-digit year and the letter's place in it.
|
|
7
|
+
*/
|
|
8
|
+
const NUMBERED = /(?<![\p{L}\p{N}_&.-])(?<series>[A-Z]{2,6}) (?<number>\d\d-\d{1,3}|\d{1,6})(?![\p{L}\p{N}_&]|[.,:/-]\d)/gu;
|
|
9
|
+
|
|
10
|
+
/** Two numbers of one length, the smaller first (10-20), are a range, not a year and a letter's place in it. */
|
|
11
|
+
const isRange = (number: string): boolean => {
|
|
12
|
+
const [low, high] = number.split("-");
|
|
13
|
+
return high !== undefined && low !== undefined && low.length === high.length && Number(low) < Number(high);
|
|
14
|
+
};
|
|
6
15
|
|
|
7
16
|
/** A year after capitals is when something was held or issued (FOSDEM 2024, SKO 2025), not a number in a series. */
|
|
8
17
|
const YEAR = /^(?:19|20)\d\d$/u;
|
|
@@ -20,8 +29,18 @@ export const numberedSeries = (source: string): ReadonlySet<string> => {
|
|
|
20
29
|
[...source.matchAll(NUMBERED)].forEach((match) => {
|
|
21
30
|
const series = match.groups?.["series"] ?? "";
|
|
22
31
|
const number = match.groups?.["number"] ?? "";
|
|
23
|
-
if (YEAR.test(number)) return;
|
|
32
|
+
if (YEAR.test(number) || isRange(number)) return;
|
|
24
33
|
numbers.set(series, (numbers.get(series) ?? new Set<string>()).add(number));
|
|
25
34
|
});
|
|
26
35
|
return new Set([...numbers].filter(([, seen]) => seen.size >= MIN_NUMBERS).map(([series]) => series));
|
|
27
36
|
};
|
|
37
|
+
|
|
38
|
+
/** A heading that opens with a document's number in its series and a colon (### SR 26-8: Updates to …). */
|
|
39
|
+
const NUMBER_HEADING = /^(?<series>[A-Z]{2,6}) \d+(?:-\d+)+:\s/u;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The capitals of a series whose number titles a heading: the page is that numbered letter or notice, and its series is
|
|
43
|
+
* how the reader finds it. A plain number (KPI 1: Revenue) numbers the headings and makes no series.
|
|
44
|
+
*/
|
|
45
|
+
export const headingSeries = (headings: readonly string[]): ReadonlySet<string> =>
|
|
46
|
+
new Set(headings.flatMap((heading) => NUMBER_HEADING.exec(heading)?.groups?.["series"] ?? []));
|
|
@@ -48,6 +48,11 @@ const contrastWordsOf = (doc: ProseDocument, frames: Lexicon): ContrastWords =>
|
|
|
48
48
|
|
|
49
49
|
/** 対比の枠は、一つなら論点の整理。二つ目から数える(割合の上限が、長い文書の二つを落とす)。 */
|
|
50
50
|
const MIN_CONTRASTS = 2;
|
|
51
|
+
/**
|
|
52
|
+
* 枠が 1000 語(日本語は 1000 字)に 1 つ以下なら重なっていない。文の長い文書(有価証券報告書の方針の節)は文の数が少なく、
|
|
53
|
+
* 離れた二つの枠でも割合が上限を超える。生成文は短い文書に二つ三つを詰める。
|
|
54
|
+
*/
|
|
55
|
+
const MIN_CONTRAST_DENSITY = 1;
|
|
51
56
|
const PERCENT = 100;
|
|
52
57
|
|
|
53
58
|
/** 文書の言語の文のうち、対比の枠で書いた文の割合(百分率、小数 1 桁)。文の長さが言語で違っても同じ物差しで比べられる。 */
|
|
@@ -62,7 +67,8 @@ export const contrastFraming: Detector = (doc, options): Finding[] => {
|
|
|
62
67
|
const hits = contrastSentences(doc.sentences, words)
|
|
63
68
|
.filter((sentence) => sentence.embeddedLanguage === undefined)
|
|
64
69
|
.map((sentence) => ({ sentence, matched: (firstIn(sentence, words.frames) ?? firstIn(sentence, words.leads))?.pattern ?? "" }));
|
|
65
|
-
|
|
70
|
+
const length = wordsOf(doc);
|
|
71
|
+
if (hits.length < MIN_CONTRASTS || length < MIN_DOCUMENT_LENGTH[doc.lengthUnit] || hits.length * PER <= length * MIN_CONTRAST_DENSITY) return [];
|
|
66
72
|
const share = contrastShare(doc, hits.length);
|
|
67
73
|
return share <= options.limit ? [] : hits.map((hit) => findingOf(hit, { count: hits.length, share, limit: options.limit }));
|
|
68
74
|
};
|
|
@@ -5,6 +5,8 @@ import { structureOf } from "../structure-shape/of-document.ts";
|
|
|
5
5
|
import { headedSections } from "../structure-shape/features.ts";
|
|
6
6
|
import { headingWords } from "../structure-shape/heading-words.ts";
|
|
7
7
|
import { isTemplateOutline, templateSectionsOf } from "../structure-shape/template-outline.ts";
|
|
8
|
+
import { SAME_SHAPE } from "../ai-score/signals.ts";
|
|
9
|
+
import { SAME_SHAPE_VALUE } from "../composite-signals.ts";
|
|
8
10
|
|
|
9
11
|
/** The template outline's name in the message, beside the structure measures past the human articles. */
|
|
10
12
|
const TEMPLATE_NAME: Texts<string> = { ja: "提案書・報告書の定型の見出し", en: "the textbook proposal or report headings" };
|
|
@@ -27,7 +29,9 @@ export const aiStructure: Detector = (doc, options): Finding[] => {
|
|
|
27
29
|
if (count < options.limit) return [];
|
|
28
30
|
const language = uiLanguageOf(doc.language);
|
|
29
31
|
const text = STRUCTURE_TEXT[language];
|
|
30
|
-
const
|
|
32
|
+
const beyond = scored.placements.filter((placement) => placement.beyond).map((placement) => placement.feature.id);
|
|
33
|
+
const measures = beyond.map((id) => text.features[id].name);
|
|
34
|
+
const sameShape = beyond.flatMap((id) => SAME_SHAPE[id] ?? []);
|
|
31
35
|
const names = template ? [...measures, TEMPLATE_NAME[language]] : measures;
|
|
32
36
|
const heading = (doc.markup?.headings ?? []).find((entry) => entry.depth > 1) ?? doc.markup?.headings[0];
|
|
33
37
|
return [
|
|
@@ -37,7 +41,7 @@ export const aiStructure: Detector = (doc, options): Finding[] => {
|
|
|
37
41
|
line: 0,
|
|
38
42
|
column: 0,
|
|
39
43
|
quote: heading?.text ?? "",
|
|
40
|
-
values: { word: names.join(text.listSeparator), count, limit: options.limit, offset: heading?.start ?? 0 },
|
|
44
|
+
values: { word: names.join(text.listSeparator), count, limit: options.limit, offset: heading?.start ?? 0, [SAME_SHAPE_VALUE]: sameShape.join(",") },
|
|
41
45
|
},
|
|
42
46
|
];
|
|
43
47
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pairMinority, type PairUses } from "./contraction-minority.ts";
|
|
2
2
|
import { blankRanges, isTermList, withoutMentions } from "./contraction-mention.ts";
|
|
3
3
|
import { stressedWords } from "./contraction-emphasis.ts";
|
|
4
|
+
import { noticeSentences, talksAboutContractions, warningSentences } from "./contraction-set-apart.ts";
|
|
4
5
|
import { escapeRegExp, straightApostrophes } from "../orthography.ts";
|
|
5
6
|
import type { Detector, Finding, ProseDocument, Sentence, Span } from "../plugin.ts";
|
|
6
7
|
|
|
@@ -72,13 +73,22 @@ const emphasisOf = (doc: ProseDocument): readonly Span[] => (doc.prose === undef
|
|
|
72
73
|
|
|
73
74
|
export const contractionMix: Detector = (doc, options): Finding[] => {
|
|
74
75
|
const stressed = emphasisOf(doc);
|
|
76
|
+
const notices = noticeSentences(doc.paragraphs, doc.lexicons["notice-phrase"] ?? []);
|
|
77
|
+
const terms = doc.lexicons["contraction-term"] ?? [];
|
|
78
|
+
const warnings = warningSentences(
|
|
79
|
+
doc.paragraphs,
|
|
80
|
+
doc.source,
|
|
81
|
+
(doc.lexicons["warning-label"] ?? []).map((entry) => entry.pattern),
|
|
82
|
+
);
|
|
83
|
+
const isWriters = (sentence: Sentence): boolean => !notices.has(sentence) && !talksAboutContractions(sentence, terms);
|
|
75
84
|
// 文ごとに数える。文をつないで数えると、箇条書きの「What we do」と次の項目「not every…」が「do not」と数えられる。
|
|
76
|
-
const texts = doc.sentences.map((sentence) => comparableText(sentence.text));
|
|
85
|
+
const texts = doc.sentences.map((sentence) => (isWriters(sentence) ? comparableText(sentence.text) : ""));
|
|
77
86
|
const mixed = (options.lexicon ?? []).flatMap((entry) => {
|
|
78
87
|
const pair = entry.instead_of === undefined ? undefined : mixedPair(texts, { short: entry.pattern.toLowerCase(), long: entry.instead_of.toLowerCase() });
|
|
79
88
|
return pair === undefined || pair.count > options.limit ? [] : [pair];
|
|
80
89
|
});
|
|
81
90
|
const hits = doc.sentences.flatMap((sentence) => {
|
|
91
|
+
if (!isWriters(sentence) || warnings.has(sentence)) return [];
|
|
82
92
|
const pointable = pointableText(sentence, stressed);
|
|
83
93
|
const pair = mixed.find((candidate) => usesMinority(pointable, candidate));
|
|
84
94
|
return pair === undefined ? [] : [{ sentence, pair }];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { entryIn } from "./lexicon-match.ts";
|
|
2
|
+
import { warningTextStart } from "../warning-action.ts";
|
|
3
|
+
import type { LexiconEntry, Paragraph, Sentence } from "../plugin.ts";
|
|
4
|
+
|
|
5
|
+
// Sentences whose forms say nothing about the writer's choice of register. Pure: reads paragraphs, sentences and the source;
|
|
6
|
+
// the words come from the language's notice-phrase, contraction-term and warning-label lexicons.
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The sentences of a paragraph of disclaimer wording (…does not constitute or imply its endorsement…). A publisher appends
|
|
10
|
+
* it to every page in its own fixed wording, so its forms are not the writer's: they are neither counted nor pointed at.
|
|
11
|
+
*/
|
|
12
|
+
export const noticeSentences = (paragraphs: readonly Paragraph[], cues: readonly LexiconEntry[]): Set<Sentence> =>
|
|
13
|
+
new Set(paragraphs.flatMap((paragraph) => (paragraph.sentences.some((sentence) => cues.some((cue) => entryIn(sentence, cue))) ? paragraph.sentences : [])));
|
|
14
|
+
|
|
15
|
+
/** A sentence about contractions (Avoid negative contractions like can't and don't.) names its forms; it does not use them. */
|
|
16
|
+
export const talksAboutContractions = (sentence: Sentence, terms: readonly LexiconEntry[]): boolean => terms.some((term) => entryIn(sentence, term));
|
|
17
|
+
|
|
18
|
+
/** A Hugo shortcode ({{< warning >}}, {{< alert title="Warning" >}}) or a Docusaurus admonition (:::caution) opening a paragraph. */
|
|
19
|
+
const SHORTCODE_OPENERS = ["{{<", "{{%"];
|
|
20
|
+
const SHORTCODE_TITLE = /\btitle\s*=\s*["']([^"']+)["']/u;
|
|
21
|
+
const ADMONITION = /^:::\s*([\w-]+)/u;
|
|
22
|
+
|
|
23
|
+
/** The name and the attributes of the shortcode opening the text, or undefined when none does. */
|
|
24
|
+
const shortcodeAt = (text: string): { readonly name: string; readonly attributes: string } | undefined => {
|
|
25
|
+
const end = text.indexOf("}}");
|
|
26
|
+
if (!SHORTCODE_OPENERS.some((opener) => text.startsWith(opener)) || end < 0) return undefined;
|
|
27
|
+
const [name = "", ...attributes] = text
|
|
28
|
+
.slice(3, end - 1)
|
|
29
|
+
.trim()
|
|
30
|
+
.split(" ");
|
|
31
|
+
return { name, attributes: attributes.join(" ") };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isLabel = (word: string | undefined, labels: readonly string[]): boolean =>
|
|
35
|
+
word !== undefined && labels.some((label) => label.toLowerCase() === word.trim().toLowerCase());
|
|
36
|
+
|
|
37
|
+
/** Whether a paragraph's text opens as a warning: a label (Warning:, > [!WARNING]), a shortcode or an admonition naming one. */
|
|
38
|
+
const opensWarning = (text: string, labels: readonly string[]): boolean => {
|
|
39
|
+
if (warningTextStart(text, labels) !== undefined) return true;
|
|
40
|
+
const shortcode = shortcodeAt(text);
|
|
41
|
+
if (shortcode !== undefined) return isLabel(shortcode.name, labels) || isLabel(SHORTCODE_TITLE.exec(shortcode.attributes)?.[1], labels);
|
|
42
|
+
return isLabel(ADMONITION.exec(text)?.[1], labels);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The sentences of a warning (Do not run this on an internet-facing cluster.). A warning spells the negative out for
|
|
47
|
+
* stress, as a writer bolds a word: counted, never pointed at.
|
|
48
|
+
*/
|
|
49
|
+
export const warningSentences = (paragraphs: readonly Paragraph[], source: string, labels: readonly string[]): Set<Sentence> =>
|
|
50
|
+
new Set(
|
|
51
|
+
paragraphs.flatMap((paragraph) => (opensWarning(source.slice(paragraph.span.start, paragraph.span.end).trimStart(), labels) ? paragraph.sentences : [])),
|
|
52
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The keys of the densest stretch, and the index of its first item. */
|
|
2
|
+
export type Stretch<K> = { readonly keys: ReadonlySet<K>; readonly first: number };
|
|
3
|
+
|
|
4
|
+
const keysIn = <K>(hitsPerItem: readonly (readonly K[])[], start: number, window: number): Set<K> => new Set(hitsPerItem.slice(start, start + window).flat());
|
|
5
|
+
|
|
6
|
+
const scoreOf = <K>(keys: ReadonlySet<K>, weightOf: (key: K) => number): number => [...keys].reduce((sum, key) => sum + weightOf(key), 0);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The run of at most `window` consecutive items whose distinct keys weigh the most, starting at an item with a key.
|
|
10
|
+
* The earliest wins a tie. When every hit fits in one window, that is all of them, from the first hit.
|
|
11
|
+
*/
|
|
12
|
+
export const densestStretch = <K>(hitsPerItem: readonly (readonly K[])[], window: number, weightOf: (key: K) => number): Stretch<K> | undefined =>
|
|
13
|
+
hitsPerItem.reduce<{ best: Stretch<K> | undefined; score: number }>(
|
|
14
|
+
(acc, hits, start) => {
|
|
15
|
+
if (hits.length === 0) return acc;
|
|
16
|
+
const keys = keysIn(hitsPerItem, start, window);
|
|
17
|
+
const score = scoreOf(keys, weightOf);
|
|
18
|
+
return acc.best !== undefined && score <= acc.score ? acc : { best: { keys, first: start }, score };
|
|
19
|
+
},
|
|
20
|
+
{ best: undefined, score: -Infinity },
|
|
21
|
+
).best;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Detector, Finding, Lexicon, Sentence, Token } from "../plugin.ts";
|
|
1
|
+
import type { Detector, Finding, Lexicon, Sentence, Span, Token } from "../plugin.ts";
|
|
2
2
|
import { citedNamesOf, endsCitedName } from "./cited-name.ts";
|
|
3
3
|
import { doubledAcrossAside } from "./doubled-across-aside.ts";
|
|
4
4
|
import { furiganaSpans } from "../furigana.ts";
|
|
@@ -167,10 +167,8 @@ const DOCUMENT_KIND = "document-kind";
|
|
|
167
167
|
const FIXED_PHRASE = "fixed-phrase";
|
|
168
168
|
|
|
169
169
|
/** 語の読みの括弧(凛々(りり)しい)の中の重なり。読みは語の書き方ではなく、仮名を重ねて読む語もある。 */
|
|
170
|
-
const inReading = (sentence: Sentence, doubled: Doubled): boolean =>
|
|
171
|
-
|
|
172
|
-
(span) => sentence.span.start + span.start <= doubled.first.span.start && doubled.second.span.end <= sentence.span.start + span.end,
|
|
173
|
-
);
|
|
170
|
+
const inReading = (sentence: Sentence, readings: readonly Span[], doubled: Doubled): boolean =>
|
|
171
|
+
readings.some((span) => sentence.span.start + span.start <= doubled.first.span.start && doubled.second.span.end <= sentence.span.start + span.end);
|
|
174
172
|
|
|
175
173
|
export const doubledWord: Detector = (doc, options): Finding[] => {
|
|
176
174
|
const spaced = doc.lengthUnit === "word";
|
|
@@ -178,9 +176,11 @@ export const doubledWord: Detector = (doc, options): Finding[] => {
|
|
|
178
176
|
const cited = citedNamesOf(doc.structure);
|
|
179
177
|
const kinds = new Set((doc.lexicons[DOCUMENT_KIND] ?? []).map((entry) => entry.pattern));
|
|
180
178
|
const phrases = doc.lexicons[FIXED_PHRASE] ?? [];
|
|
181
|
-
return doc.sentences.flatMap((sentence) =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
return doc.sentences.flatMap((sentence) => {
|
|
180
|
+
// The readings are found once per sentence: once per doubled pair costs the pairs times the sentence's length.
|
|
181
|
+
const readings = furiganaSpans(sentence.text);
|
|
182
|
+
return [...doubledIn(doc.source, sentence.tokens ?? [], spaced, allowed, phrases), ...(spaced ? [] : doubledAcrossAside(doc.source, sentence.tokens ?? []))]
|
|
183
|
+
.filter((doubled) => !endsCitedName(doubled.first, doubled.second, cited, kinds) && !inReading(sentence, readings, doubled))
|
|
184
|
+
.map((doubled) => findingOf(sentence, doubled, spaced));
|
|
185
|
+
});
|
|
186
186
|
};
|
|
@@ -3,6 +3,7 @@ import { minorityWithin } from "../orthography.ts";
|
|
|
3
3
|
import { QUOTATION_MARKS, isWithinAny, quotedSpans } from "../quoted-span.ts";
|
|
4
4
|
import { isCitation } from "./kutoten-consistency.ts";
|
|
5
5
|
import { ALNUM_RUN, FULLWIDTH, HALFWIDTH } from "./alnum-number.ts";
|
|
6
|
+
import { gluedNumberSpans } from "./sentence-parts.ts";
|
|
6
7
|
|
|
7
8
|
const LETTER = /[A-Za-zA-Za-z]/u;
|
|
8
9
|
|
|
@@ -79,7 +80,14 @@ const continuesVersion = (text: string, start: number, run: string): boolean =>
|
|
|
79
80
|
|
|
80
81
|
const isListItemNumber = (source: string, offset: number): boolean => LIST_ITEM_HEAD.test(source.slice(source.lastIndexOf("\n", offset - 1) + 1, offset));
|
|
81
82
|
|
|
82
|
-
export type AlnumRun = {
|
|
83
|
+
export type AlnumRun = {
|
|
84
|
+
readonly kind: AlnumKind;
|
|
85
|
+
readonly fullwidth: boolean;
|
|
86
|
+
readonly written: string;
|
|
87
|
+
readonly offset: number;
|
|
88
|
+
/** 表のセルを続けてしまった数字(8,457 と 95.7 の 8,45795.7)の中。幅は書き手のものだが、セルの切れ目が分からず桁の数は当てにならない。 */
|
|
89
|
+
readonly glued: boolean;
|
|
90
|
+
};
|
|
83
91
|
|
|
84
92
|
/**
|
|
85
93
|
* 文の中の英字・数字の並び。全角と半角が混ざった並び、鉤括弧で引いたものの中、項目と注の番号、箇条書きの頭の番号、版の番号の続き(TLS1.2 の 2)は数えない。
|
|
@@ -87,6 +95,7 @@ export type AlnumRun = { readonly kind: AlnumKind; readonly fullwidth: boolean;
|
|
|
87
95
|
*/
|
|
88
96
|
export const alnumRunsIn = (sentence: Sentence, source: string): AlnumRun[] => {
|
|
89
97
|
const quoted: readonly Span[] = quotedSpans(sentence.text, QUOTATION_MARKS);
|
|
98
|
+
const glued = gluedNumberSpans(sentence.text);
|
|
90
99
|
return [...sentence.text.matchAll(ALNUM_RUN)]
|
|
91
100
|
.filter((match) => FULLWIDTH.test(match[0]) || HALFWIDTH.test(match[0]))
|
|
92
101
|
.filter((match) => !isWithinAny(quoted, { start: match.index, end: match.index + match[0].length }))
|
|
@@ -96,7 +105,13 @@ export const alnumRunsIn = (sentence: Sentence, source: string): AlnumRun[] => {
|
|
|
96
105
|
.filter((match) => !isInApostropheWord(sentence.text, match.index, match.index + match[0].length))
|
|
97
106
|
.filter((match) => !isNumberLabel(sentence.text, match.index + match[0].length, match[0]))
|
|
98
107
|
.filter((match) => !continuesVersion(sentence.text, match.index, match[0]))
|
|
99
|
-
.map((match) => ({
|
|
108
|
+
.map((match) => ({
|
|
109
|
+
kind: kindOf(match[0]),
|
|
110
|
+
fullwidth: FULLWIDTH.test(match[0]),
|
|
111
|
+
written: match[0],
|
|
112
|
+
offset: sentence.span.start + match.index,
|
|
113
|
+
glued: isWithinAny(glued, { start: match.index, end: match.index + match[0].length }),
|
|
114
|
+
}));
|
|
100
115
|
};
|
|
101
116
|
|
|
102
117
|
const KINDS: readonly AlnumKind[] = ["letter", "letters", "digit", "digits"];
|
|
@@ -157,6 +172,7 @@ const findingOf = ({ sentence, run }: Located, count: number, of: number, limit:
|
|
|
157
172
|
/**
|
|
158
173
|
* 英字・数字を全角で書くか半角で書くか。組(英字一字・英字の語・数字一字・数字の並び)ごとに、文書の中で少ないほうを指摘する。
|
|
159
174
|
* 少ないほうが組の limit パーセントを超えるほど多いなら、文書が使い分けている(数え方の語や見出しの書き方)と見て言わない。
|
|
175
|
+
* 表のセルを続けてしまった数字の中の並びは、書き方の票には入れるが、少ないほうとしては指摘しない(8,45795.7 の 8 は一桁の数ではない)。
|
|
160
176
|
* どちらが正しいかは決めない。
|
|
161
177
|
*/
|
|
162
178
|
export const fullwidthAlnum: Detector = (doc, options): Finding[] => {
|
|
@@ -169,7 +185,7 @@ export const fullwidthAlnum: Detector = (doc, options): Finding[] => {
|
|
|
169
185
|
const ofKind = located.filter(({ run }) => run.kind === kind);
|
|
170
186
|
const odd = minorityWithin(ofKind, ({ run }) => run.fullwidth, options.limit);
|
|
171
187
|
return odd
|
|
172
|
-
.filter(({ run }) => !isHalfwidthEnglishWord(run))
|
|
188
|
+
.filter(({ run }) => !isHalfwidthEnglishWord(run) && !run.glued)
|
|
173
189
|
.filter(departsFromHabit(ofKind, odd))
|
|
174
190
|
.map((entry) => findingOf(entry, odd.length, ofKind.length, options.limit));
|
|
175
191
|
});
|
|
@@ -59,22 +59,36 @@ const QUOTE_CLOSING_MAX = 12;
|
|
|
59
59
|
*/
|
|
60
60
|
const QUOTE_CLOSING = new RegExp(String.raw`[」』]([をがにでへ][^「」『』、,。.をがにでへ]{1,${String(QUOTE_CLOSING_MAX - 1)}}[。.]?)\s*$`, "u");
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
/** リンクの文字のすぐ後ろの結び([ノンス](…)を参照してください。)。題を受ける助詞と述語だけなのは引いた題の後ろと同じ。 */
|
|
63
|
+
const LINK_CLOSING = new RegExp(String.raw`[をがにでへ][^「」『』、,。.をがにでへ]{1,${String(QUOTE_CLOSING_MAX - 1)}}[。.]?\s*$`, "u");
|
|
64
|
+
|
|
65
|
+
/** 文の中の位置がリンクの文字か。リンクの無い文は、どの位置もリンクではない。 */
|
|
66
|
+
export type Linked = (index: number) => boolean;
|
|
67
|
+
|
|
68
|
+
const NOT_LINKED: Linked = () => false;
|
|
69
|
+
|
|
70
|
+
/** 引いた題か、リンクの文字の直後で結ぶ範囲。手引きや参照のページは、別のページを指すたびに同じ結びで指す。 */
|
|
71
|
+
const closingAfterReference = (text: string, linked: Linked): Span | undefined => {
|
|
72
|
+
const quoted = QUOTE_CLOSING.exec(text);
|
|
73
|
+
if (quoted !== null) return { start: quoted.index + 1, end: quoted.index + quoted[0].length };
|
|
74
|
+
const afterLink = LINK_CLOSING.exec(text);
|
|
75
|
+
return afterLink !== null && afterLink.index > 0 && linked(afterLink.index - 1)
|
|
76
|
+
? { start: afterLink.index, end: afterLink.index + afterLink[0].length }
|
|
77
|
+
: undefined;
|
|
65
78
|
};
|
|
66
79
|
|
|
67
|
-
const closingTextOf = (text: string): string | undefined => {
|
|
68
|
-
const span =
|
|
80
|
+
const closingTextOf = (text: string, linked: Linked): string | undefined => {
|
|
81
|
+
const span = closingAfterReference(text, linked);
|
|
69
82
|
return span === undefined ? undefined : text.slice(span.start, span.end).trimEnd();
|
|
70
83
|
};
|
|
71
84
|
|
|
72
85
|
/**
|
|
73
|
-
* 文書が参照の書式として使う結び:
|
|
74
|
-
*
|
|
86
|
+
* 文書が参照の書式として使う結び: 引いた題かリンクの直後で結ぶことが、その結びで終わる文の過半である結び(詳しくは「…」を確認してください。
|
|
87
|
+
* 詳しくは[…](…)を参照してください。)。引いた名前の後ろにたまたま来た書き手の結び(「生涯活躍のまち」を推進している。のほかは整備を
|
|
88
|
+
* 推進している。)は、ほとんどが題の後ろではない。linked は texts と同じ順の、文ごとのリンクの位置。
|
|
75
89
|
*/
|
|
76
|
-
export const referenceClosings = (texts: readonly string[]): ReadonlySet<string> => {
|
|
77
|
-
const afterQuote = texts.flatMap((text) => closingTextOf(text) ?? []);
|
|
90
|
+
export const referenceClosings = (texts: readonly string[], linked: readonly Linked[] = []): ReadonlySet<string> => {
|
|
91
|
+
const afterQuote = texts.flatMap((text, index) => closingTextOf(text, linked[index] ?? NOT_LINKED) ?? []);
|
|
78
92
|
return new Set(
|
|
79
93
|
[...new Set(afterQuote)].filter((closing) => {
|
|
80
94
|
const quoted = afterQuote.filter((each) => each === closing).length;
|
|
@@ -85,12 +99,12 @@ export const referenceClosings = (texts: readonly string[]): ReadonlySet<string>
|
|
|
85
99
|
};
|
|
86
100
|
|
|
87
101
|
/**
|
|
88
|
-
*
|
|
102
|
+
* 引いた題かリンクで終わる文の結び(詳しくは「入力可能な文字」を確認してください。)の範囲。
|
|
89
103
|
* closings(referenceClosings)にある結びだけを、参照の書式として数えない。
|
|
90
104
|
*/
|
|
91
|
-
export const quotedClosingSpans = (text: string, closings: ReadonlySet<string
|
|
92
|
-
const span =
|
|
93
|
-
const closing = closingTextOf(text);
|
|
105
|
+
export const quotedClosingSpans = (text: string, closings: ReadonlySet<string>, linked: Linked = NOT_LINKED): Span[] => {
|
|
106
|
+
const span = closingAfterReference(text, linked);
|
|
107
|
+
const closing = closingTextOf(text, linked);
|
|
94
108
|
return span !== undefined && closing !== undefined && closings.has(closing) ? [span] : [];
|
|
95
109
|
};
|
|
96
110
|
|