@chaffjs/lang-ja 0.35.0 → 0.37.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/english-run.d.ts.map +1 -1
- package/dist/english-run.js +2 -1
- package/dist/english-run.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/initial-stop.d.ts +23 -0
- package/dist/initial-stop.d.ts.map +1 -0
- package/dist/initial-stop.js +33 -0
- package/dist/initial-stop.js.map +1 -0
- package/dist/list-line.d.ts +12 -1
- package/dist/list-line.d.ts.map +1 -1
- package/dist/list-line.js +79 -11
- package/dist/list-line.js.map +1 -1
- package/dist/pos.d.ts.map +1 -1
- package/dist/pos.js +7 -1
- package/dist/pos.js.map +1 -1
- package/dist/quoted-line-stop.d.ts +4 -0
- package/dist/quoted-line-stop.d.ts.map +1 -0
- package/dist/quoted-line-stop.js +18 -0
- package/dist/quoted-line-stop.js.map +1 -0
- package/lexicons/abbreviation-mention.yaml +9 -0
- package/lexicons/addressee-prefix.yaml +6 -0
- package/lexicons/addressee-title.yaml +35 -0
- package/lexicons/adversative-ga-causal.yaml +11 -0
- package/lexicons/adversative-ga-prefatory.yaml +27 -0
- package/lexicons/alternative-clause-label.yaml +7 -0
- package/lexicons/asker-heading.yaml +14 -0
- package/lexicons/bracket-annotation.yaml +8 -0
- package/lexicons/bracket-width.yaml +6 -0
- package/lexicons/case-party-joiner.yaml +7 -0
- package/lexicons/cited-title-action.yaml +13 -0
- package/lexicons/common-acronym.yaml +7 -1
- package/lexicons/comparative-baseline.yaml +8 -1
- package/lexicons/comparison-marker.yaml +7 -0
- package/lexicons/count-hedge.yaml +5 -0
- package/lexicons/defined-term-group-suffix.yaml +6 -0
- package/lexicons/demonstrative-not-opener.yaml +14 -0
- package/lexicons/empty-intensifier.yaml +2 -0
- package/lexicons/final-period.yaml +27 -0
- package/lexicons/fixed-name-ending.yaml +22 -0
- package/lexicons/headnote-heading.yaml +9 -0
- package/lexicons/honorific-group.yaml +9 -0
- package/lexicons/humble-own-act.yaml +15 -0
- package/lexicons/kanji-known-word.yaml +14 -0
- package/lexicons/licence-word.yaml +7 -0
- package/lexicons/line-head-tag.yaml +10 -0
- package/lexicons/link-label-ending.yaml +11 -0
- package/lexicons/list-conjunction.yaml +13 -0
- package/lexicons/list-note-lead.yaml +2 -0
- package/lexicons/list-suffix.yaml +6 -0
- package/lexicons/necessity-purpose.yaml +13 -0
- package/lexicons/neutral-request.yaml +9 -0
- package/lexicons/newsletter-issue.yaml +10 -0
- package/lexicons/ngram-fixed-ending.yaml +9 -0
- package/lexicons/notice-header.yaml +10 -0
- package/lexicons/numbering-counter.yaml +13 -0
- package/lexicons/organisation-unit.yaml +2 -0
- package/lexicons/orthographic-variant-comparative.yaml +8 -0
- package/lexicons/orthographic-variant-conjunction.yaml +4 -0
- package/lexicons/orthographic-variant-distinct.yaml +5 -0
- package/lexicons/orthographic-variant-idiom.yaml +3 -0
- package/lexicons/orthographic-variant-judging.yaml +11 -0
- package/lexicons/orthographic-variant-katakana-sense.yaml +8 -0
- package/lexicons/orthographic-variant-two-readings.yaml +14 -0
- package/lexicons/orthographic-variant-voice.yaml +8 -0
- package/lexicons/orthographic-variant-whole-word.yaml +6 -0
- package/lexicons/placeholder-division.yaml +8 -0
- package/lexicons/placeholder-word.yaml +63 -1
- package/lexicons/prepositive-abbreviation.yaml +9 -0
- package/lexicons/quoted-wording-cue.yaml +14 -0
- package/lexicons/range-kana-unit.yaml +16 -0
- package/lexicons/reference-prefix.yaml +12 -0
- package/lexicons/rejected-wording.yaml +18 -0
- package/lexicons/relative-start.yaml +8 -0
- package/lexicons/request-deadline-section.yaml +12 -0
- package/lexicons/request-prohibition.yaml +9 -0
- package/lexicons/requirement-open-end.yaml +8 -0
- package/lexicons/sentence-start-word.yaml +59 -0
- package/lexicons/spelling-mention.yaml +9 -0
- package/lexicons/superlative-owner.yaml +6 -0
- package/lexicons/superlative-phrase.yaml +13 -0
- package/lexicons/superlative-suffix.yaml +5 -0
- package/lexicons/telling-cue.yaml +12 -0
- package/lexicons/term-source-marker.yaml +11 -0
- package/lexicons/title-ending.yaml +13 -1
- package/package.json +1 -1
- package/src/english-run.ts +2 -1
- package/src/index.ts +13 -4
- package/src/initial-stop.ts +58 -0
- package/src/list-line.ts +102 -13
- package/src/pos.ts +14 -1
- package/src/quoted-line-stop.ts +20 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# 雛形の空欄の括弧に書く語。【会社名】【氏名】。括弧の中がこの語そのものか、この語で始まって空白が続くときに数える。
|
|
2
|
-
#
|
|
2
|
+
# 例として置く「○○」は正しい書き方なので入れない(官公庁の文書は記入例に使う)。宛名・署名・金額・日付の位置の伏せ字は下の blank-* の組で数える。
|
|
3
3
|
id: placeholder-word
|
|
4
4
|
language: ja
|
|
5
5
|
entries:
|
|
@@ -38,6 +38,68 @@ entries:
|
|
|
38
38
|
# group: instruction — 丸括弧の中の、書き手に向けた指示の書き出し((ここに会社名を書く))。丸括弧は、ほかの語では空欄と数えない。
|
|
39
39
|
- pattern: ここに
|
|
40
40
|
group: instruction
|
|
41
|
+
# group: blank-suffix / blank-prefix / blank-unit — 伏せ字(〇〇、△△)が空欄になる位置。手紙やメールの宛名・署名・金額・日付に
|
|
42
|
+
# 残った伏せ字は埋め忘れ。文の中で例に置いた「○○」(○○株式会社作成など)は数えないので、ビジネス文書の種類だけで数える。
|
|
43
|
+
# 後ろに付く語(〇〇様、〇〇部)。〇〇さんは例に挙げた人(「○○さんが…」と声を掛け)にも使うので入れない。
|
|
44
|
+
- pattern: 様
|
|
45
|
+
group: blank-suffix
|
|
46
|
+
genres: [business]
|
|
47
|
+
- pattern: 殿
|
|
48
|
+
group: blank-suffix
|
|
49
|
+
genres: [business]
|
|
50
|
+
- pattern: 御中
|
|
51
|
+
group: blank-suffix
|
|
52
|
+
genres: [business]
|
|
53
|
+
- pattern: 株式会社
|
|
54
|
+
group: blank-suffix
|
|
55
|
+
genres: [business]
|
|
56
|
+
- pattern: 部
|
|
57
|
+
group: blank-suffix
|
|
58
|
+
genres: [business]
|
|
59
|
+
- pattern: 課
|
|
60
|
+
group: blank-suffix
|
|
61
|
+
genres: [business]
|
|
62
|
+
# 前に付く語(株式会社〇〇、総務部の〇〇、署名の「営業部 〇〇」)。
|
|
63
|
+
- pattern: 株式会社
|
|
64
|
+
group: blank-prefix
|
|
65
|
+
genres: [business]
|
|
66
|
+
- pattern: 有限会社
|
|
67
|
+
group: blank-prefix
|
|
68
|
+
genres: [business]
|
|
69
|
+
- pattern: 合同会社
|
|
70
|
+
group: blank-prefix
|
|
71
|
+
genres: [business]
|
|
72
|
+
- pattern: 部の
|
|
73
|
+
group: blank-prefix
|
|
74
|
+
genres: [business]
|
|
75
|
+
- pattern: 課の
|
|
76
|
+
group: blank-prefix
|
|
77
|
+
genres: [business]
|
|
78
|
+
- pattern: 部
|
|
79
|
+
group: blank-prefix
|
|
80
|
+
genres: [business]
|
|
81
|
+
- pattern: 課
|
|
82
|
+
group: blank-prefix
|
|
83
|
+
genres: [business]
|
|
84
|
+
# 数の代わりの伏せ字に付く単位(月額〇万円、2026年〇月〇日、〇か月)。行頭の「○」は箇条書きの印なので数えない。
|
|
85
|
+
- pattern: 万円
|
|
86
|
+
group: blank-unit
|
|
87
|
+
genres: [business]
|
|
88
|
+
- pattern: 円
|
|
89
|
+
group: blank-unit
|
|
90
|
+
genres: [business]
|
|
91
|
+
- pattern: か月
|
|
92
|
+
group: blank-unit
|
|
93
|
+
genres: [business]
|
|
94
|
+
- pattern: ヶ月
|
|
95
|
+
group: blank-unit
|
|
96
|
+
genres: [business]
|
|
97
|
+
- pattern: 月
|
|
98
|
+
group: blank-unit
|
|
99
|
+
genres: [business]
|
|
100
|
+
- pattern: 日
|
|
101
|
+
group: blank-unit
|
|
102
|
+
genres: [business]
|
|
41
103
|
# group: template — 見出しにあれば、その節が雛形だと言う語(「## 雛形」「# 記入例」)。
|
|
42
104
|
# その見出しの下(同じ深さか浅い次の見出しまで)の空欄は雛形の役目なので数えない。
|
|
43
105
|
- pattern: 雛形
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 名前の前に形容詞として立つ、点の付いた大文字の略語(U.S. Census Bureau、U.K. Parliament)。文頭の語ではない大文字の語の
|
|
2
|
+
# 前では、点で文が終わらない。日本語の文書の中の英文も同じ分割器で切るので、英語と同じ語を置く。字面どおりに照らす。
|
|
3
|
+
id: prepositive-abbreviation
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: U.S.
|
|
7
|
+
- pattern: U.K.
|
|
8
|
+
- pattern: U.N.
|
|
9
|
+
- pattern: E.U.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# かぎ括弧に入れた語が、定義した語の使い直しではなく、条文や文書の文言を引いたものだと分かる語(defined-term-form)。
|
|
2
|
+
# group before は開きかぎ括弧のすぐ前で終わる語(憲法一九条にいう「良心の自由」、第1項1号の「特定居住用宅地等」)。
|
|
3
|
+
# group after は閉じかぎ括弧のすぐ後ろ(並べた引用の後ろ)で始まる語(「謝罪」の文言、「謝罪」、「陳謝」という文言)。
|
|
4
|
+
id: quoted-wording-cue
|
|
5
|
+
language: ja
|
|
6
|
+
entries:
|
|
7
|
+
- { pattern: にいう, group: before }
|
|
8
|
+
- { pattern: にいわゆる, group: before }
|
|
9
|
+
- { pattern: 条の, group: before }
|
|
10
|
+
- { pattern: 項の, group: before }
|
|
11
|
+
- { pattern: 号の, group: before }
|
|
12
|
+
- { pattern: の文言, group: after }
|
|
13
|
+
- { pattern: という文言, group: after }
|
|
14
|
+
- { pattern: との文言, group: after }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 仮名で始まる単位や程度の語(3-5か月、約3-5つ、3-5ほど)。漢字の語に詰めて書いた番号の後ろに仮名が続けば文書の番号
|
|
2
|
+
# (直資4-5ほか)と読むが、この語が続くなら範囲として読む(range-notation-consistency)。字面どおりに照らす。
|
|
3
|
+
id: range-kana-unit
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: か月
|
|
7
|
+
- pattern: かげつ
|
|
8
|
+
- pattern: か所
|
|
9
|
+
- pattern: か国
|
|
10
|
+
- pattern: か年
|
|
11
|
+
- pattern: か条
|
|
12
|
+
- pattern: つ
|
|
13
|
+
- pattern: ほど
|
|
14
|
+
- pattern: くらい
|
|
15
|
+
- pattern: ぐらい
|
|
16
|
+
- pattern: まで
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 前に書いたもの(または後に書くもの)を指して語の頭に付く語(上記暗号資産交換業者、当該保険契約)。
|
|
2
|
+
# max-kanji-continuous は、漢字の連なりの頭にこの語があり、解析が別の語に分けたときは、この語を数えない。
|
|
3
|
+
id: reference-prefix
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: 上記
|
|
7
|
+
- pattern: 下記
|
|
8
|
+
- pattern: 前記
|
|
9
|
+
- pattern: 後記
|
|
10
|
+
- pattern: 当該
|
|
11
|
+
- pattern: 前述
|
|
12
|
+
- pattern: 後述
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 鉤括弧で引いた言い方のすぐ後ろに来て、その言い方を「書かない」と退ける語(「風雨が強い」とはせずに、…)。「X」とは、の定義に
|
|
2
|
+
# 見えても定義ではないので、unused-definition はその語を指さない。字面どおりに照らす。
|
|
3
|
+
id: rejected-wording
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: とはせず
|
|
7
|
+
- pattern: とはしない
|
|
8
|
+
- pattern: とは書かず
|
|
9
|
+
- pattern: とは書かない
|
|
10
|
+
- pattern: とは言わず
|
|
11
|
+
- pattern: とは言わない
|
|
12
|
+
- pattern: とはいわず
|
|
13
|
+
- pattern: とはいわない
|
|
14
|
+
# 「X」とは言えない・とは限らない も、その語に当たらないと言っていて、定義ではない。
|
|
15
|
+
- pattern: とは言え
|
|
16
|
+
- pattern: とはいえ
|
|
17
|
+
- pattern: とは限ら
|
|
18
|
+
- pattern: とは呼べ
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 文書の締め切りを一度だけ書く節の見出し(それだけで書いた見出し)。その節に締め切りの語と日付があれば、文書の中の
|
|
2
|
+
# 依頼はどれもその締め切りを持つ。見出し全体と比べる(終わりの「:」は除く)。
|
|
3
|
+
id: request-deadline-section
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: 日程
|
|
7
|
+
- pattern: 期限
|
|
8
|
+
- pattern: 締切
|
|
9
|
+
- pattern: 締め切り
|
|
10
|
+
- pattern: 提出期限
|
|
11
|
+
- pattern: 応募期限
|
|
12
|
+
- pattern: 募集期間
|
|
@@ -25,3 +25,11 @@ entries:
|
|
|
25
25
|
- { pattern: 場合, group: scope-condition }
|
|
26
26
|
- { pattern: 際, group: scope-condition }
|
|
27
27
|
- { pattern: とき, group: scope-condition }
|
|
28
|
+
# group: scope-topic は、述語で終わる節が説明する名詞のすぐ後ろの「は」(…を行う個人間融資は)。一覧はその名詞の説明の中にあって、
|
|
29
|
+
# 要求が何についてかを言っているだけで、果たす義務の中にはない。「は」の後ろに読点があるときだけ。
|
|
30
|
+
# group: scope-nominal は、その名詞が行い自体を名指すとき(提出することは、提出する義務は)。一覧は義務の中にある。
|
|
31
|
+
- { pattern: は, group: scope-topic }
|
|
32
|
+
- { pattern: こと, group: scope-nominal }
|
|
33
|
+
- { pattern: 義務, group: scope-nominal }
|
|
34
|
+
- { pattern: 責任, group: scope-nominal }
|
|
35
|
+
- { pattern: 必要, group: scope-nominal }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# 文の頭に立ち、姓にはならない英語の機能語。大文字と点の頭文字の後ろ(Regulation C. The Guide、Appendix B. In 2020)では、
|
|
2
|
+
# 点で文が終わる。日本語の文書の中の英文も同じ分割器で切るので、英語と同じ語を置く。字面どおりに照らす。
|
|
3
|
+
id: sentence-start-word
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: The
|
|
7
|
+
- pattern: This
|
|
8
|
+
- pattern: That
|
|
9
|
+
- pattern: These
|
|
10
|
+
- pattern: Those
|
|
11
|
+
- pattern: A
|
|
12
|
+
- pattern: An
|
|
13
|
+
- pattern: It
|
|
14
|
+
- pattern: Its
|
|
15
|
+
- pattern: In
|
|
16
|
+
- pattern: On
|
|
17
|
+
- pattern: At
|
|
18
|
+
- pattern: For
|
|
19
|
+
- pattern: From
|
|
20
|
+
- pattern: With
|
|
21
|
+
- pattern: By
|
|
22
|
+
- pattern: As
|
|
23
|
+
- pattern: If
|
|
24
|
+
- pattern: When
|
|
25
|
+
- pattern: While
|
|
26
|
+
- pattern: Although
|
|
27
|
+
- pattern: However
|
|
28
|
+
- pattern: Thus
|
|
29
|
+
- pattern: Therefore
|
|
30
|
+
- pattern: We
|
|
31
|
+
- pattern: They
|
|
32
|
+
- pattern: He
|
|
33
|
+
- pattern: She
|
|
34
|
+
- pattern: You
|
|
35
|
+
- pattern: Our
|
|
36
|
+
- pattern: Their
|
|
37
|
+
- pattern: There
|
|
38
|
+
- pattern: Here
|
|
39
|
+
- pattern: Each
|
|
40
|
+
- pattern: Every
|
|
41
|
+
- pattern: All
|
|
42
|
+
- pattern: Some
|
|
43
|
+
- pattern: Many
|
|
44
|
+
- pattern: Most
|
|
45
|
+
- pattern: But
|
|
46
|
+
- pattern: And
|
|
47
|
+
- pattern: So
|
|
48
|
+
- pattern: Yet
|
|
49
|
+
- pattern: Also
|
|
50
|
+
- pattern: Then
|
|
51
|
+
- pattern: After
|
|
52
|
+
- pattern: Before
|
|
53
|
+
- pattern: Under
|
|
54
|
+
- pattern: To
|
|
55
|
+
- pattern: Such
|
|
56
|
+
- pattern: What
|
|
57
|
+
- pattern: Which
|
|
58
|
+
- pattern: How
|
|
59
|
+
- pattern: Why
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# 最上級を含むが、何かが一番だと言ってはいない決まった言い方。最上級がこの中にあれば unqualified-superlative は指さない。
|
|
2
|
+
# 職名・機関名(最高裁判所・最高経営責任者)は名前。「最も近い」「最も遠い」は書いている場所からの距離。
|
|
3
|
+
id: superlative-phrase
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: 最高裁判所
|
|
7
|
+
- pattern: 最高裁
|
|
8
|
+
- pattern: 最高検察庁
|
|
9
|
+
- pattern: 最高指揮官
|
|
10
|
+
- pattern: 最高責任者
|
|
11
|
+
- pattern: 最高経営責任者
|
|
12
|
+
- pattern: 最も近い
|
|
13
|
+
- pattern: 最も遠い
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 引用した言葉を、誰がいつ言ったかを名指す語。「申し込んだら、「…」と言われています」「業者から「…」と言われている」の
|
|
2
|
+
# 「と言われている」は、名前の無い大勢の説ではなく、その場で相手から言われた言葉。weasel-word はこの形の言い回しを指さない。
|
|
3
|
+
# group: occasion は引用より前のどこかにあれば、言われた場面を名指す(〜たら、・〜ところ、)。group: sayer は引用の直前に
|
|
4
|
+
# あれば、言った人を名指す(業者から「)。
|
|
5
|
+
id: telling-cue
|
|
6
|
+
language: ja
|
|
7
|
+
entries:
|
|
8
|
+
- { pattern: たら、, group: occasion }
|
|
9
|
+
- { pattern: だら、, group: occasion }
|
|
10
|
+
- { pattern: ところ、, group: occasion }
|
|
11
|
+
- { pattern: から, group: sayer }
|
|
12
|
+
- { pattern: より, group: sayer }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# 語の前に置いて、その語の意味がどこで決まっているかを言う言葉(措置法69条の3所定の小規模宅地等、同法2条に規定する事業者)。
|
|
2
|
+
# この言葉に続く語は、出どころを示して書いた所なので、後で同じ語を定義しても、定義より前の使用に数えない(use-before-definition)。
|
|
3
|
+
id: term-source-marker
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: 所定の
|
|
7
|
+
- pattern: に規定する
|
|
8
|
+
- pattern: に規定される
|
|
9
|
+
- pattern: に規定された
|
|
10
|
+
- pattern: に定める
|
|
11
|
+
- pattern: に定められた
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
# 題の置き方(括弧の中身を閉じる、すぐ後ろに補いの括弧が付く、文がその連なりだけ、見出しにある)をしていれば、
|
|
3
3
|
# 書き手が選んだ複合語ではなく、変えられない名前(大阪市鶴見区役所公募型比較見積実施要綱、国家公務員中途採用者選考試験)。
|
|
4
4
|
# 閉じる語は語の切れ目で始まり、前に 2 字以上の語が要る(解決方法の「法」、本事業は当たらない)。
|
|
5
|
-
#
|
|
5
|
+
# 文の中で使っただけの連なり(情報処理推進機構認定試験の受験者)は、文書のどこかで題として置かれているか、
|
|
6
|
+
# 文書の中で同じ連なりを繰り返していなければ数える。法令・制度・給付の名前は、置き方を問わない fixed-name-ending にもある。
|
|
7
|
+
# 会合・会同・演習・窓口は催しや受け付けの名前(G7仙台科学技術大臣会合、自衛隊高級幹部会同、区役所就学事務担当窓口)、
|
|
8
|
+
# 戦略・基金・審議会・協議会・機構は計画や機関の名前(保険契約者保護機構)。
|
|
6
9
|
id: title-ending
|
|
7
10
|
language: ja
|
|
8
11
|
entries:
|
|
@@ -32,3 +35,12 @@ entries:
|
|
|
32
35
|
- pattern: 届出書
|
|
33
36
|
- pattern: 報告書
|
|
34
37
|
- pattern: 証明書
|
|
38
|
+
- pattern: 会合
|
|
39
|
+
- pattern: 会同
|
|
40
|
+
- pattern: 演習
|
|
41
|
+
- pattern: 窓口
|
|
42
|
+
- pattern: 戦略
|
|
43
|
+
- pattern: 基金
|
|
44
|
+
- pattern: 審議会
|
|
45
|
+
- pattern: 協議会
|
|
46
|
+
- pattern: 機構
|
package/package.json
CHANGED
package/src/english-run.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 漢字だけなら含んでよい(英文の中の「東京」)。仮名があれば和文の一部と読む。
|
|
5
5
|
*/
|
|
6
6
|
const KANA = /[\p{Script=Hiragana}\p{Script=Katakana}]/u;
|
|
7
|
-
|
|
7
|
+
/** 全角の英字(TEL)は和文の組み方で、英文は使わない。英字に数えない。 */
|
|
8
|
+
const LATIN = /(?![A-Za-z])\p{Script=Latin}/gu;
|
|
8
9
|
const LETTER = /\p{L}/gu;
|
|
9
10
|
// 英文の文末。閉じ括弧・引用符が続いてよい。断片の末尾だけを見る。
|
|
10
11
|
const ENGLISH_STOP_AT_END = /[.?!][)\]"'”’]{0,3}$/u;
|
package/src/index.ts
CHANGED
|
@@ -5,11 +5,13 @@ import { isEnglishBoundary, isEnglishRun } from "./english-run.ts";
|
|
|
5
5
|
import { unmarkNumberStops } from "./number-stop.ts";
|
|
6
6
|
import { pairMixedWidthBrackets } from "./mixed-width-bracket.ts";
|
|
7
7
|
import { labelStops, unmarkLabelStops } from "./label-stop.ts";
|
|
8
|
+
import { initialStops, unmarkInitialStops } from "./initial-stop.ts";
|
|
8
9
|
import { splitAtQuotedStops } from "./quoted-stop.ts";
|
|
9
10
|
import { reattachClosingQuotes } from "./closing-quote.ts";
|
|
11
|
+
import { splitAtQuotedLineEnds } from "./quoted-line-stop.ts";
|
|
10
12
|
import { insideBrackets, startsWithCloser } from "./inside-brackets.ts";
|
|
11
13
|
import { structure } from "./structure.ts";
|
|
12
|
-
import { cutAtBreaks, listItemHeads, listLineBreaks, startsListItem } from "./list-line.ts";
|
|
14
|
+
import { cutAtBreaks, lineVocabulary, listItemHeads, listLineBreaks, startsListItem } from "./list-line.ts";
|
|
13
15
|
import { listItemHeads as englishListItemHeads, listLineBreaks as englishListLineBreaks } from "./english-list-line.ts";
|
|
14
16
|
import { isReady, predicateOnly, prepare, readsAsCounter, readsAsOneAdverb, readsAsOneWord, tokenize } from "./pos.ts";
|
|
15
17
|
import { markSpacedCounters } from "./spaced-counter.ts";
|
|
@@ -59,7 +61,7 @@ const merge = (source: string, spans: readonly Span[]): Sentence[] => {
|
|
|
59
61
|
const open = insideBrackets(source);
|
|
60
62
|
// 英文だけの段落は英語のアダプタと同じに切る(項目の印も英語の読み方で)。行頭の「J.」は人名の頭文字で、項目の印ではない。
|
|
61
63
|
const english = isEnglishRun(source);
|
|
62
|
-
const listBreaks = english ? englishListLineBreaks(source) : listLineBreaks(source);
|
|
64
|
+
const listBreaks = english ? englishListLineBreaks(source) : listLineBreaks(source, LINE_VOCABULARY);
|
|
63
65
|
const itemHeads = english ? englishListItemHeads(source) : listItemHeads(source);
|
|
64
66
|
return spans
|
|
65
67
|
.reduce<Span[]>((acc, span) => {
|
|
@@ -101,16 +103,23 @@ const withTokens = (source: string, sentences: readonly Sentence[]): Sentence[]
|
|
|
101
103
|
}));
|
|
102
104
|
};
|
|
103
105
|
|
|
106
|
+
const patternsOf = (id: string): string[] => (LEXICONS[id] ?? []).map((entry) => entry.pattern);
|
|
107
|
+
const LINE_VOCABULARY = lineVocabulary(patternsOf("numbering-counter"), patternsOf("line-head-tag"));
|
|
108
|
+
|
|
104
109
|
const LABEL_STOPS = labelStops((LEXICONS["abbreviated-label"] ?? []).map((entry) => entry.pattern));
|
|
110
|
+
const INITIAL_STOPS = initialStops(
|
|
111
|
+
(LEXICONS["sentence-start-word"] ?? []).map((entry) => entry.pattern),
|
|
112
|
+
(LEXICONS["prepositive-abbreviation"] ?? []).map((entry) => entry.pattern),
|
|
113
|
+
);
|
|
105
114
|
|
|
106
115
|
/**
|
|
107
116
|
* 英語のアダプタと同じ手当てを英文にも当てる。番号の前の略した名前(FIG. 1)の点で切らず、
|
|
108
117
|
* 英文の閉じ引用符の内側の句点で切り、文頭に取り残された閉じ引用符を前の文へ戻す。
|
|
109
118
|
*/
|
|
110
119
|
const spansOf = (text: string): Span[] => {
|
|
111
|
-
const spans = sentenceSpans(pairMixedWidthBrackets(unmarkNumberStops(unmarkLabelStops(text, LABEL_STOPS))));
|
|
120
|
+
const spans = sentenceSpans(pairMixedWidthBrackets(unmarkInitialStops(unmarkNumberStops(unmarkLabelStops(text, LABEL_STOPS)), INITIAL_STOPS)));
|
|
112
121
|
const quotedStops = spans.flatMap((span) => (isEnglishRun(text.slice(span.start, span.end)) ? splitAtQuotedStops(text, span) : [span]));
|
|
113
|
-
return reattachClosingQuotes(text, quotedStops);
|
|
122
|
+
return reattachClosingQuotes(text, quotedStops).flatMap((span) => splitAtQuotedLineEnds(text, span));
|
|
114
123
|
};
|
|
115
124
|
|
|
116
125
|
export const adapter: LanguageAdapter = {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// lang-en/src/initial-stop.ts の写し。アダプタは互いに依存しないので、和文の中の英文に同じ手当てをするために置く。元とのずれは test_mixed_language_stops.ts で比べる。
|
|
2
|
+
import { escapeRegExp } from "./regexp.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* sentence-splitter reads a capital and a full stop as an initial and never ends a sentence there: "Regulation C. The
|
|
6
|
+
* Guide applies" and "Appendix B. In 2020 …" were one sentence. It also ends a sentence after an abbreviation such as
|
|
7
|
+
* "U.S." before any capital, so "the U.S. Census Bureau" was two. Both are decided by the word after the full stop:
|
|
8
|
+
* - capitals with full stops (C., D.C.) before a sentence-start-word (The, In) end the sentence. Their capitals are
|
|
9
|
+
* replaced with a plain letter, which the splitter does not read as an initial;
|
|
10
|
+
* - a prepositive abbreviation (U.S.) before any other capitalised word does not end it, unless a comma follows that
|
|
11
|
+
* word ("in the U.S. Yesterday, …"). Its last full stop is replaced with a letter;
|
|
12
|
+
* - capitals with full stops (J., U.K.) before a word in lower case ("J. meacham", "Hart, K. and J. Reed") do not end
|
|
13
|
+
* it, since no sentence opens in lower case. A word that is lower case only at its head (iPhone) may be a name that
|
|
14
|
+
* opens one, so it is left out. Their last full stop is replaced with a letter.
|
|
15
|
+
* The length does not change, so the spans fit the original text. Initials first on their line are a list's labels
|
|
16
|
+
* (A. The first item) and are left as they are.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type InitialStops = { readonly ends: RegExp | undefined; readonly joins: RegExp | undefined };
|
|
20
|
+
|
|
21
|
+
const EDGE_BEFORE = String.raw`(?<![\p{L}\p{N}_.'’])`;
|
|
22
|
+
const WORD_END = String.raw`(?![\p{L}\p{N}_.'’-])`;
|
|
23
|
+
const PLAIN_LETTER = "n";
|
|
24
|
+
const CAPITAL = /\p{Lu}/gu;
|
|
25
|
+
const BEFORE_LOWER_CASE = new RegExp(String.raw`${EDGE_BEFORE}(?:\p{Lu}\.){1,3}(?=[ \t\r\n]+\p{Ll}(?!\p{Lu}))`, "gu");
|
|
26
|
+
|
|
27
|
+
const oneOf = (words: readonly string[]): string => `(?:${words.map(escapeRegExp).join("|")})`;
|
|
28
|
+
|
|
29
|
+
/** Built once from the lexicons. */
|
|
30
|
+
export const initialStops = (startWords: readonly string[], prepositive: readonly string[]): InitialStops => {
|
|
31
|
+
if (startWords.length === 0) return { ends: undefined, joins: undefined };
|
|
32
|
+
const start = String.raw`\s+${oneOf(startWords)}${WORD_END}`;
|
|
33
|
+
const ends = new RegExp(String.raw`${EDGE_BEFORE}(?:\p{Lu}\.){1,3}(?=${start})`, "gu");
|
|
34
|
+
if (prepositive.length === 0) return { ends, joins: undefined };
|
|
35
|
+
return { ends, joins: new RegExp(String.raw`${EDGE_BEFORE}${oneOf(prepositive)}(?=\s+\p{Lu})(?!${start})(?!\s+\p{Lu}\p{L}*,)`, "gu") };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Only a list's marker, or nothing, before the initials on their line (A. The first item; - B. The second item). */
|
|
39
|
+
const LABEL_HEAD = /^[ \t]*(?:[-*+•][ \t]+)?$/u;
|
|
40
|
+
|
|
41
|
+
const lineStartOf = (text: string, index: number): number => Math.max(text.lastIndexOf("\n", index - 1), text.lastIndexOf("\r", index - 1)) + 1;
|
|
42
|
+
|
|
43
|
+
const isFirstOnLine = (text: string, index: number): boolean => LABEL_HEAD.test(text.slice(lineStartOf(text, index), index));
|
|
44
|
+
|
|
45
|
+
const withoutLastStop = (abbreviation: string): string => `${abbreviation.slice(0, -1)}${PLAIN_LETTER}`;
|
|
46
|
+
|
|
47
|
+
/** Initials before a word in lower case, not first on their line (a list's label stays as it is), rewritten. */
|
|
48
|
+
const joinedBeforeLowerCase = (text: string): string =>
|
|
49
|
+
text.replace(BEFORE_LOWER_CASE, (initials: string, index: number) => (isFirstOnLine(text, index) ? initials : withoutLastStop(initials)));
|
|
50
|
+
|
|
51
|
+
/** The text with every initial that ends a sentence, and every prepositive abbreviation or initial that does not, rewritten. */
|
|
52
|
+
export const unmarkInitialStops = (text: string, stops: InitialStops): string => {
|
|
53
|
+
const ended =
|
|
54
|
+
stops.ends === undefined
|
|
55
|
+
? text
|
|
56
|
+
: text.replace(stops.ends, (initials: string, index: number) => (isFirstOnLine(text, index) ? initials : initials.replace(CAPITAL, PLAIN_LETTER)));
|
|
57
|
+
return joinedBeforeLowerCase(stops.joins === undefined ? ended : ended.replace(stops.joins, withoutLastStop));
|
|
58
|
+
};
|
package/src/list-line.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Span } from "chaffjs/plugin";
|
|
2
|
+
import { escapeRegExp } from "./regexp.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 空行を挟まず 1 行に 1 項目を並べた箇条書き(「①誓約書」「・〜に関する業務」「(1)学歴:…」、`<br>` で改めた行)。
|
|
@@ -6,6 +7,9 @@ import type { Span } from "chaffjs/plugin";
|
|
|
6
7
|
*
|
|
7
8
|
* 切るのは、印で始まる行の前と後ろの改行。ただし前の行が読点で終わるか、括弧を開いたまま終わるなら、文は次の行へ続いている。
|
|
8
9
|
* 印の無い行の折り返しは切らない。
|
|
10
|
+
*
|
|
11
|
+
* 番号だけの札の行(「第1」「第3条」)と、行頭の括弧で囲んだ札(「(別添)…」)も、印で始まる行と同じに切る。札の語は辞書から取る。
|
|
12
|
+
* URL だけの行、欄の行(電話:…、〒…)、括弧の語だけの行も、文の途中に立っていなければ前後で切る(メールマガジンや連絡先の欄)。
|
|
9
13
|
*/
|
|
10
14
|
|
|
11
15
|
const SPACE = "[ \\t\\u3000]";
|
|
@@ -52,26 +56,111 @@ const linesOf = (text: string): Line[] => {
|
|
|
52
56
|
});
|
|
53
57
|
};
|
|
54
58
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
/**
|
|
60
|
+
* 注記の印(「※」)。前の行に添える注記で、前の行の文を終えるとは限らない(「ファックス番号:…\n※送ったらご連絡ください。」)。
|
|
61
|
+
* 注記は折り返して次の行へ続くこともあるので、注記の行の前と後ろでは文を改めない。ただし注記の行が並べば、その間で改める。
|
|
62
|
+
* そこで文が始まっていれば項目と同じく段落を改める。
|
|
63
|
+
*/
|
|
64
|
+
const NOTE = /^[ \t\u3000]*※/u;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 印のほかに、行を項目と同じに切る札。
|
|
68
|
+
* label は番号だけの行(「第1」「第3条」「第二章の二」)。数える語は辞書 numbering-counter から。
|
|
69
|
+
* tag は行頭の括弧で囲んだ札(「(別添)」「【参考】」)。札の語は辞書 line-head-tag から。後ろが助詞なら文の中の語(「(別添)の資料」)。
|
|
70
|
+
*/
|
|
71
|
+
export type LineVocabulary = { readonly label: RegExp; readonly tag: RegExp | undefined };
|
|
72
|
+
|
|
73
|
+
const NUMERAL = "[0-90-9〇一二三四五六七八九十百千]+";
|
|
74
|
+
const TAG_OPENER = "[((【〔[]";
|
|
75
|
+
const TAG_CLOSER = "[))】〕]]";
|
|
76
|
+
const alternativesOf = (words: readonly string[]): string => words.map(escapeRegExp).join("|");
|
|
77
|
+
|
|
78
|
+
/** counters は番号を数える語(条、章)、tags は括弧で囲む札の語(別添、参考)。 */
|
|
79
|
+
export const lineVocabulary = (counters: readonly string[], tags: readonly string[]): LineVocabulary => {
|
|
80
|
+
const counter = counters.length === 0 ? "" : `(?:${alternativesOf(counters)})?`;
|
|
81
|
+
return {
|
|
82
|
+
label: new RegExp(`^${SPACE}*第${NUMERAL}${counter}(?:の${NUMERAL})*${SPACE}*$`, "u"),
|
|
83
|
+
tag: tags.length === 0 ? undefined : new RegExp(`^${SPACE}*${TAG_OPENER}(?:${alternativesOf(tags)})${TAG_CLOSER}${PARTICLE_AFTER}`, "u"),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** 項目の行: 箇条書きの印、番号だけの札、行頭の括弧の札で始まる。その前でも後ろでも文が改まる。 */
|
|
88
|
+
const isListLine = (line: string, vocabulary: LineVocabulary): boolean =>
|
|
89
|
+
startsWithListMarker(line) || vocabulary.label.test(line) || (vocabulary.tag?.test(line) ?? false);
|
|
90
|
+
|
|
91
|
+
/** URL だけの行(▼こちら の次の行のアドレス)。 */
|
|
92
|
+
const URL_LINE = new RegExp(`^${SPACE}*https?://\\S+${SPACE}*$`, "u");
|
|
93
|
+
/**
|
|
94
|
+
* 欄の行: 短い札と全角か半角のコロンで始まる行(電話:03-…、E-mail:…)と、郵便番号の印〒で始まる行。連絡先の欄は 1 行 1 項目。
|
|
95
|
+
* 札が数字で終われば時刻(10:00、午前10:00)か比(1:2)で、札ではない。
|
|
96
|
+
*/
|
|
97
|
+
const FIELD_LINE = new RegExp(`^${SPACE}*(?:〒|[^\\s、。,::「」『』()()【】]{0,11}[^\\s、。,::「」『』()()【】0-90-9][::])`, "u");
|
|
98
|
+
/** 括弧でくくった語だけの行((お問い合わせ先)、【新着】(文部科学省)、「報告書は実践の宝庫」)。札か題で、文の途中ではない。 */
|
|
99
|
+
const BRACKET_GROUP = "[((【〔[「『][^((【〔[「『))】〕]」』\\n]*[))】〕]」』]";
|
|
100
|
+
const BRACKET_LINE = new RegExp(`^(?:${SPACE}*${BRACKET_GROUP})+${SPACE}*$`, "u");
|
|
101
|
+
/** 空白の後の括弧の注記で終わる行(題 (○○小学校))。題の行の終わりで、文は折り返しても括弧の前に空白を置かない。 */
|
|
102
|
+
const NOTE_IN_BRACKETS_END = new RegExp(`\\S${SPACE}+[((][^(())\\n]*[))]${SPACE}*$`, "u");
|
|
103
|
+
|
|
104
|
+
/** 行が助詞で始まる: 前の行の語を受けて文が続いている(「…」\nと述べた)。 */
|
|
105
|
+
const PARTICLE_START = new RegExp(`^${SPACE}*(?:の|に|を|が|は|と|で|へ|も|から|まで|より|及び|又は|並びに|若しくは)`, "u");
|
|
106
|
+
/** 行が助詞で終わる: 文が次の行へ続いている(担当者は\n「…」)。 */
|
|
107
|
+
const PARTICLE_END = new RegExp(`(?:の|に|を|が|は|と|で|へ|も|から|まで|より)${SPACE}*$`, "u");
|
|
108
|
+
|
|
109
|
+
/** 1 行で一つの単位になりうる行: URL、欄、括弧の語だけ。 */
|
|
110
|
+
const standsAlone = (line: string): boolean => URL_LINE.test(line) || FIELD_LINE.test(line) || BRACKET_LINE.test(line);
|
|
111
|
+
|
|
112
|
+
/** 空白だけの行。段落の中では、伏せた URL やコードが 1 行を占めていた所。 */
|
|
113
|
+
const isMaskedLine = (line: string): boolean => line.trim() === "";
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 行が文の途中に立っていない: 前の行が読点・開いた括弧・助詞で終わらず、次の行が助詞で始まらない。
|
|
117
|
+
* 折り返した文の途中に括弧の語だけの行が来ることがある(〜始まり、\n(休憩を挟んで)\n夕方まで続く。)。
|
|
118
|
+
*/
|
|
119
|
+
const standsBetween = (before: Line | undefined, after: Line | undefined): boolean =>
|
|
120
|
+
(before === undefined || (!continuesToNextLine(before.text) && !PARTICLE_END.test(before.text))) && (after === undefined || !PARTICLE_START.test(after.text));
|
|
121
|
+
|
|
122
|
+
/** 1 行で一つの単位の行。その前でも後ろでも文が改まる。 */
|
|
123
|
+
const isUnitLine = (lines: readonly Line[], index: number): boolean =>
|
|
124
|
+
standsAlone(lines[index]?.text ?? "") && standsBetween(lines[index - 1], lines[index + 1]);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* index の行の後ろで文が改まる: 1 行で一つの単位の行、題の注記で終わる行、伏せた行の後ろ。
|
|
128
|
+
* 次の行が注記(※)なら、その行に添える注記なので続ける。
|
|
129
|
+
*/
|
|
130
|
+
const endsUnitAt = (lines: readonly Line[], index: number): boolean => {
|
|
131
|
+
const line = lines[index]?.text ?? "";
|
|
132
|
+
const ends = isUnitLine(lines, index) || ((NOTE_IN_BRACKETS_END.test(line) || isMaskedLine(line)) && standsBetween(lines[index - 1], lines[index + 1]));
|
|
133
|
+
return ends && !NOTE.test(lines[index + 1]?.text ?? "");
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* index - 1 の行と index の行の間で文が改まるか: どちらかが項目の行か、1 行で一つの単位の行か、注記の行が続く。
|
|
138
|
+
* 前の行が次へ続いている(読点、開いた括弧)なら改まらない。
|
|
139
|
+
*/
|
|
140
|
+
const isCut = (lines: readonly Line[], index: number, vocabulary: LineVocabulary): boolean => {
|
|
141
|
+
const previous = lines[index - 1]?.text ?? "";
|
|
142
|
+
const next = lines[index]?.text ?? "";
|
|
143
|
+
return (
|
|
144
|
+
next.trim().length > 0 &&
|
|
145
|
+
!continuesToNextLine(previous) &&
|
|
146
|
+
(isListLine(next, vocabulary) ||
|
|
147
|
+
isListLine(previous, vocabulary) ||
|
|
148
|
+
isUnitLine(lines, index) ||
|
|
149
|
+
endsUnitAt(lines, index - 1) ||
|
|
150
|
+
(NOTE.test(previous) && NOTE.test(next)))
|
|
151
|
+
);
|
|
152
|
+
};
|
|
58
153
|
|
|
59
154
|
/** 文を改める改行の位置: 前の行の終わり(end)と、次の行の最初の文字(start)。 */
|
|
60
|
-
export const listLineBreaks = (text: string): Span[] => {
|
|
155
|
+
export const listLineBreaks = (text: string, vocabulary: LineVocabulary): Span[] => {
|
|
61
156
|
const lines = linesOf(text);
|
|
62
|
-
return lines.slice(1).flatMap((next,
|
|
63
|
-
const previous = lines[
|
|
64
|
-
if (previous === undefined || !isCut(
|
|
157
|
+
return lines.slice(1).flatMap((next, offset) => {
|
|
158
|
+
const previous = lines[offset];
|
|
159
|
+
if (previous === undefined || !isCut(lines, offset + 1, vocabulary)) return [];
|
|
65
160
|
return [{ start: previous.end, end: next.start + (next.text.length - next.text.trimStart().length) }];
|
|
66
161
|
});
|
|
67
162
|
};
|
|
68
163
|
|
|
69
|
-
/**
|
|
70
|
-
* 注記の印(「※」)。前の行に添える注記で、前の行の文を終えるとは限らない(「ファックス番号:…\n※送ったらご連絡ください。」)。
|
|
71
|
-
* 文を改めはしないが、そこで文が始まっていれば項目と同じく段落を改める。
|
|
72
|
-
*/
|
|
73
|
-
const NOTE = /^[ \t\u3000]*※/u;
|
|
74
|
-
|
|
75
164
|
/** 箇条書きの項目か注記の行の頭: 行の始まりから印の最初の文字まで。項目を始める文は、ここで始まる。 */
|
|
76
165
|
export const listItemHeads = (text: string): Span[] =>
|
|
77
166
|
linesOf(text).flatMap((line) =>
|