chaffjs 0.47.0 → 0.48.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/bound-word-particles.d.ts +1 -0
- package/dist/bound-word-particles.d.ts.map +1 -1
- package/dist/bound-word-particles.js +1 -1
- package/dist/bound-word-particles.js.map +1 -1
- package/dist/clause-particles.d.ts +11 -0
- package/dist/clause-particles.d.ts.map +1 -0
- package/dist/clause-particles.js +20 -0
- package/dist/clause-particles.js.map +1 -0
- package/dist/detectors/acronym-definition.d.ts.map +1 -1
- package/dist/detectors/acronym-definition.js +14 -6
- package/dist/detectors/acronym-definition.js.map +1 -1
- package/dist/detectors/acronym-expansion.d.ts +2 -0
- package/dist/detectors/acronym-expansion.d.ts.map +1 -1
- package/dist/detectors/acronym-expansion.js +18 -7
- package/dist/detectors/acronym-expansion.js.map +1 -1
- package/dist/detectors/acronym-mention.d.ts.map +1 -1
- package/dist/detectors/acronym-mention.js +3 -1
- package/dist/detectors/acronym-mention.js.map +1 -1
- package/dist/detectors/acronym-parent-item.d.ts +6 -0
- package/dist/detectors/acronym-parent-item.d.ts.map +1 -0
- package/dist/detectors/acronym-parent-item.js +50 -0
- package/dist/detectors/acronym-parent-item.js.map +1 -0
- package/dist/detectors/broken-link.d.ts.map +1 -1
- package/dist/detectors/broken-link.js +14 -0
- package/dist/detectors/broken-link.js.map +1 -1
- package/dist/detectors/citation-sentence.d.ts +8 -0
- package/dist/detectors/citation-sentence.d.ts.map +1 -1
- package/dist/detectors/citation-sentence.js +24 -0
- package/dist/detectors/citation-sentence.js.map +1 -1
- package/dist/detectors/concrete-evidence-density.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence-density.js +13 -6
- package/dist/detectors/concrete-evidence-density.js.map +1 -1
- package/dist/detectors/concrete-evidence.d.ts +7 -1
- package/dist/detectors/concrete-evidence.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence.js +45 -0
- package/dist/detectors/concrete-evidence.js.map +1 -1
- package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
- package/dist/detectors/doubled-punctuation.js +14 -4
- package/dist/detectors/doubled-punctuation.js.map +1 -1
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +8 -5
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/law-governed.d.ts +10 -0
- package/dist/detectors/law-governed.d.ts.map +1 -0
- package/dist/detectors/law-governed.js +41 -0
- package/dist/detectors/law-governed.js.map +1 -0
- package/dist/detectors/name-variant-two-things.d.ts +2 -1
- package/dist/detectors/name-variant-two-things.d.ts.map +1 -1
- package/dist/detectors/name-variant-two-things.js +9 -3
- package/dist/detectors/name-variant-two-things.js.map +1 -1
- package/dist/detectors/open-end-names.d.ts +7 -2
- package/dist/detectors/open-end-names.d.ts.map +1 -1
- package/dist/detectors/open-end-names.js +14 -4
- package/dist/detectors/open-end-names.js.map +1 -1
- package/dist/detectors/requirement-smell.d.ts.map +1 -1
- package/dist/detectors/requirement-smell.js +6 -2
- package/dist/detectors/requirement-smell.js.map +1 -1
- package/dist/detectors/sentence-length.js +5 -5
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-parts.d.ts +2 -0
- package/dist/detectors/sentence-parts.d.ts.map +1 -1
- package/dist/detectors/sentence-parts.js +10 -0
- package/dist/detectors/sentence-parts.js.map +1 -1
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +3 -0
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/space-before-punctuation.js +3 -3
- package/dist/detectors/space-before-punctuation.js.map +1 -1
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +21 -5
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/topic-predicate-distance.d.ts.map +1 -1
- package/dist/detectors/topic-predicate-distance.js +3 -1
- package/dist/detectors/topic-predicate-distance.js.map +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +31 -6
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/vague-density.d.ts +4 -2
- package/dist/detectors/vague-density.d.ts.map +1 -1
- package/dist/detectors/vague-density.js +17 -9
- package/dist/detectors/vague-density.js.map +1 -1
- package/dist/document.js +2 -2
- package/dist/document.js.map +1 -1
- package/dist/name-variant-shapes.d.ts +22 -0
- package/dist/name-variant-shapes.d.ts.map +1 -1
- package/dist/name-variant-shapes.js +63 -0
- package/dist/name-variant-shapes.js.map +1 -1
- package/dist/paragraph-length.d.ts.map +1 -1
- package/dist/paragraph-length.js +5 -6
- package/dist/paragraph-length.js.map +1 -1
- package/dist/sentence-load.d.ts.map +1 -1
- package/dist/sentence-load.js +20 -6
- package/dist/sentence-load.js.map +1 -1
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +13 -0
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/universal.d.ts.map +1 -1
- package/dist/structure/universal.js +9 -1
- package/dist/structure/universal.js.map +1 -1
- package/dist/structure/unread-label.d.ts.map +1 -1
- package/dist/structure/unread-label.js +3 -1
- package/dist/structure/unread-label.js.map +1 -1
- package/dist/topic-clause.d.ts +2 -0
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js.map +1 -1
- package/package.json +3 -3
- package/rules/adverb-overuse.yaml +2 -2
- package/rules/bracket-nesting.yaml +2 -2
- package/rules/broken-link.yaml +2 -2
- package/rules/concrete-evidence-density.yaml +2 -2
- package/rules/doubled-punctuation.yaml +2 -2
- package/rules/max-sentence-length.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/space-before-punctuation.yaml +4 -4
- package/rules/taigen-dome-in-prose.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +3 -3
- package/rules/unbalanced-bracket.yaml +4 -4
- package/rules/undefined-acronym.yaml +2 -0
- package/rules/vague-word-density.yaml +2 -2
- package/src/bound-word-particles.ts +2 -1
- package/src/clause-particles.ts +35 -0
- package/src/detectors/acronym-definition.ts +14 -6
- package/src/detectors/acronym-expansion.ts +26 -7
- package/src/detectors/acronym-mention.ts +6 -1
- package/src/detectors/acronym-parent-item.ts +60 -0
- package/src/detectors/broken-link.ts +16 -0
- package/src/detectors/citation-sentence.ts +30 -0
- package/src/detectors/concrete-evidence-density.ts +18 -7
- package/src/detectors/concrete-evidence.ts +56 -1
- package/src/detectors/doubled-punctuation.ts +20 -4
- package/src/detectors/en-shape.ts +8 -5
- package/src/detectors/law-governed.ts +50 -0
- package/src/detectors/name-variant-two-things.ts +18 -3
- package/src/detectors/open-end-names.ts +21 -4
- package/src/detectors/requirement-smell.ts +6 -2
- package/src/detectors/sentence-length.ts +5 -5
- package/src/detectors/sentence-parts.ts +12 -0
- package/src/detectors/signals.ts +3 -0
- package/src/detectors/space-before-punctuation.ts +3 -3
- package/src/detectors/token-shape.ts +27 -7
- package/src/detectors/topic-predicate-distance.ts +3 -1
- package/src/detectors/unbalanced-bracket.ts +39 -7
- package/src/detectors/vague-density.ts +25 -10
- package/src/document.ts +2 -2
- package/src/name-variant-shapes.ts +74 -0
- package/src/paragraph-length.ts +8 -9
- package/src/sentence-load.ts +29 -6
- package/src/structure/definition-use.ts +15 -0
- package/src/structure/universal.ts +10 -1
- package/src/structure/unread-label.ts +3 -1
- package/src/topic-clause.ts +2 -0
|
@@ -42,8 +42,8 @@ example:
|
|
|
42
42
|
after: 本社営業部にある第二課の方針を確認しました。
|
|
43
43
|
|
|
44
44
|
not_flagged:
|
|
45
|
-
ja: 読点で区切った並び、=・:・→ で区切った句、「」や『』の中の題名や引用、行の頭のリンクで引いた外のページの題名、文の中に書いた法律の題名(障害者等の移動等の円滑化の促進に関する法律)、短い呼び名を付けた長い名前(被害者のための相談センター(以下「センター」という。))、文書が一度鉤括弧で引いた名前を括弧なしで書き直したもの(「地域のための共通の指針」と引いた後の、地域のための共通の指針の改定)は数えません。括弧(】や )
|
|
46
|
-
en: Items separated by commas, phrases separated by =, a colon or an arrow, titles or quotations inside 「」 or 『』, the title of an outside page quoted by a link at a line's head, the title of a law written in the sentence (障害者等の移動等の円滑化の促進に関する法律), a long name given a short one (被害者のための相談センター(以下「センター」という。)), a name the document quotes once and writes again without brackets, and the の before an honorific for a group of people when that form of address goes on with の (国民の皆様の期待, 被災者の方々の暮らし), are not counted. Nor is the の before a word that places something against another (下, 上, 横, 裏) when the place goes on with の (ラックの下の段, the shelf under the rack). Nor is the の inside a set phrase read as one word (おそれのある, "at risk of", in
|
|
45
|
+
ja: 読点で区切った並び、=・:・→ で区切った句、「」や『』の中の題名や引用、行の頭のリンクで引いた外のページの題名、文の中に書いた法律の題名(障害者等の移動等の円滑化の促進に関する法律)、短い呼び名を付けた長い名前(被害者のための相談センター(以下「センター」という。))、文書が一度鉤括弧で引いた名前を括弧なしで書き直したもの(「地域のための共通の指針」と引いた後の、地域のための共通の指針の改定)は数えません。括弧(】や ))は、解析器が次の語とつなげて読んでも連なりを切ります。人の集まりを敬って呼ぶ語の前の「の」も、その呼び方が「の」で次の語に係るとき(国民の皆様の期待、被災者の方々の暮らし)は一つの呼び方の中なので数えません。置き場所を前の語との関係で言う語(下、上、横、裏)の前の「の」も、その場所が「の」で次の語に係るとき(ラックの下の段)は一つの場所の名前の中なので数えません。決まった言い回しの中の「の」(絶滅のおそれのある種の「おそれのある」、AとBとの間の「との間」)も、一語のように読むので数えません。「他の」の「の」も、名詞を名詞の中に入れず絞るだけなので数えません。「の」が節の主語を示すとき(番号のついた版の部品)は、節の前と後ろを別の句として数え、どちらかが上限を超えるときだけ言います。表を一続きの文に平らにしたもの(セルの数字がつながった 8,45795.7 や、見出しのセルが単位の括弧で閉じる 割合(%)被所有割合(%)…)は、セルの切れ目が見えないので数えません。
|
|
46
|
+
en: Items separated by commas, phrases separated by =, a colon or an arrow, titles or quotations inside 「」 or 『』, the title of an outside page quoted by a link at a line's head, the title of a law written in the sentence (障害者等の移動等の円滑化の促進に関する法律), a long name given a short one (被害者のための相談センター(以下「センター」という。)), a name the document quotes once and writes again without brackets, and the の before an honorific for a group of people when that form of address goes on with の (国民の皆様の期待, 被災者の方々の暮らし), are not counted. Nor is the の before a word that places something against another (下, 上, 横, 裏) when the place goes on with の (ラックの下の段, the shelf under the rack). Nor is the の inside a set phrase read as one word (おそれのある, "at risk of", in 絶滅のおそれのある種; との間, "between", in AとBとの間), nor the の of 他の ("other"), which narrows the noun rather than nesting it. When の marks the subject of a clause (番号のついた版の部品, the part of the version that has a number), the phrases before and after the clause are counted apart, and the run is reported only when one of them goes over the limit. Nor is a table flattened into one run of text (numbers of two cells run together, 8,45795.7, or header cells each closed by a unit in brackets, 割合(%)被所有割合(%)…), whose cell boundaries cannot be seen. A bracket (】 or ")") ends the run even when the parser joins it to the next word.
|
|
47
47
|
level_meaning:
|
|
48
48
|
ja: 同じ助詞の連続 {limit} 回まで
|
|
49
49
|
en: up to {limit} of the same particle in a row
|
|
@@ -74,5 +74,5 @@ example:
|
|
|
74
74
|
config: { genre: technical/spec }
|
|
75
75
|
|
|
76
76
|
not_flagged:
|
|
77
|
-
ja: 要求の文でない文(説明や背景)、法令、ブログやビジネス文書は見ません。語彙表にない言い方は指しません。文書が定めた名前の「等」(以下「委託先等」という、銀行等(…をいう。)、定義の号の頭の語、次の段落で定義する項目だけを書いた語(9 書面等)と、監査等委員会のように後ろへ語が続く「等」は、列挙を閉じているので指しません。文書が定義した語のすぐ後ろの「等」(「秘密情報」と定義した文書の秘密情報等)も、定義したものを広げた名前で、開いた一覧ではないので指しません。すぐ後ろで種類を名指す「等」(印刷等、二次的に利用される場合/印刷等の二次的利用)も、一覧がその種類の例なので指しません。条件(訂正等を行った際に)、与える権利(消去等できるものとします)、禁止や免責(転載等をしてはならない、責任を負わないものとします)の中の「等」も、わざと広く取った一覧なので指しません。「しないこと。」「ではないこと。」で閉じる文(禁止や否定)、権利が誰のものかを定める文(帰属するものとする、留保されるものとします)、「次の行為をしてはならない。」の下に並ぶ項目の中の「等」も同じです。「当該」「前記」で始まる一覧(当該改良、改善等)は前に挙げた一覧を指し直すだけなので、そこでは指しません。要求が何についてかを説明する節の中の「など」(SNSなどを通じて知り合った人と行う取引は、…必要があります)も、果たす義務の中にないので指しません。条件の語のすぐ後ろの括弧の中の「等」(不要な場合(一つの表だけを読むとき等)も付けること)は、いつ当てはまるかの例なので指しません。英語の as soon as possible は、同じ文に日数の期限(no later than two days after)があれば、期限が決まっているので指しません。英語の but not limited to(including, but not limited to
|
|
78
|
-
en: Sentences that state no requirement (background, explanation), statutes, and blogs and business documents are not checked. Phrases not on chaff's lists are not reported. In Japanese, an open word in the clause that describes what the requirement is about (SNSなどを通じて…行う取引は、…必要があります) is not reported, since it is not in what the reader is asked to do. An open-ended word inside a name the document defines (a quoted term, one defined in the brackets after it, or one an item of a definition list holds alone and the next paragraph defines) is not reported, nor is one written right after a term the document defines (秘密情報等 where 「秘密情報」 is defined), which widens a named thing rather than leaving a list open. "As soon as possible" followed in the same sentence by a limit in numbers ("but in any event no later than two days after") is bounded, and not reported. In a contract, "including, but not limited to" is a term of art that keeps the listed examples from narrowing the class, and is not reported. In Japanese, 等 right before the words that name the kind it gives examples of (印刷等、二次的に利用, "secondary use, such as printing") is not reported either. Nor is a Japanese 等 in a condition (訂正等を行った際に), a right the writer grants (できるものとする) or a prohibition or disclaimer (てはならない, ないものとする), because such a list is kept wide on purpose; the same holds for a sentence closed by a negation (しないこと, ではないこと), one that says who holds a right (帰属するものとする, 留保されるものとします), and the items of a list under a lead that forbids them (次の行為をしてはならない). A Japanese list opened by a pointing word (当該改良、改善等, "the said improvements, etc.") names one given before and is not reported again; or an open list in brackets right after a condition word (場合(…等), "in cases (…, etc.)"), which gives examples of when the requirement applies. Nor is a Japanese 等 in a noun a heading of the document names (出願書類等 under 出願書類等の送付先), which is the page's subject rather than an open list.
|
|
77
|
+
ja: 要求の文でない文(説明や背景)、法令、ブログやビジネス文書は見ません。語彙表にない言い方は指しません。文書が定めた名前の「等」(以下「委託先等」という、銀行等(…をいう。)、定義の号の頭の語、次の段落で定義する項目だけを書いた語(9 書面等)と、監査等委員会のように後ろへ語が続く「等」は、列挙を閉じているので指しません。文書が定義した語のすぐ後ろの「等」(「秘密情報」と定義した文書の秘密情報等)も、定義したものを広げた名前で、開いた一覧ではないので指しません。すぐ後ろで種類を名指す「等」(印刷等、二次的に利用される場合/印刷等の二次的利用)も、一覧がその種類の例なので指しません。条件(訂正等を行った際に)、与える権利(消去等できるものとします)、禁止や免責(転載等をしてはならない、責任を負わないものとします)の中の「等」も、わざと広く取った一覧なので指しません。「しないこと。」「ではないこと。」で閉じる文(禁止や否定)、権利が誰のものかを定める文(帰属するものとする、留保されるものとします)、「次の行為をしてはならない。」の下に並ぶ項目の中の「等」も同じです。「当該」「前記」で始まる一覧(当該改良、改善等)は前に挙げた一覧を指し直すだけなので、そこでは指しません。要求が何についてかを説明する節の中の「など」(SNSなどを通じて知り合った人と行う取引は、…必要があります)も、果たす義務の中にないので指しません。条件の語のすぐ後ろの括弧の中の「等」(不要な場合(一つの表だけを読むとき等)も付けること)は、いつ当てはまるかの例なので指しません。英語の as soon as possible は、同じ文に日数の期限(no later than two days after)があれば、期限が決まっているので指しません。英語の but not limited to(including, but not limited to)は、契約書では例の一覧で範囲を狭めないための決まった言い方なので、契約書では指しません。文書の見出しが名指す語の「等」(見出し「出願書類等の送付先」の下の出願書類等)も、ページの主題の名前なので指しません。法令や慣行が「等」まで含めて決めている語(消費税等、免許等。語彙表にあるもの)の「等」も、開いた一覧ではないので指しません。
|
|
78
|
+
en: Sentences that state no requirement (background, explanation), statutes, and blogs and business documents are not checked. Phrases not on chaff's lists are not reported. In Japanese, an open word in the clause that describes what the requirement is about (SNSなどを通じて…行う取引は、…必要があります) is not reported, since it is not in what the reader is asked to do. An open-ended word inside a name the document defines (a quoted term, one defined in the brackets after it, or one an item of a definition list holds alone and the next paragraph defines) is not reported, nor is one written right after a term the document defines (秘密情報等 where 「秘密情報」 is defined), which widens a named thing rather than leaving a list open. "As soon as possible" followed in the same sentence by a limit in numbers ("but in any event no later than two days after") is bounded, and not reported. In a contract, "including, but not limited to" is a term of art that keeps the listed examples from narrowing the class, and is not reported. In Japanese, 等 right before the words that name the kind it gives examples of (印刷等、二次的に利用, "secondary use, such as printing") is not reported either. Nor is a Japanese 等 in a condition (訂正等を行った際に), a right the writer grants (できるものとする) or a prohibition or disclaimer (てはならない, ないものとする), because such a list is kept wide on purpose; the same holds for a sentence closed by a negation (しないこと, ではないこと), one that says who holds a right (帰属するものとする, 留保されるものとします), and the items of a list under a lead that forbids them (次の行為をしてはならない). A Japanese list opened by a pointing word (当該改良、改善等, "the said improvements, etc.") names one given before and is not reported again; or an open list in brackets right after a condition word (場合(…等), "in cases (…, etc.)"), which gives examples of when the requirement applies. Nor is a Japanese 等 in a noun a heading of the document names (出願書類等 under 出願書類等の送付先), which is the page's subject rather than an open list. Nor is a Japanese 等 in a term that law or usage fixes with it (消費税等, 免許等, from the lexicon), which is no open list.
|
|
@@ -10,8 +10,8 @@ name:
|
|
|
10
10
|
en: Space before punctuation
|
|
11
11
|
|
|
12
12
|
why:
|
|
13
|
-
ja: '英文では句読点を前の語に付けて書きます。「word .」「(word) ,」のように前に空白があると、行の折り返しで句読点だけが次の行の頭に落ちることがあり、書き換えの途中で残った空白に見えます。ピリオド・カンマ・セミコロン・疑問符・感嘆符を見ます。コロン("Note : ")、空白で区切った省略の点や目次の点線(". . ."
|
|
14
|
-
en: 'English attaches punctuation to the word before it. A space before it ("word .", "(word) ,") can leave the mark alone at the start of the next line, and reads as a space left over from an edit. Periods, commas, semicolons, question marks and exclamation marks are checked. A colon ("Note : "), dots spaced out as an ellipsis or a leader in a table of contents (". . ."), a dot that starts the next word (".NET", ".5"), a mark after a number ("[ 1 , N ]" in a formula), code and URLs are not counted, nor are two or more spaces before the mark (a line laid out like a table).'
|
|
13
|
+
ja: '英文では句読点を前の語に付けて書きます。「word .」「(word) ,」のように前に空白があると、行の折り返しで句読点だけが次の行の頭に落ちることがあり、書き換えの途中で残った空白に見えます。ピリオド・カンマ・セミコロン・疑問符・感嘆符を見ます。コロン("Note : ")、空白で区切った省略の点や目次の点線(". . ."、行の折り返しが点の間に入ったものも)、".NET" や ".5" のように次の語の頭の点、数の後ろ(式の "[ 1 , N ]")、コードと URL は数えません。前の空白が二つ以上の所(表のように並べた行)も数えません。'
|
|
14
|
+
en: 'English attaches punctuation to the word before it. A space before it ("word .", "(word) ,") can leave the mark alone at the start of the next line, and reads as a space left over from an edit. Periods, commas, semicolons, question marks and exclamation marks are checked. A colon ("Note : "), dots spaced out as an ellipsis or a leader in a table of contents (". . .", also when a line break falls between the dots), a dot that starts the next word (".NET", ".5"), a mark after a number ("[ 1 , N ]" in a formula), code and URLs are not counted, nor are two or more spaces before the mark (a line laid out like a table).'
|
|
15
15
|
|
|
16
16
|
message:
|
|
17
17
|
ja: 「{mark}」の前に空白があります
|
|
@@ -37,5 +37,5 @@ example:
|
|
|
37
37
|
The form is ready, and the office has a copy.
|
|
38
38
|
|
|
39
39
|
not_flagged:
|
|
40
|
-
ja: コロン、空白で区切った省略の点や目次の点線(「. .
|
|
41
|
-
en: Colons, dots spaced out as an ellipsis or a leader (". . ."), a dot that starts a word (".NET", ".5"), a mark after a number or after two or more spaces, code and URLs, and a comma after a capitalised field left empty in a reference list ("ISBN ,") are not reported.
|
|
40
|
+
ja: コロン、空白で区切った省略の点や目次の点線(「. . .」、点の間で行を折り返したものも)、「.NET」「.5」のような語の頭の点、数の後ろの句読点、二つ以上の空白の後ろの句読点、コードと URL、文献一覧で値の落ちた大文字の欄の後ろの読点(「ISBN ,」)は指しません。
|
|
41
|
+
en: Colons, dots spaced out as an ellipsis or a leader (". . .", even across a line break), a dot that starts a word (".NET", ".5"), a mark after a number or after two or more spaces, code and URLs, and a comma after a capitalised field left empty in a reference list ("ISBN ,") are not reported.
|
|
@@ -44,8 +44,8 @@ example:
|
|
|
44
44
|
今年の目標は売上の回復です。そのための施策は三つあります。最初に、店頭の品ぞろえを見直します。
|
|
45
45
|
|
|
46
46
|
not_flagged:
|
|
47
|
-
ja: 箇条書きの中の体言止めは、その書き方が普通なので数えません。段落の頭に (1)(2)(3) と順に番号を付け、URL や西暦の年で出典を書いた注や文献の一覧も、名前や題を並べた項目なので数えません。(注1
|
|
48
|
-
en: Noun endings in bullet lists, where the form is normal, are not counted. Nor are the entries of a list of notes or references written as paragraphs numbered (1), (2), (3) in order that cite sources (a URL or a year), which list names and titles. Nor are the paragraphs of a note to a table or a figure opened by its label ((注1), 注:), or the sentence right before a bullet list that hands the reader to it (以下のとおり説明。), which are written ending in a noun.
|
|
47
|
+
ja: 箇条書きの中の体言止めは、その書き方が普通なので数えません。段落の頭に (1)(2)(3) と順に番号を付け、URL や西暦の年で出典を書いた注や文献の一覧も、名前や題を並べた項目なので数えません。(注1)や「注:」で始まる表や図の注の段落と、箇条書きのすぐ前でそこへ渡す文(以下のとおり説明。)も、名詞で止めるのが書き方なので数えません。「どのような見直しが必要か。」のように問いの「か」で閉じた文は問いなので数えません。
|
|
48
|
+
en: Noun endings in bullet lists, where the form is normal, are not counted. Nor are the entries of a list of notes or references written as paragraphs numbered (1), (2), (3) in order that cite sources (a URL or a year), which list names and titles. Nor are the paragraphs of a note to a table or a figure opened by its label ((注1), 注:), or the sentence right before a bullet list that hands the reader to it (以下のとおり説明。), which are written ending in a noun. Nor is a question closed by the particle か (どのような見直しが必要か。).
|
|
49
49
|
level_meaning:
|
|
50
50
|
ja: 本文の体言止め {limit} 文まで
|
|
51
51
|
en: up to {limit} noun-ending sentences in the body
|
|
@@ -3,7 +3,7 @@ layer: L3
|
|
|
3
3
|
status: stable
|
|
4
4
|
how_to_find: topic-predicate-distance
|
|
5
5
|
requires: [pos]
|
|
6
|
-
extra_word_lists: [topic-clause-close, statute-article-opener]
|
|
6
|
+
extra_word_lists: [topic-clause-close, statute-article-opener, topic-adverb]
|
|
7
7
|
languages: [ja]
|
|
8
8
|
severity: info
|
|
9
9
|
|
|
@@ -45,8 +45,8 @@ example:
|
|
|
45
45
|
来週は、新しい担当者の紹介、先月から続く予算の見直し、春の本社移転の準備、秋の採用計画の確認、年末の懇親会の段取りを話し合います。そのため定例会議は二時間に延長します。
|
|
46
46
|
|
|
47
47
|
not_flagged:
|
|
48
|
-
ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題に移る文か、直後に名前の新しい主題(〜ましたが、赤澤大臣は…)が立って文末まで続く文、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」(語は語彙表 topic-clause-close
|
|
49
|
-
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 (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが 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 name as a new topic that runs to the end (〜ましたが、赤澤大臣は…); 〜ことから, 〜つつ, 〜としても or 〜こととし 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 〜来てほしいのは日本であったという調査の結果、…), the count stops at that clause's end. A later clause's subject may be a part, as in 〜のほとんどは. When a は that sets the time or the case (今夜は, 当日は, 〜ときは) is followed by another topic, the count starts from that topic. 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.
|
|
48
|
+
ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題に移る文か、直後に名前の新しい主題(〜ましたが、赤澤大臣は…)が立って文末まで続く文、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」(語は語彙表 topic-clause-close)、述語の後ろに丸数字の番号(③)が来て一行に詰まった箇条の次の項目が始まるところ、「〜のは」の主題が「という」で名詞に掛かる節の中で繋辞の述語を得て、その名詞句が読点で終わるところ(〜来てほしいのは日本であったという調査の結果、…))は、その節の終わりまでを数えます。後ろの節の主語には「〜のほとんどは」も数えます。副詞になる「は」(最後は=結局のところ。語は語彙表 topic-adverb)は主題と読みません。前に名詞や「の」が付けば(交渉の最後は)主題です。時や場面を言う「は」(今夜は、当日は、〜ときは)の後ろに別の主題があれば、その主題から数えます。法令でも契約でもない文書が条文をそのまま載せた文(「第7条 …」、形は語彙表 statute-article-opener)は、書き手が直せる文ではないので数えません。英語の文書には使いません。
|
|
49
|
+
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 (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが 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 name as a new topic that runs to the end (〜ましたが、赤澤大臣は…); 〜ことから, 〜つつ, 〜としても or 〜こととし 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 〜来てほしいのは日本であったという調査の結果、…), 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. 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.
|
|
50
50
|
level_meaning:
|
|
51
51
|
ja: 主題から述語まで {limit} 字まで
|
|
52
52
|
en: up to {limit} characters between the topic and the predicate
|
|
@@ -9,8 +9,8 @@ name:
|
|
|
9
9
|
en: Unbalanced bracket
|
|
10
10
|
|
|
11
11
|
why:
|
|
12
|
-
ja: 閉じ忘れた「(」や、開きの無い「」」があると、読み手はどこまでが括弧の中なのか分からなくなります。全角の「(」を半角の「)」で閉じるのも、書き換えの途中で残った印です。見出しで区切った節ごとに、「」『』()()[][]【】〔〕〈〉《》“” と半角の 「」 の組を数えます。詩の連や長い引用は段落をまたぐので、段落を越えて組にします。行の頭や空白の後ろの「1)」「a)」「事例)」のような三文字までの番号の印と数の後ろの「)」、括弧の中の番号の印(「(…以下、事例5)まで同じ。)」の「事例5)」。同じ字の印を行の頭でも使っていて、同じ行の後ろの閉じで括弧が閉じるときに限る)、コードと URL
|
|
13
|
-
en: A "(" never closed, or a ")" never opened, leaves the reader unsure where the aside ends. A full-width "(" closed by a half-width ")" is left over from an edit too. Brackets are paired within each section under a heading ((), [], “”, and the Japanese 「」『』()[]【】〔〕〈〉《》), across paragraphs, since a stanza or a long quotation may span several. A short label of up to three characters such as "1)", "a)" or "iv)" at the start of a line or after a space, a ")" right after a number, a numbered label inside an aside ("A3)" in "(see the notes; A3) and more)", when the same label is used at the start of a line and later closes on the same line still close the aside), code, URLs, and an opening bracket quoted as the last character of a quotation (「取締役(」, as statutes quote the text they amend) are not counted. An opening quotation mark carried into a paragraph that opens with the same mark, as in fiction, is not counted.
|
|
12
|
+
ja: 閉じ忘れた「(」や、開きの無い「」」があると、読み手はどこまでが括弧の中なのか分からなくなります。全角の「(」を半角の「)」で閉じるのも、書き換えの途中で残った印です。見出しで区切った節ごとに、「」『』()()[][]【】〔〕〈〉《》“” と半角の 「」 の組を数えます。詩の連や長い引用は段落をまたぐので、段落を越えて組にします。行の頭や空白の後ろの「1)」「a)」「事例)」のような三文字までの番号の印と数の後ろの「)」、括弧の中の番号の印(「(…以下、事例5)まで同じ。)」の「事例5)」。同じ字の印を行の頭でも使っていて、同じ行の後ろの閉じで括弧が閉じるときに限る)、コードと URL、引用の閉じのすぐ前の開き(法令の読替えの「取締役(」とあるのは)は数えません。英語の小説のように、次の段落も同じ開きで始まるなら、閉じない開きは続きとして数えません。詩の引用のように二行以上を続けて行の頭の同じ引用符で開き直し、終わりで一度だけ閉じるものも、続きとして数えません。
|
|
13
|
+
en: A "(" never closed, or a ")" never opened, leaves the reader unsure where the aside ends. A full-width "(" closed by a half-width ")" is left over from an edit too. Brackets are paired within each section under a heading ((), [], “”, and the Japanese 「」『』()[]【】〔〕〈〉《》), across paragraphs, since a stanza or a long quotation may span several. A short label of up to three characters such as "1)", "a)" or "iv)" at the start of a line or after a space, a ")" right after a number, a numbered label inside an aside ("A3)" in "(see the notes; A3) and more)", when the same label is used at the start of a line and later closes on the same line still close the aside), code, URLs, and an opening bracket quoted as the last character of a quotation (「取締役(」, as statutes quote the text they amend) are not counted. An opening quotation mark carried into a paragraph that opens with the same mark, as in fiction, is not counted, nor is a quotation of verse that reopens with the same mark at the start of two or more lines in a row and closes once at the end.
|
|
14
14
|
|
|
15
15
|
message:
|
|
16
16
|
ja: 「{mark}」が組になっていません
|
|
@@ -52,5 +52,5 @@ example:
|
|
|
52
52
|
The plan (see below) is ready.
|
|
53
53
|
|
|
54
54
|
not_flagged:
|
|
55
|
-
ja: 行の頭や空白の後ろの「1)」「a)」「事例)」のような三文字までの番号の印、数の後ろの「)」、行の頭でも使う番号の印を括弧の中に書いたもの(「以下、事例5)まで同じ。」)、コードと URL
|
|
56
|
-
en: Labels of up to three characters such as "1)" or "a)" at the start of a line or after a space, a ")" right after a number, a numbered label also used at the start of a line, written inside an aside ("(see the notes; A3) and more)"), code and URLs are not counted. A bracket closed in a later paragraph,
|
|
55
|
+
ja: 行の頭や空白の後ろの「1)」「a)」「事例)」のような三文字までの番号の印、数の後ろの「)」、行の頭でも使う番号の印を括弧の中に書いたもの(「以下、事例5)まで同じ。」)、コードと URL は数えません。段落をまたいで閉じる括弧と、次の段落を同じ引用符で始める台詞、行ごとに同じ引用符で開き直して終わりで一度だけ閉じる詩の引用も指しません。小数と単位の間の引用符はインチの印(.015 “Hg)として数えません。半角の「「」」も鉤括弧として組にし、全角との幅の違い(「…」)は hankaku-kana に任せます。
|
|
56
|
+
en: Labels of up to three characters such as "1)" or "a)" at the start of a line or after a space, a ")" right after a number, a numbered label also used at the start of a line, written inside an aside ("(see the notes; A3) and more)"), code and URLs are not counted. A bracket closed in a later paragraph, a quotation carried into a paragraph that opens with the same mark, and verse quoted with the same mark reopening each line and one close at the end, are not reported. A curly quote between a decimal number and a unit is an inch mark (".015 “Hg") and is not counted. Half-width 「」 pair as Japanese brackets too; a width difference against 「」 (「…」) is left to hankaku-kana.
|
|
@@ -68,6 +68,8 @@ by_genre:
|
|
|
68
68
|
business: { strict: 1, normal: 2, relaxed: 5 }
|
|
69
69
|
speech: { strict: 1, normal: 2, relaxed: 5 }
|
|
70
70
|
docs/faq: { strict: 1, normal: 1, relaxed: 3 }
|
|
71
|
+
# 手引きも、日常の略語(HR)を数えなくなってから judged corpus で測り直して下げた。
|
|
72
|
+
docs/manual: { strict: 1, normal: 2, relaxed: 5 }
|
|
71
73
|
|
|
72
74
|
use_for: [business, technical, legal, docs, academic, literature, speech]
|
|
73
75
|
off_for:
|
|
@@ -53,8 +53,8 @@ example:
|
|
|
53
53
|
Report an incident within 30 minutes and notify the affected teams. Record it in the incident log and fix the cause by the next working day.
|
|
54
54
|
|
|
55
55
|
not_flagged:
|
|
56
|
-
ja: 文書の長さに対して少ないものは指しません。短すぎる文書も測りません。指すのは語のある文ごとに一度で、長い言い方の中の語(in a timely manner の timely)は一つと数えます。英語の法務の文書では、法律や慣行が意味を決めている言い方(reasonable、best efforts、from time to time)の中の語は数えません。要求の文の中の「可能な限り」「必要に応じて」は、要求の書き方として requirement-smell も見ます。すぐ後ろの括弧で中身を書いた語(一定の事項(請求書に書く事項))も数えません。括弧が名前を付けるだけ(以下「本措置」という。)なら数えます。目次の見出しの下の行(節の名前)は数えません。英語の reasonable accommodation
|
|
57
|
-
en: 'A few vague words for the document''s length are not reported, and very short documents are not measured. Each sentence is reported once, and a word inside a longer phrase ("timely" in "in a timely manner") counts once. In legal documents, a word inside a term that law and practice define ("reasonable", "best efforts", "from time to time") is not counted. Inside a requirement, requirement-smell also reads "where possible" and "as needed". A word that the bracket right after it pins down ("a reasonable fee (USD 50)") is not counted either; a bracket that only names it ("(hereinafter the ""Fee"")") pins nothing down. Lines under a table of contents heading (the sections'' names) are not counted, and "reasonable accommodation" is the name of a legal duty in any genre.'
|
|
56
|
+
ja: 文書の長さに対して少ないものは指しません。短すぎる文書も測りません。指すのは語のある文ごとに一度で、長い言い方の中の語(in a timely manner の timely)は一つと数えます。英語の法務の文書では、法律や慣行が意味を決めている言い方(reasonable、best efforts、from time to time)の中の語は数えません。要求の文の中の「可能な限り」「必要に応じて」は、要求の書き方として requirement-smell も見ます。すぐ後ろの括弧で中身を書いた語(一定の事項(請求書に書く事項))も数えません。括弧が名前を付けるだけ(以下「本措置」という。)なら数えます。目次の見出しの下の行(節の名前)は数えません。英語の reasonable accommodation は、どのジャンルでも法律が決めた義務の名前なので数えません。英語で、すぐ後ろに法律や条を名指す語が続くもの(as required by applicable law、as required under 45 CFR §164.528、as required under HIPAA)は、何が要るのかをその法律が決めているので数えません。当事者が決めるもの(as required by Licensor)は数えます。
|
|
57
|
+
en: 'A few vague words for the document''s length are not reported, and very short documents are not measured. Each sentence is reported once, and a word inside a longer phrase ("timely" in "in a timely manner") counts once. In legal documents, a word inside a term that law and practice define ("reasonable", "best efforts", "from time to time") is not counted. Inside a requirement, requirement-smell also reads "where possible" and "as needed". A word that the bracket right after it pins down ("a reasonable fee (USD 50)") is not counted either; a bracket that only names it ("(hereinafter the ""Fee"")") pins nothing down. Lines under a table of contents heading (the sections'' names) are not counted, and "reasonable accommodation" is the name of a legal duty in any genre. A word that a law or a section governs right after it ("as required by applicable law", "as required under 45 CFR §164.528", "as required under HIPAA") is not counted, since that law says what is required; one a party decides ("as required by Licensor") is.'
|
|
58
58
|
level_meaning:
|
|
59
59
|
ja: 1000 字あたりあいまいな語 {limit} 個まで
|
|
60
60
|
en: up to {limit} vague words per 1000 words
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Token } from "./plugin.ts";
|
|
2
2
|
|
|
3
|
-
const touches = (left: Token | undefined, right: Token | undefined): boolean =>
|
|
3
|
+
export const touches = (left: Token | undefined, right: Token | undefined): boolean =>
|
|
4
|
+
left !== undefined && right !== undefined && left.span.end === right.span.start;
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* 前の語と組んで一つの名前になる語(敬って呼ぶ語の皆様、置き場所を言う語の下)の直前の助詞で、組んだ名前がさらに同じ助詞で次の語に
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Token } from "./plugin.ts";
|
|
2
|
+
import { touches } from "./bound-word-particles.ts";
|
|
3
|
+
|
|
4
|
+
// Particles that look like a link of a nesting chain (の) but do not nest a noun in a noun, and the predicates that
|
|
5
|
+
// close a chain. Pure.
|
|
6
|
+
|
|
7
|
+
/** The counted particles (particles) written straight after a word that only picks out which ones (他の: words). */
|
|
8
|
+
export const determinerParticles = (tokens: readonly Token[], particles: readonly string[], words: readonly string[]): ReadonlySet<Token> =>
|
|
9
|
+
new Set(tokens.filter((token, at) => particles.includes(token.surface) && touches(tokens[at - 1], token) && words.includes(tokens[at - 1]?.surface ?? "")));
|
|
10
|
+
|
|
11
|
+
/** A verb that ends a clause: in its dictionary form (定める) or followed by an auxiliary (つい of ついた), not a stem that starts a compound noun (繰下げ of 繰下げ受給). */
|
|
12
|
+
const endsClause = (verb: Token, after: Token | undefined): boolean => verb.pos === "VERB" && (verb.surface === verb.lemma || after?.pos === "AUX");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The verbs written straight after a counted particle (番号のついた版): that の marks the subject of a clause as が would,
|
|
16
|
+
* and the clause ends at its verb, so the noun after it starts a new phrase. The の itself still counts, in the phrase before.
|
|
17
|
+
*/
|
|
18
|
+
export const clauseEnds = (tokens: readonly Token[], particles: readonly string[]): ReadonlySet<Token> =>
|
|
19
|
+
new Set(
|
|
20
|
+
tokens.filter((token, at) => endsClause(token, tokens[at + 1]) && particles.includes(tokens[at - 1]?.surface ?? "") && touches(tokens[at - 1], token)),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const endsBetween = (left: Token, right: Token, ends: ReadonlySet<Token>): boolean =>
|
|
24
|
+
[...ends].some((verb) => verb.span.start >= left.span.end && verb.span.end <= right.span.start);
|
|
25
|
+
|
|
26
|
+
/** The most particles of a run (in order) that no clause end (ends) falls between: 2 for 特定の番号の|ついた版の. 0 for none. */
|
|
27
|
+
export const longestClausePart = (run: readonly Token[], ends: ReadonlySet<Token>): number =>
|
|
28
|
+
run.reduce<{ readonly current: number; readonly longest: number }>(
|
|
29
|
+
(acc, token, at) => {
|
|
30
|
+
const previous = run[at - 1];
|
|
31
|
+
const current = previous !== undefined && endsBetween(previous, token, ends) ? 1 : acc.current + 1;
|
|
32
|
+
return { current, longest: Math.max(acc.longest, current) };
|
|
33
|
+
},
|
|
34
|
+
{ current: 0, longest: 0 },
|
|
35
|
+
).longest;
|
|
@@ -113,11 +113,19 @@ const nameLineDefinitions = (source: string): string[] => {
|
|
|
113
113
|
.filter((initials) => initials !== "");
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 文中の書式のタグ(<span id="13.18">**"GDPR"**</span> means)。読み手には見えず、語と定義の語の間を空けない。表の欄や段落のタグは
|
|
118
|
+
* 区切りなので外さない。
|
|
119
|
+
*/
|
|
120
|
+
const INLINE_TAG = /<\/?(?:span|a|b|strong|em|i|u|mark|small|abbr|dfn)(?:\s[^<>\n]{0,200})?>/giu;
|
|
121
|
+
|
|
116
122
|
/** 文書が括弧の展開の形をとらずに定義した略語。 */
|
|
117
|
-
export const statedAcronyms = (source: string, words: DefinitionStatementWords): ReadonlySet<string> =>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
...
|
|
121
|
-
...
|
|
122
|
-
...
|
|
123
|
+
export const statedAcronyms = (source: string, words: DefinitionStatementWords): ReadonlySet<string> => {
|
|
124
|
+
const text = source.replaceAll(INLINE_TAG, "");
|
|
125
|
+
return new Set([
|
|
126
|
+
...statementDefinitions(text, words.statements),
|
|
127
|
+
...labelDefinitions(text),
|
|
128
|
+
...markedDefinitions(text, words.markers),
|
|
129
|
+
...nameLineDefinitions(text),
|
|
123
130
|
]);
|
|
131
|
+
};
|
|
@@ -120,7 +120,13 @@ const isNamedBeforeAt = (body: string, acronym: string, at: number): boolean =>
|
|
|
120
120
|
*/
|
|
121
121
|
export type DefinitionWords = { readonly markers: readonly string[]; readonly verbs: readonly string[]; readonly alternatives?: readonly string[] };
|
|
122
122
|
|
|
123
|
-
type DefinitionPatterns = {
|
|
123
|
+
type DefinitionPatterns = {
|
|
124
|
+
readonly opened: RegExp;
|
|
125
|
+
readonly closes: RegExp;
|
|
126
|
+
readonly alternative: RegExp;
|
|
127
|
+
readonly quotedAlternative: RegExp;
|
|
128
|
+
readonly otherName: RegExp;
|
|
129
|
+
};
|
|
124
130
|
|
|
125
131
|
const oneOf = (words: readonly string[]): string => (words.length === 0 ? "(?!)" : words.map(escapeRegExp).join("|"));
|
|
126
132
|
|
|
@@ -128,6 +134,7 @@ const definitionPatterns = (words: DefinitionWords): DefinitionPatterns => ({
|
|
|
128
134
|
opened: new RegExp(String.raw`[((]\s*(?<markers>(?:(?:${oneOf(words.markers)})${MARKER_GAP})*)${WRAP}(?<![A-Za-z])$`, "iu"),
|
|
129
135
|
closes: new RegExp(String.raw`^${WRAP}(?<verb>(?:${oneOf(words.verbs)})[。.]?)?${WRAP}[))]`, "iu"),
|
|
130
136
|
alternative: new RegExp(String.raw`[,,、]\s*(?:${oneOf(words.alternatives ?? [])})\s*["“'‘]?$`, "iu"),
|
|
137
|
+
quotedAlternative: new RegExp(String.raw`(?<=["”'’])\s(?:${oneOf(words.alternatives ?? [])})\s*["“'‘]?$`, "iu"),
|
|
131
138
|
otherName: new RegExp(String.raw`^${WRAP}[,,、]?\s*(?:${oneOf(words.alternatives ?? [])})\s[^()()\n]{1,${String(DEFINITION_REACH)}}[))]`, "iu"),
|
|
132
139
|
});
|
|
133
140
|
|
|
@@ -244,13 +251,25 @@ const isPrefixedAt = (body: string, acronym: string, at: number): boolean => {
|
|
|
244
251
|
/** 引用符で囲んで書き終えた名前(‘abstract syntax tree’)。小文字の語でも、囲みが名前の始まりと終わりを決める。 */
|
|
245
252
|
const QUOTED_NAME_END = /(?:“(?<curly>[^“”\n]{1,60})”|‘(?<single>[^‘’\n]{1,60})’|"(?<straight>[^"\n]{1,60})")$/u;
|
|
246
253
|
|
|
247
|
-
|
|
254
|
+
const quotedNameBefore = (name: string): string | undefined => {
|
|
255
|
+
const groups = QUOTED_NAME_END.exec(name)?.groups;
|
|
256
|
+
return groups?.["curly"] ?? groups?.["single"] ?? groups?.["straight"];
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 名前の後ろの読点と言い換えの語に続く略語(Special Interest Groups, or SIGs、‘abstract syntax tree’, or ‘AST’)。名前の頭文字が略語と揃うときだけ。
|
|
261
|
+
* 引用符で囲んだ名前なら読点が無くてもよい(“subject matter experts” or SME)。囲みが名前の終わりを決める。
|
|
262
|
+
*/
|
|
248
263
|
const isAlternativeAt = (patterns: DefinitionPatterns, body: string, acronym: string, at: number): boolean => {
|
|
249
|
-
const
|
|
250
|
-
|
|
264
|
+
const before = body.slice(Math.max(0, at - DEFINITION_REACH), at);
|
|
265
|
+
const joined = patterns.alternative.exec(before);
|
|
266
|
+
if (joined === null) {
|
|
267
|
+
const quotedJoin = patterns.quotedAlternative.exec(before);
|
|
268
|
+
const quoted = quotedJoin === null ? undefined : quotedNameBefore(body.slice(0, at - quotedJoin[0].length));
|
|
269
|
+
return quoted !== undefined && namesAcronym(quoted, acronym);
|
|
270
|
+
}
|
|
251
271
|
const name = body.slice(0, at - joined[0].length);
|
|
252
|
-
const
|
|
253
|
-
const quoted = groups?.["curly"] ?? groups?.["single"] ?? groups?.["straight"];
|
|
272
|
+
const quoted = quotedNameBefore(name);
|
|
254
273
|
return spellsOut(name, acronym) || (quoted !== undefined && namesAcronym(quoted, acronym));
|
|
255
274
|
};
|
|
256
275
|
|
|
@@ -363,7 +382,7 @@ const CLOSING_FENCE = /^ {0,3}(?<fence>`{3,}|~{3,})\s*$/u;
|
|
|
363
382
|
const closes = (line: string, open: string): boolean => CLOSING_FENCE.exec(line)?.groups?.["fence"]?.startsWith(open) === true;
|
|
364
383
|
|
|
365
384
|
/** コードの囲みの中の行(開き・閉じの行も)を空にする。閉じるのは同じ記号で、開きと同じか長い並び。 */
|
|
366
|
-
const withoutFences = (lines: readonly string[]): string[] =>
|
|
385
|
+
export const withoutFences = (lines: readonly string[]): string[] =>
|
|
367
386
|
lines.reduce<FenceScan>(
|
|
368
387
|
(scan, line) => {
|
|
369
388
|
const fence = FENCE.exec(line)?.groups?.["fence"];
|
|
@@ -36,11 +36,16 @@ export const spelledOutAcronyms = (sentences: readonly string[], mentions: reado
|
|
|
36
36
|
.flatMap((sentence) => (sentence.match(ACRONYM) ?? []).filter((acronym) => spellsOutInWords(sentence, acronym))),
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
+
/** Capitals and a plural s (CRs): the plural of a shorter acronym (CR), not the longer one (CRS) set in other capitals. */
|
|
40
|
+
const PLURAL_OF_CAPITALS = /^\p{Lu}+s$/u;
|
|
41
|
+
|
|
39
42
|
/** The other ways the text capitalises an acronym (TCoP for TCOP, TCOP for TCoP), each with two capitals or more. */
|
|
40
43
|
export const caseVariantsIn = (text: string, acronym: string): string[] => {
|
|
41
44
|
const written = new RegExp(String.raw`(?<![\p{L}\p{N}])${escapeRegExp(acronym)}(?![\p{L}\p{N}])`, "giu");
|
|
42
45
|
const variants = [...text.matchAll(written)].map((match) => match[0]);
|
|
43
|
-
return [...new Set(variants)].filter(
|
|
46
|
+
return [...new Set(variants)].filter(
|
|
47
|
+
(variant) => variant !== acronym && (variant.match(CAPITAL) ?? []).length >= MIN_CAPITALS && !PLURAL_OF_CAPITALS.test(variant),
|
|
48
|
+
);
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
/** A name in capitals that the text also writes as a word is that word set in capitals; short capitals (IT, It) are left alone. */
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { withoutFences } from "./acronym-expansion.ts";
|
|
2
|
+
|
|
3
|
+
/** 箇条書きの項目の行。字下げの幅と、印の後ろの文。 */
|
|
4
|
+
const LIST_ITEM = /^(?<indent>[ \t]*)(?:[-*+]|\d+[.)])\s+(?<text>(?:\S.*)?)$/u;
|
|
5
|
+
const ITEM_ACRONYM = /(?<![\p{L}\p{N}_&])(?<acronym>[A-Z]{2,10})s?(?![\p{L}\p{N}_&])/gu;
|
|
6
|
+
/** 親の項目の名前の語の短さの下限。of や to の頭文字は、2 字の略語にたまたま揃いやすい。 */
|
|
7
|
+
const MIN_PARENT_WORD = 3;
|
|
8
|
+
|
|
9
|
+
type ListItem = { readonly text: string; readonly children: string };
|
|
10
|
+
|
|
11
|
+
const indentOf = (line: string): number => (/^[ \t]*/u.exec(line)?.[0] ?? "").length;
|
|
12
|
+
|
|
13
|
+
/** at から始まる項目の、自分の文(続きの行も)と、それより深く字下げした子の項目の文。 */
|
|
14
|
+
const itemAt = (lines: readonly string[], at: number): ListItem | undefined => {
|
|
15
|
+
const item = LIST_ITEM.exec(lines[at] ?? "")?.groups;
|
|
16
|
+
if (item === undefined) return undefined;
|
|
17
|
+
const indent = (item["indent"] ?? "").length;
|
|
18
|
+
const endIndex = lines.findIndex((line, index) => index > at && line.trim() !== "" && indentOf(line) <= indent);
|
|
19
|
+
const block = lines.slice(at + 1, endIndex === -1 ? lines.length : endIndex);
|
|
20
|
+
const firstChild = block.findIndex((line) => LIST_ITEM.test(line));
|
|
21
|
+
const own = firstChild === -1 ? block : block.slice(0, firstChild);
|
|
22
|
+
const children = firstChild === -1 ? [] : block.slice(firstChild);
|
|
23
|
+
return { text: [item["text"] ?? "", ...own].join(" "), children: children.join("\n") };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** リンクの行き先と URL。アドレスの語(…/cross-project-council/…)は、書き手が書いた名前ではない。 */
|
|
27
|
+
const LINK_TARGET = /\]\([^()\s]*\)/gu;
|
|
28
|
+
const BARE_URL = /\bhttps?:\/\/\S+/gu;
|
|
29
|
+
|
|
30
|
+
const withoutAddresses = (text: string): string => text.replace(LINK_TARGET, "]").replace(BARE_URL, " ");
|
|
31
|
+
|
|
32
|
+
/** 文の中に、略語の文字を頭文字に持つ語が続けて並ぶか(product owner → PO)。大文字小文字を問わず、短い語は数えない。 */
|
|
33
|
+
const spelledByRun = (text: string, acronym: string): boolean => {
|
|
34
|
+
const letters = [...acronym.toLowerCase()];
|
|
35
|
+
const words =
|
|
36
|
+
withoutAddresses(text)
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.match(/\p{L}+/gu) ?? [];
|
|
39
|
+
const runStartsAt = (start: number): boolean =>
|
|
40
|
+
letters.every((letter, offset) => {
|
|
41
|
+
const word = words[start + offset] ?? "";
|
|
42
|
+
return word.length >= MIN_PARENT_WORD && word.startsWith(letter);
|
|
43
|
+
});
|
|
44
|
+
return words.some((_, start) => runStartsAt(start));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 子の項目で使う略語のうち、親の項目がその名前を書き出しているもの(- **No product owner:** … の下の - Unavailable PO: …)。
|
|
49
|
+
* 入れ子の箇条書きでは、親の項目が子の項目の話題を名指すので、親の語の頭文字が略語と揃えば展開と読む。
|
|
50
|
+
*/
|
|
51
|
+
export const parentItemAcronyms = (source: string): ReadonlySet<string> => {
|
|
52
|
+
const lines = withoutFences(source.split(/\r?\n/u));
|
|
53
|
+
return new Set(
|
|
54
|
+
lines.flatMap((_, index) => {
|
|
55
|
+
const item = itemAt(lines, index);
|
|
56
|
+
if (item === undefined || item.children === "") return [];
|
|
57
|
+
return [...item.children.matchAll(ITEM_ACRONYM)].map((match) => match.groups?.["acronym"] ?? "").filter((acronym) => spelledByRun(item.text, acronym));
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -68,6 +68,21 @@ const REFERENCE_LIKE = /(?<![\\A-Za-z0-9_\]])\[([^[\]\n]+)\]\[([^[\]\n]*)\]/gu;
|
|
|
68
68
|
/** 数だけの括弧([1][2]、[3, 4])は、参照の記法ではなく文献の番号を並べたもの。 */
|
|
69
69
|
const CITATION_NUMBERS = /^[\d\s,,、–-]+$/u;
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* ファイルの種類と大きさの札([PDF:47KB]、[PDFファイル/269KB]、[Excel 28 KB])。役所のページがリンクの後ろに書く添え書きで、
|
|
73
|
+
* 写すと字のまま残る。名前の定義で呼ぶ参照の記法ではない。
|
|
74
|
+
*/
|
|
75
|
+
const FILE_SIZE = /^\d[\d.,]*\s*(?:[KMGT]i?B|bytes?|バイト)$/iu;
|
|
76
|
+
const FILE_TYPE_PREFIX = /^\p{L}[\p{L}\p{N}]*(?:\s*[:://、,,]\s*|\s+)/u;
|
|
77
|
+
|
|
78
|
+
const isFileSizeLabel = (text: string): boolean => {
|
|
79
|
+
if (FILE_SIZE.test(text)) return true;
|
|
80
|
+
const prefix = FILE_TYPE_PREFIX.exec(text)?.[0];
|
|
81
|
+
return prefix !== undefined && FILE_SIZE.test(text.slice(prefix.length));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const fileSizeLabel = (match: RegExpMatchArray): boolean => isFileSizeLabel(match[1] ?? "") || isFileSizeLabel(match[2] ?? "");
|
|
85
|
+
|
|
71
86
|
/** 画像の参照(`![alt][label]`)の頭の印。指摘の範囲に含める。 */
|
|
72
87
|
const IMAGE_MARK = "!";
|
|
73
88
|
|
|
@@ -118,6 +133,7 @@ export const unresolvedReferences = (source: string, markup: Markup): Span[] =>
|
|
|
118
133
|
return markup.texts.flatMap((text) =>
|
|
119
134
|
[...source.slice(text.start, text.end).matchAll(REFERENCE_LIKE)]
|
|
120
135
|
.filter((match) => !CITATION_NUMBERS.test(match[1] ?? "") && !siteDefinedImage(source, text.start + match.index, match[2] ?? ""))
|
|
136
|
+
.filter((match) => !fileSizeLabel(match))
|
|
121
137
|
.filter((match) => !CHARACTER_CLASS.test(match[1] ?? "") && !CHARACTER_CLASS.test(match[2] ?? "") && !bookDefined(match[2] ?? ""))
|
|
122
138
|
.map((match) => ({ start: text.start + match.index, end: text.start + match.index + match[0].length }))
|
|
123
139
|
.map((span) => (imageAt(source, span.start) ? { start: span.start - 1, end: span.end } : span)),
|
|
@@ -42,3 +42,33 @@ export const citationLead = (text: string, signals: readonly string[]): string |
|
|
|
42
42
|
const lastSignal = pattern === undefined ? undefined : [...beforeYear.matchAll(pattern)].at(-1);
|
|
43
43
|
return (lastSignal === undefined ? beforeYear : beforeYear.slice(0, lastSignal.index)).trim();
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
/** The same marks of a publication, every one of them: where an earlier reference in the text ends. */
|
|
47
|
+
const PUBLICATION_MARKS_ALL: readonly RegExp[] = PUBLICATION_MARKS.map((mark) => new RegExp(mark.source, "gu"));
|
|
48
|
+
|
|
49
|
+
const LEADING_SEPARATOR = /^[\s;,.]*(?:and\s+)?/u;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The lead without the tail of an earlier reference it begins inside (…Discussion Series 2020-069 (Washington: Board of
|
|
53
|
+
* Governors, August); and Ben S. Bernanke, …): a splitter that cut inside a reference list hands over the end of one
|
|
54
|
+
* reference before the next one's authors. What follows the last mark of a publication is kept.
|
|
55
|
+
*/
|
|
56
|
+
export const withoutEarlierReference = (lead: string): string => {
|
|
57
|
+
const ends = PUBLICATION_MARKS_ALL.flatMap((mark) => [...lead.matchAll(mark)].map((match) => match.index + match[0].length));
|
|
58
|
+
return ends.length === 0
|
|
59
|
+
? lead
|
|
60
|
+
: lead
|
|
61
|
+
.slice(Math.max(...ends))
|
|
62
|
+
.replace(LEADING_SEPARATOR, "")
|
|
63
|
+
.trim();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** One author as a reference list in the Vancouver style writes them: a surname, then the initials (Kreimer AR, Gail MH, Cyr JT). */
|
|
67
|
+
const AUTHOR = String.raw`\p{Lu}[\p{L}'’-]*\p{Ll}[\p{L}'’-]*(?: \p{Lu}[\p{L}'’-]*\p{Ll}[\p{L}'’-]*)* \p{Lu}{1,3}`;
|
|
68
|
+
/** Fewer authors in a row than this are a sentence naming people, not the author list of a reference. */
|
|
69
|
+
const MIN_AUTHORS = 3;
|
|
70
|
+
const AUTHOR_LIST = new RegExp(String.raw`(?<!\p{L})${AUTHOR}(?:, ${AUTHOR}){${MIN_AUTHORS - 1},}(?!\p{L})`, "gu");
|
|
71
|
+
|
|
72
|
+
/** The words an author list (Kreimer AR, Porras C, Liu D, …) adds beyond one: the authors of a reference, not the writer's sentence. */
|
|
73
|
+
export const authorListSaving = (text: string): number =>
|
|
74
|
+
[...text.matchAll(AUTHOR_LIST)].reduce((saving, match) => saving + match[0].split(/\s+/u).length - 1, 0);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { nameSpans } from "../compare/proper-nouns.ts";
|
|
1
2
|
import { proseText } from "../measure.ts";
|
|
2
3
|
import type { Detector, Finding, ProseDocument, Section, Sentence } from "../plugin.ts";
|
|
3
4
|
import {
|
|
5
|
+
distinctiveNames,
|
|
4
6
|
evidenceSpans,
|
|
7
|
+
namesAsEvidence,
|
|
5
8
|
hasNumeral,
|
|
6
9
|
isClaim,
|
|
7
10
|
isConditionHeading,
|
|
@@ -9,6 +12,7 @@ import {
|
|
|
9
12
|
isNavigationLine,
|
|
10
13
|
startsWithin,
|
|
11
14
|
statesIntent,
|
|
15
|
+
withSubsections,
|
|
12
16
|
type AdviceWords,
|
|
13
17
|
type IntentWords,
|
|
14
18
|
} from "./concrete-evidence.ts";
|
|
@@ -18,7 +22,7 @@ import { letteredIndexEntries } from "./lettered-index.ts";
|
|
|
18
22
|
* 具体物の密度。数値・コード・リンク・引用が 1 つも無い節は、
|
|
19
23
|
* 読み終えても何も持ち帰れない。**少ないほうを指摘する**ので、他の密度 rule と向きが逆。
|
|
20
24
|
*/
|
|
21
|
-
const CONCRETE = /\d|`|https
|
|
25
|
+
const CONCRETE = /\d|`|https?:\/\/|(?<![/\\\w.-])[A-Za-z][A-Za-z\d-]+\.[a-z]{2,}\b/u;
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* 見出しのない導入部は、書き出しで呼ぶ。文書の言葉なので、message がどの言語でも混ざらない。
|
|
@@ -35,6 +39,10 @@ const openingOf = (sentence: Sentence | undefined, unit: ProseDocument["lengthUn
|
|
|
35
39
|
|
|
36
40
|
const hasNumeralIn = (section: Section): boolean => section.sentences.some((sentence) => hasNumeral(sentence.tokens ?? []));
|
|
37
41
|
|
|
42
|
+
/** 数字・コード・リンク・ドメイン名が書かれているか、数の語があるか。 */
|
|
43
|
+
const concreteIn = (doc: ProseDocument, section: Section): boolean =>
|
|
44
|
+
CONCRETE.test(doc.source.slice(section.span.start, section.span.end)) || hasNumeralIn(section) || startsWithin(section.span, doc.links);
|
|
45
|
+
|
|
38
46
|
/** これより短い節は、具体物があるべきか判断できない。 */
|
|
39
47
|
const MIN_SENTENCES = 3;
|
|
40
48
|
|
|
@@ -75,12 +83,15 @@ export const concreteEvidence: Detector = (doc, options): Finding[] => {
|
|
|
75
83
|
mostlyClaims(sentences, doc.language, advice, intent)
|
|
76
84
|
);
|
|
77
85
|
});
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
);
|
|
81
|
-
//
|
|
82
|
-
const
|
|
83
|
-
|
|
86
|
+
const families = new Map(sections.map((section) => [section, withSubsections(doc.sections, section)]));
|
|
87
|
+
const familyOf = (section: Section): Section[] => families.get(section) ?? [section];
|
|
88
|
+
const bare = sections.filter((section) => familyOf(section).every((member) => !concreteIn(doc, member)));
|
|
89
|
+
// 構造の木と名前は求めるのに手間がかかる。指摘に届かない文書では求めない。
|
|
90
|
+
const spans =
|
|
91
|
+
bare.length < options.limit
|
|
92
|
+
? []
|
|
93
|
+
: [...evidenceSpans(doc.structure), ...namesAsEvidence(distinctiveNames(doc.sentences, nameSpans(doc)), doc.source, doc.sections)];
|
|
94
|
+
const empty = bare.filter((section) => familyOf(section).every((member) => !startsWithin(member.span, spans)));
|
|
84
95
|
if (empty.length < options.limit) return [];
|
|
85
96
|
return empty.map((section) => ({
|
|
86
97
|
rule: "concrete-evidence-density",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Sentence, Span, StructureKind, StructureNode, Token } from "../plugin.ts";
|
|
1
|
+
import type { Section, Sentence, Span, StructureKind, StructureNode, Token } from "../plugin.ts";
|
|
2
2
|
import { preOrder } from "../tree-walk.ts";
|
|
3
3
|
import { isStatement } from "./technical-docs.ts";
|
|
4
4
|
|
|
@@ -146,3 +146,58 @@ export const isNavigationLine = (sentence: Pick<Sentence, "text">, lines: readon
|
|
|
146
146
|
|
|
147
147
|
/** 条件を並べる節の見出し(Requirements、応募資格)。並ぶのは条件で、裏づけを求める主張ではない。 */
|
|
148
148
|
export const isConditionHeading = (heading: string, headings: readonly string[]): boolean => headings.includes(bareLine(heading));
|
|
149
|
+
|
|
150
|
+
/** 節と、その下の節(続く、見出しがより深い節)。親の節の本文は短い導入で、中身は下の節にある。導入部(深さ 0)は親ではない。 */
|
|
151
|
+
export const withSubsections = <T extends Pick<Section, "depth">>(sections: readonly T[], section: T): T[] => {
|
|
152
|
+
const index = sections.indexOf(section);
|
|
153
|
+
const after = index === -1 ? [] : sections.slice(index + 1);
|
|
154
|
+
const next = section.depth === 0 ? 0 : after.findIndex((other) => other.depth <= section.depth);
|
|
155
|
+
return [section, ...(next === -1 ? after : after.slice(0, next))];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/** 大文字だけの略語(API、PDFs)。どの文書にも出る技術の語で、名指しした物ではない。 */
|
|
159
|
+
const ACRONYM = /^\p{Lu}+s?$/u;
|
|
160
|
+
const CAPITAL_HEAD = /^\p{Lu}/u;
|
|
161
|
+
const WORD = /\p{L}/u;
|
|
162
|
+
|
|
163
|
+
/** 一字の語(e-Tax の e)は、名前の切れ端。 */
|
|
164
|
+
const MIN_NAME_CHARS = 2;
|
|
165
|
+
|
|
166
|
+
/** 名前と読んだ語のうち、ふつうの語の大文字書き(Timeline、Changes)・強調(NEVER)・略語・切れ端でないもの。 */
|
|
167
|
+
const isDistinctiveName = (token: Token): boolean =>
|
|
168
|
+
token.pos === "PROPN" &&
|
|
169
|
+
token.features?.["OrdinaryWord"] !== "Yes" &&
|
|
170
|
+
token.features?.["Emph"] !== "Yes" &&
|
|
171
|
+
!ACRONYM.test(token.surface) &&
|
|
172
|
+
Array.from(token.surface).length >= MIN_NAME_CHARS;
|
|
173
|
+
|
|
174
|
+
/** 大文字で始まる文頭の語は、名前と区別がつかない(Chimneys)。大文字の無い文字(日本語)の文頭は名前のまま読む。 */
|
|
175
|
+
const distinctiveIn = (sentence: Pick<Sentence, "tokens">): Span[] => {
|
|
176
|
+
const tokens = sentence.tokens ?? [];
|
|
177
|
+
const head = tokens.find((token) => WORD.test(token.surface));
|
|
178
|
+
const skipped = head !== undefined && CAPITAL_HEAD.test(head.surface) ? head : undefined;
|
|
179
|
+
return tokens.filter((token) => token !== skipped && isDistinctiveName(token)).map((token) => token.span);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** 固有の名前(KubeCon、GitHub、大阪城ホール)の範囲。ふつうの語・略語・文頭の語だけでできた名前は除く。 */
|
|
183
|
+
export const distinctiveNames = (sentences: readonly Pick<Sentence, "tokens">[], names: readonly Span[]): Span[] => {
|
|
184
|
+
const distinctive = sentences.flatMap(distinctiveIn);
|
|
185
|
+
return names.filter((name) => startsWithin(name, distinctive));
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** 名前が書かれた節の数がこの割合に届くなら、文書の主題(Kubernetes、Rust)で、その節が持ち帰らせる具体物ではない。 */
|
|
189
|
+
const SUBJECT_SHARE = 0.5;
|
|
190
|
+
|
|
191
|
+
const indexOfSection = (sections: readonly Pick<Section, "span">[], at: number): number =>
|
|
192
|
+
sections.findIndex((section) => at >= section.span.start && at < section.span.end);
|
|
193
|
+
|
|
194
|
+
/** 固有の名前(KubeCon、GitHub)のうち、節の具体物として数えるもの。文書の半分以上の節に書かれた名前は主題なので除く。 */
|
|
195
|
+
export const namesAsEvidence = (names: readonly Span[], source: string, sections: readonly Pick<Section, "span">[]): Span[] => {
|
|
196
|
+
const keyOf = (span: Span): string => source.slice(span.start, span.end).toLowerCase();
|
|
197
|
+
const sectionsOf = new Map<string, Set<number>>();
|
|
198
|
+
names.forEach((name) => {
|
|
199
|
+
const index = indexOfSection(sections, name.start);
|
|
200
|
+
if (index !== -1) sectionsOf.set(keyOf(name), (sectionsOf.get(keyOf(name)) ?? new Set<number>()).add(index));
|
|
201
|
+
});
|
|
202
|
+
return names.filter((name) => (sectionsOf.get(keyOf(name))?.size ?? 0) < sections.length * SUBJECT_SHARE);
|
|
203
|
+
};
|