@chaffjs/lang-ja 0.30.0 → 0.32.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/currency-amounts.d.ts +21 -0
- package/dist/currency-amounts.d.ts.map +1 -0
- package/dist/currency-amounts.js +73 -0
- package/dist/currency-amounts.js.map +1 -0
- package/dist/era-year.d.ts +18 -0
- package/dist/era-year.d.ts.map +1 -0
- package/dist/era-year.js +47 -0
- package/dist/era-year.js.map +1 -0
- package/dist/lexicons.d.ts +3 -0
- package/dist/lexicons.d.ts.map +1 -1
- package/dist/lexicons.js +12 -0
- package/dist/lexicons.js.map +1 -1
- package/dist/numbers.d.ts +1 -1
- package/dist/numbers.d.ts.map +1 -1
- package/dist/numbers.js +7 -4
- package/dist/numbers.js.map +1 -1
- package/dist/quantities.d.ts +2 -0
- package/dist/quantities.d.ts.map +1 -1
- package/dist/quantities.js +56 -27
- package/dist/quantities.js.map +1 -1
- package/dist/unit-case.d.ts +4 -0
- package/dist/unit-case.d.ts.map +1 -0
- package/dist/unit-case.js +11 -0
- package/dist/unit-case.js.map +1 -0
- package/lexicons/age-reference-label.yaml +12 -0
- package/lexicons/age-time-mark.yaml +9 -0
- package/lexicons/annual-holidays-label.yaml +10 -0
- package/lexicons/annual-holidays-word.yaml +23 -0
- package/lexicons/annual-pay-label.yaml +22 -0
- package/lexicons/annual-pay-word.yaml +44 -0
- package/lexicons/any-year-marker.yaml +18 -0
- package/lexicons/balance-column.yaml +43 -0
- package/lexicons/benefit-limit-word.yaml +9 -0
- package/lexicons/birth-date-label.yaml +6 -0
- package/lexicons/bmi-term.yaml +10 -0
- package/lexicons/bmi-unit.yaml +7 -0
- package/lexicons/calendar-era.yaml +6 -0
- package/lexicons/change-column.yaml +28 -0
- package/lexicons/change-target.yaml +4 -1
- package/lexicons/closing-balance-label.yaml +48 -0
- package/lexicons/company-form-foreign.yaml +45 -0
- package/lexicons/company-name-kana.yaml +91 -0
- package/lexicons/cumulative-table.yaml +35 -0
- package/lexicons/currency-column.yaml +13 -0
- package/lexicons/date-deadline-mark.yaml +10 -0
- package/lexicons/dated-column-label.yaml +14 -0
- package/lexicons/dated-pair-label.yaml +217 -0
- package/lexicons/dated-span-label.yaml +12 -0
- package/lexicons/deductible-basis.yaml +20 -0
- package/lexicons/deductible-word.yaml +8 -0
- package/lexicons/discount-rate-label.yaml +30 -0
- package/lexicons/due-date-label.yaml +4 -0
- package/lexicons/email-greeting.yaml +4 -0
- package/lexicons/email-sentence-end.yaml +10 -0
- package/lexicons/event-bill-word.yaml +5 -0
- package/lexicons/event-due-word.yaml +6 -0
- package/lexicons/event-payment-deadline-word.yaml +18 -0
- package/lexicons/event-payment-word.yaml +8 -0
- package/lexicons/event-start-label.yaml +9 -0
- package/lexicons/event-ticket-word.yaml +8 -0
- package/lexicons/event-trip-word.yaml +12 -0
- package/lexicons/fact-age-joiner.yaml +10 -0
- package/lexicons/fact-age-limit.yaml +7 -0
- package/lexicons/fact-age-mark.yaml +7 -0
- package/lexicons/fact-amount-condition.yaml +15 -0
- package/lexicons/fact-count-column.yaml +8 -0
- package/lexicons/fact-count-counter.yaml +7 -0
- package/lexicons/fact-count-not-whole.yaml +22 -0
- package/lexicons/fact-count-restating.yaml +9 -0
- package/lexicons/fact-count-separate-rows.yaml +6 -0
- package/lexicons/fact-count-whole.yaml +9 -0
- package/lexicons/fact-document-term.yaml +32 -0
- package/lexicons/fact-label-count-link.yaml +9 -0
- package/lexicons/fact-label-counter.yaml +25 -0
- package/lexicons/fact-label-drop.yaml +7 -0
- package/lexicons/fact-label-qualifier.yaml +8 -0
- package/lexicons/fact-rate-base.yaml +12 -0
- package/lexicons/fact-rate-kind.yaml +13 -0
- package/lexicons/fact-rate-period.yaml +16 -0
- package/lexicons/fact-separator.yaml +2 -0
- package/lexicons/fact-term-self.yaml +9 -0
- package/lexicons/fact-term-start.yaml +7 -0
- package/lexicons/formula-amount-word.yaml +12 -0
- package/lexicons/gpa-label.yaml +18 -0
- package/lexicons/grade-point.yaml +35 -0
- package/lexicons/heading-number-label.yaml +1 -2
- package/lexicons/installment-label.yaml +49 -0
- package/lexicons/installment-word.yaml +37 -0
- package/lexicons/interest-label.yaml +28 -0
- package/lexicons/item-name-column.yaml +9 -0
- package/lexicons/lab-result-column.yaml +23 -0
- package/lexicons/label-product-word.yaml +21 -0
- package/lexicons/line-amount-column.yaml +3 -0
- package/lexicons/meter-event.yaml +24 -0
- package/lexicons/meter-reading-label.yaml +29 -0
- package/lexicons/meter-unit.yaml +10 -0
- package/lexicons/name-char-reading.yaml +18 -0
- package/lexicons/name-lookalike-char.yaml +26 -0
- package/lexicons/net-amount-label.yaml +62 -0
- package/lexicons/net-amount-period.yaml +14 -0
- package/lexicons/net-gross-weight-column.yaml +20 -0
- package/lexicons/order-quantity-column.yaml +26 -0
- package/lexicons/organization-unit.yaml +25 -0
- package/lexicons/orthographic-variant-distinct.yaml +6 -0
- package/lexicons/orthographic-variant-whole-word.yaml +27 -0
- package/lexicons/overnight-work-mark.yaml +13 -0
- package/lexicons/pack-count-column.yaml +10 -0
- package/lexicons/pack-price-column.yaml +12 -0
- package/lexicons/per-unit-mark.yaml +1 -0
- package/lexicons/period-label.yaml +9 -0
- package/lexicons/period-multiple-label.yaml +12 -0
- package/lexicons/period-multiple-word.yaml +30 -0
- package/lexicons/period-part-after.yaml +8 -0
- package/lexicons/period-part-inline-joiner.yaml +5 -0
- package/lexicons/period-part-marker.yaml +9 -0
- package/lexicons/period-part-range.yaml +10 -0
- package/lexicons/period-part-word.yaml +5 -0
- package/lexicons/person-label.yaml +19 -0
- package/lexicons/person-title.yaml +22 -0
- package/lexicons/phone-label.yaml +9 -0
- package/lexicons/points-earned-column.yaml +20 -0
- package/lexicons/points-rate-joiner.yaml +9 -0
- package/lexicons/points-unit.yaml +7 -0
- package/lexicons/product-form.yaml +23 -0
- package/lexicons/quantity-column.yaml +22 -0
- package/lexicons/range-start-end.yaml +30 -0
- package/lexicons/rate-unit.yaml +8 -0
- package/lexicons/ratio-label.yaml +15 -0
- package/lexicons/ratio-term.yaml +13 -0
- package/lexicons/reference-bound-mark.yaml +14 -0
- package/lexicons/reference-column-heading.yaml +7 -0
- package/lexicons/reference-column.yaml +16 -0
- package/lexicons/reference-flag.yaml +23 -0
- package/lexicons/reference-label.yaml +123 -0
- package/lexicons/reference-unit-column.yaml +7 -0
- package/lexicons/reference-unit.yaml +80 -0
- package/lexicons/reporting-comparison.yaml +26 -0
- package/lexicons/reporting-current-not.yaml +10 -0
- package/lexicons/reporting-current.yaml +15 -0
- package/lexicons/reporting-forecast.yaml +18 -0
- package/lexicons/reporting-period-frame.yaml +19 -0
- package/lexicons/reporting-period-line.yaml +12 -0
- package/lexicons/reporting-period-not.yaml +23 -0
- package/lexicons/reporting-results-word.yaml +10 -0
- package/lexicons/reporting-year-frame.yaml +7 -0
- package/lexicons/request-offer.yaml +15 -0
- package/lexicons/retention-unit.yaml +2 -2
- package/lexicons/revision-column.yaml +15 -0
- package/lexicons/revision-direction.yaml +21 -0
- package/lexicons/serial-label.yaml +9 -0
- package/lexicons/service-charge-label.yaml +6 -0
- package/lexicons/share-amount-label.yaml +20 -0
- package/lexicons/share-column-rate-header.yaml +41 -0
- package/lexicons/shift-column.yaml +25 -0
- package/lexicons/table-scale-unit.yaml +19 -0
- package/lexicons/table-unit-caption.yaml +6 -0
- package/lexicons/tax-price-column.yaml +14 -0
- package/lexicons/tier-label.yaml +25 -0
- package/lexicons/tier-unit.yaml +9 -0
- package/lexicons/timed-pair-label.yaml +71 -0
- package/lexicons/total-label.yaml +12 -1
- package/lexicons/total-noun-listed.yaml +8 -0
- package/lexicons/total-noun-qualifier.yaml +8 -0
- package/lexicons/total-noun-unsummed.yaml +10 -0
- package/lexicons/total-period-qualifier.yaml +10 -0
- package/lexicons/transcript-column.yaml +17 -0
- package/lexicons/unit-area.yaml +6 -0
- package/lexicons/unit-concentration.yaml +71 -0
- package/lexicons/unit-price-column.yaml +21 -0
- package/lexicons/unit-volume.yaml +4 -0
- package/lexicons/use-amount-word.yaml +9 -0
- package/lexicons/variance-column.yaml +17 -0
- package/lexicons/vehicle-plate.yaml +7 -0
- package/lexicons/weekly-days-off.yaml +35 -0
- package/lexicons/year-span-joiner.yaml +13 -0
- package/package.json +2 -2
- package/src/currency-amounts.ts +96 -0
- package/src/era-year.ts +66 -0
- package/src/lexicons.ts +18 -0
- package/src/numbers.ts +7 -3
- package/src/quantities.ts +61 -29
- package/src/unit-case.ts +14 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 成績の表で、列の見出しが言う役割(gpa-mismatch)。group: course は科目、credits は単位数、grade は評価(評語)、
|
|
2
|
+
# points はグレードポイントの列(評価の列と取り違えないよう先に見る)。grade か points の語のある行だけを、評価と点の
|
|
3
|
+
# 対応(「S(4)」)として読む。total は合計の行の最初の升に書く語で、その行は科目として数えない。
|
|
4
|
+
id: transcript-column
|
|
5
|
+
language: ja
|
|
6
|
+
entries:
|
|
7
|
+
- { pattern: GP, group: points }
|
|
8
|
+
- { pattern: グレードポイント, group: points }
|
|
9
|
+
- { pattern: 評価, group: grade }
|
|
10
|
+
- { pattern: 成績, group: grade }
|
|
11
|
+
- { pattern: 評語, group: grade }
|
|
12
|
+
- { pattern: 単位, group: credits }
|
|
13
|
+
- { pattern: 科目, group: course }
|
|
14
|
+
- { pattern: 授業, group: course }
|
|
15
|
+
- { pattern: 合計, group: total }
|
|
16
|
+
- { pattern: 小計, group: total }
|
|
17
|
+
- { pattern: 総計, group: total }
|
package/lexicons/unit-area.yaml
CHANGED
|
@@ -7,6 +7,10 @@ entries:
|
|
|
7
7
|
weight: 1
|
|
8
8
|
- pattern: "m²"
|
|
9
9
|
weight: 1
|
|
10
|
+
- pattern: "m2"
|
|
11
|
+
weight: 1
|
|
12
|
+
- pattern: "m^2"
|
|
13
|
+
weight: 1
|
|
10
14
|
- pattern: "平方メートル"
|
|
11
15
|
weight: 1
|
|
12
16
|
- pattern: "平米"
|
|
@@ -15,6 +19,8 @@ entries:
|
|
|
15
19
|
weight: 1000000
|
|
16
20
|
- pattern: "km²"
|
|
17
21
|
weight: 1000000
|
|
22
|
+
- pattern: "km2"
|
|
23
|
+
weight: 1000000
|
|
18
24
|
- pattern: "平方キロメートル"
|
|
19
25
|
weight: 1000000
|
|
20
26
|
- pattern: "ヘクタール"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 濃度と、血球などの数の単位(検査値の mg/dL、mmol/L、U/L、×10⁴/µL)。group が単位の組で、比べるのは同じ組の単位どうしだけ。
|
|
2
|
+
# mg/dL と mmol/L の換算は物質で違うので、組をまたぐ倍率は持たない。weight は組の基準の単位への倍率。
|
|
3
|
+
id: unit-concentration
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
# 質量濃度(基準は mg/L)
|
|
7
|
+
- { pattern: "g/L", group: mass, weight: 1000 }
|
|
8
|
+
- { pattern: "g/dL", group: mass, weight: 10000 }
|
|
9
|
+
- { pattern: "g/dl", group: mass, weight: 10000 }
|
|
10
|
+
- { pattern: "mg/L", group: mass, weight: 1 }
|
|
11
|
+
- { pattern: "mg/l", group: mass, weight: 1 }
|
|
12
|
+
- { pattern: "mg/dL", group: mass, weight: 10 }
|
|
13
|
+
- { pattern: "mg/dl", group: mass, weight: 10 }
|
|
14
|
+
- { pattern: "mg/100mL", group: mass, weight: 10 }
|
|
15
|
+
- { pattern: "mg/mL", group: mass, weight: 1000 }
|
|
16
|
+
- { pattern: "µg/L", group: mass, weight: 0.001 }
|
|
17
|
+
- { pattern: "μg/L", group: mass, weight: 0.001 }
|
|
18
|
+
- { pattern: "µg/dL", group: mass, weight: 0.01 }
|
|
19
|
+
- { pattern: "μg/dL", group: mass, weight: 0.01 }
|
|
20
|
+
- { pattern: "µg/mL", group: mass, weight: 1 }
|
|
21
|
+
- { pattern: "μg/mL", group: mass, weight: 1 }
|
|
22
|
+
- { pattern: "ng/mL", group: mass, weight: 0.001 }
|
|
23
|
+
- { pattern: "ng/dL", group: mass, weight: 0.00001 }
|
|
24
|
+
- { pattern: "pg/mL", group: mass, weight: 0.000001 }
|
|
25
|
+
# 物質量の濃度(基準は µmol/L)
|
|
26
|
+
- { pattern: "mol/L", group: molar, weight: 1000000 }
|
|
27
|
+
- { pattern: "mmol/L", group: molar, weight: 1000 }
|
|
28
|
+
- { pattern: "mmol/l", group: molar, weight: 1000 }
|
|
29
|
+
- { pattern: "µmol/L", group: molar, weight: 1 }
|
|
30
|
+
- { pattern: "μmol/L", group: molar, weight: 1 }
|
|
31
|
+
- { pattern: "nmol/L", group: molar, weight: 0.001 }
|
|
32
|
+
- { pattern: "pmol/L", group: molar, weight: 0.000001 }
|
|
33
|
+
# 当量の濃度(基準は mEq/L)
|
|
34
|
+
- { pattern: "mEq/L", group: equivalent, weight: 1 }
|
|
35
|
+
- { pattern: "mEq/l", group: equivalent, weight: 1 }
|
|
36
|
+
# 酵素の活性(基準は U/L)
|
|
37
|
+
- { pattern: "U/L", group: enzyme, weight: 1 }
|
|
38
|
+
- { pattern: "U/l", group: enzyme, weight: 1 }
|
|
39
|
+
- { pattern: "U/mL", group: enzyme, weight: 1000 }
|
|
40
|
+
- { pattern: "mU/mL", group: enzyme, weight: 1 }
|
|
41
|
+
- { pattern: "mU/L", group: enzyme, weight: 0.001 }
|
|
42
|
+
- { pattern: "µU/mL", group: enzyme, weight: 0.001 }
|
|
43
|
+
- { pattern: "μU/mL", group: enzyme, weight: 0.001 }
|
|
44
|
+
# 国際単位(基準は IU/L)
|
|
45
|
+
- { pattern: "IU/L", group: international, weight: 1 }
|
|
46
|
+
- { pattern: "IU/l", group: international, weight: 1 }
|
|
47
|
+
- { pattern: "IU/mL", group: international, weight: 1000 }
|
|
48
|
+
- { pattern: "mIU/mL", group: international, weight: 1 }
|
|
49
|
+
- { pattern: "mIU/L", group: international, weight: 0.001 }
|
|
50
|
+
- { pattern: "µIU/mL", group: international, weight: 0.001 }
|
|
51
|
+
- { pattern: "μIU/mL", group: international, weight: 0.001 }
|
|
52
|
+
# 血球などの数(基準は 1 µL あたりの個数。1 mm³ は 1 µL、10⁹/L は 10³/µL)
|
|
53
|
+
- { pattern: "/µL", group: count, weight: 1 }
|
|
54
|
+
- { pattern: "/μL", group: count, weight: 1 }
|
|
55
|
+
- { pattern: "/mm³", group: count, weight: 1 }
|
|
56
|
+
- { pattern: "×10³/µL", group: count, weight: 1000 }
|
|
57
|
+
- { pattern: "×10³/μL", group: count, weight: 1000 }
|
|
58
|
+
- { pattern: "×10^3/µL", group: count, weight: 1000 }
|
|
59
|
+
- { pattern: "×10⁴/µL", group: count, weight: 10000 }
|
|
60
|
+
- { pattern: "×10⁴/μL", group: count, weight: 10000 }
|
|
61
|
+
- { pattern: "×10^4/µL", group: count, weight: 10000 }
|
|
62
|
+
- { pattern: "万/µL", group: count, weight: 10000 }
|
|
63
|
+
- { pattern: "万/μL", group: count, weight: 10000 }
|
|
64
|
+
- { pattern: "万/mm³", group: count, weight: 10000 }
|
|
65
|
+
- { pattern: "×10⁶/µL", group: count, weight: 1000000 }
|
|
66
|
+
- { pattern: "×10⁶/μL", group: count, weight: 1000000 }
|
|
67
|
+
- { pattern: "×10^6/µL", group: count, weight: 1000000 }
|
|
68
|
+
- { pattern: "×10⁹/L", group: count, weight: 1000 }
|
|
69
|
+
- { pattern: "×10^9/L", group: count, weight: 1000 }
|
|
70
|
+
- { pattern: "×10¹²/L", group: count, weight: 1000000 }
|
|
71
|
+
- { pattern: "×10^12/L", group: count, weight: 1000000 }
|
|
@@ -5,3 +5,24 @@ entries:
|
|
|
5
5
|
- pattern: 単価
|
|
6
6
|
- pattern: 単価(税抜)
|
|
7
7
|
- pattern: 単価(円)
|
|
8
|
+
- pattern: 1点の単価
|
|
9
|
+
- pattern: 点数単価
|
|
10
|
+
- pattern: 単価(円/点)
|
|
11
|
+
- { pattern: 時給, group: hour }
|
|
12
|
+
- { pattern: 単価(円/km), group: km }
|
|
13
|
+
- { pattern: 月額, group: month }
|
|
14
|
+
- { pattern: 月額賃料, group: month }
|
|
15
|
+
- { pattern: 日額, group: day }
|
|
16
|
+
- { pattern: 日額給付金, group: day }
|
|
17
|
+
- { pattern: 1日あたり, group: day }
|
|
18
|
+
# 授業料の明細の1単位あたりの授業料(単位数と掛けて金額になる)。
|
|
19
|
+
- { pattern: 1単位あたりの授業料, group: credit }
|
|
20
|
+
- { pattern: 単位あたり, group: credit }
|
|
21
|
+
# 不動産の精算書の日割り(日割額 × 日数 = 精算金)。
|
|
22
|
+
- { pattern: 日割額, group: day }
|
|
23
|
+
- { pattern: 日割り額, group: day }
|
|
24
|
+
# 土地の面積あたりの単価。坪は㎡と別の単位なので、別の group にする。
|
|
25
|
+
- { pattern: ㎡単価, group: sqm }
|
|
26
|
+
- { pattern: 平米単価, group: sqm }
|
|
27
|
+
- { pattern: 単価(円/㎡), group: sqm }
|
|
28
|
+
- { pattern: 坪単価, group: tsubo }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 1回に使う量の印(product-exceeds-maximum)。数のすぐ前に書く(1回2錠、1回500円)。
|
|
2
|
+
id: use-amount-word
|
|
3
|
+
language: ja
|
|
4
|
+
entries:
|
|
5
|
+
- { pattern: "1回", position: before }
|
|
6
|
+
- { pattern: "一回", position: before }
|
|
7
|
+
- { pattern: "1回あたり", position: before }
|
|
8
|
+
- { pattern: "1回につき", position: before }
|
|
9
|
+
- { pattern: "1回量", position: before }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 予算と決算を並べた表で、列の見出しが言う役割(variance-mismatch)。group: budget は予算の列、actual は決算・実績の列、
|
|
2
|
+
# variance は二つの差の列、rate は率の列(差の列としては読まない)。rate、variance、budget、actual の順に見るので、
|
|
3
|
+
# 「増減率」は率の列、「予算比」は差の列になる。字面どおりに照らす。
|
|
4
|
+
id: variance-column
|
|
5
|
+
language: ja
|
|
6
|
+
entries:
|
|
7
|
+
- { pattern: 率, group: rate }
|
|
8
|
+
- { pattern: "%", group: rate }
|
|
9
|
+
- { pattern: 増減, group: variance }
|
|
10
|
+
- { pattern: 差異, group: variance }
|
|
11
|
+
- { pattern: 差額, group: variance }
|
|
12
|
+
- { pattern: 予算比, group: variance }
|
|
13
|
+
- { pattern: 過不足, group: variance }
|
|
14
|
+
- { pattern: 予算, group: budget }
|
|
15
|
+
- { pattern: 決算, group: actual }
|
|
16
|
+
- { pattern: 実績, group: actual }
|
|
17
|
+
- { pattern: 執行額, group: actual }
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# 自動車のナンバー(地名・分類番号・かな・一連番号。ひばり野 330 ね 48-15)の形。reference-number-variant は、reference-label の語のすぐ後ろでこの形に合う並びを、ここの group の番号として読む。
|
|
2
|
+
# pattern は正規表現で、名前の付いた部分がナンバーの部分。serial(一連番号)だけが打ち間違いで変わる部分で、ほかの部分がそろっていないナンバーどうしは一文字違いとして比べない。
|
|
3
|
+
id: vehicle-plate
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: '(?<region>[\p{Script=Han}々ぁ-ゖァ-ヺー]{1,5})[ ]?(?<class>[0-90-9]{1,3}[A-Za-zA-Z]?)[ ]?(?<kana>[ぁ-ゖ])[ ]?(?<serial>[0-90-9]{1,2}[-‐−-][0-90-9]{2}|[・・]{1,3}[0-90-9]{1,3}|[0-90-9]{1,4})'
|
|
7
|
+
group: vehicle
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 毎週の休みを言う語と、それが一年に必ず生む休日の数(annual-holidays-mismatch)。weight は52週ぶんの最低の日数で、
|
|
2
|
+
# 年間休日がこれより少なければ食い違い。group every-week は毎週その日数を休む語(完全週休2日制は毎週2日で 52 × 2 = 104日、
|
|
3
|
+
# 4週8休は4週ごとに8日で 52 ÷ 4 × 8 = 104日)。group not-every-week は毎週ではない語で、weight を持たない。「完全」の
|
|
4
|
+
# 付かない週休2日制は「月に1回以上、2日休む週がある」という意味で、毎週2日休むとは限らない。これがある文書は比べない。
|
|
5
|
+
id: weekly-days-off
|
|
6
|
+
language: ja
|
|
7
|
+
entries:
|
|
8
|
+
- { pattern: 完全週休2日制, group: every-week, weight: 104 }
|
|
9
|
+
- { pattern: 完全週休2日, group: every-week, weight: 104 }
|
|
10
|
+
- { pattern: 完全週休2日制, group: every-week, weight: 104 }
|
|
11
|
+
- { pattern: 完全週休2日, group: every-week, weight: 104 }
|
|
12
|
+
- { pattern: 完全週休二日制, group: every-week, weight: 104 }
|
|
13
|
+
- { pattern: 完全週休二日, group: every-week, weight: 104 }
|
|
14
|
+
- { pattern: 完全週休3日制, group: every-week, weight: 156 }
|
|
15
|
+
- { pattern: 完全週休3日, group: every-week, weight: 156 }
|
|
16
|
+
- { pattern: 完全週休3日制, group: every-week, weight: 156 }
|
|
17
|
+
- { pattern: 完全週休3日, group: every-week, weight: 156 }
|
|
18
|
+
- { pattern: 完全週休三日制, group: every-week, weight: 156 }
|
|
19
|
+
- { pattern: 完全週休三日, group: every-week, weight: 156 }
|
|
20
|
+
- { pattern: 4週8休, group: every-week, weight: 104 }
|
|
21
|
+
- { pattern: 4週8休, group: every-week, weight: 104 }
|
|
22
|
+
- { pattern: 4週6休, group: every-week, weight: 78 }
|
|
23
|
+
- { pattern: 4週6休, group: every-week, weight: 78 }
|
|
24
|
+
- { pattern: 週休2日制, group: not-every-week }
|
|
25
|
+
- { pattern: 週休2日, group: not-every-week }
|
|
26
|
+
- { pattern: 週休2日制, group: not-every-week }
|
|
27
|
+
- { pattern: 週休2日, group: not-every-week }
|
|
28
|
+
- { pattern: 週休二日制, group: not-every-week }
|
|
29
|
+
- { pattern: 週休二日, group: not-every-week }
|
|
30
|
+
- { pattern: 週休3日制, group: not-every-week }
|
|
31
|
+
- { pattern: 週休3日, group: not-every-week }
|
|
32
|
+
- { pattern: 週休3日制, group: not-every-week }
|
|
33
|
+
- { pattern: 週休3日, group: not-every-week }
|
|
34
|
+
- { pattern: 週休三日制, group: not-every-week }
|
|
35
|
+
- { pattern: 週休三日, group: not-every-week }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# 期間の始めと終わりの日付をつなぐ言葉。date-without-year は、終わりの日付の年を語で言う期間(4月1日から翌年3月31日まで)の
|
|
2
|
+
# 始めの日付を指さない。毎年度の区切りのように、どの年にも当てはまる期間だから。
|
|
3
|
+
id: year-span-joiner
|
|
4
|
+
language: ja
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: から
|
|
7
|
+
- pattern: 〜
|
|
8
|
+
- pattern: ~
|
|
9
|
+
- pattern: "-"
|
|
10
|
+
- pattern: -
|
|
11
|
+
- pattern: ‐
|
|
12
|
+
- pattern: –
|
|
13
|
+
- pattern: —
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaffjs/lang-ja",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Japanese language adapter for chaff",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "isamu",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"url": "git+https://github.com/isamu/lab.git",
|
|
42
42
|
"directory": "text/packages/lang-ja"
|
|
43
43
|
},
|
|
44
|
-
"homepage": "https://github.
|
|
44
|
+
"homepage": "https://isamu.github.io/lab/en/",
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { parseJapaneseNumber, toHalfWidth } from "./numbers.ts";
|
|
2
|
+
import { startsWithUnit } from "./unit-case.ts";
|
|
3
|
+
|
|
4
|
+
// 通貨の書き方(語彙 currency-notation)と百分率の単位(percent-unit)で読む金額と率。助数詞として読めない書き方
|
|
5
|
+
// (¥1,320、US$1,320、1,320米ドル、1,320ユーロ、1,320兆円、1,320 JPY、8.0 %)を、語彙だけを頼りに読む。
|
|
6
|
+
|
|
7
|
+
export type Multiplier = { readonly pattern: string; readonly weight: number };
|
|
8
|
+
|
|
9
|
+
export type AmountVocabulary = {
|
|
10
|
+
/** 数の前に書く通貨(¥、US$、JPY)。 */
|
|
11
|
+
readonly before: readonly string[];
|
|
12
|
+
/** 数の後ろに書く通貨(円、米ドル、JPY)と百分率の単位。 */
|
|
13
|
+
readonly after: readonly string[];
|
|
14
|
+
/** 数と後ろの通貨のあいだの桁の語(兆、million)と、それが掛ける数。 */
|
|
15
|
+
readonly multipliers: readonly Multiplier[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type CurrencyAmount = { readonly start: number; readonly end: number; readonly value: number; readonly unit: string };
|
|
19
|
+
|
|
20
|
+
const DIGITS = /[0-90-9][0-90-9,,..]{0,15}/gu;
|
|
21
|
+
const GAP = /^[ \t\u3000]?/u;
|
|
22
|
+
const LATIN = /[A-Za-z]/u;
|
|
23
|
+
const WORD_CHAR = /[A-Za-z0-90-9]/u;
|
|
24
|
+
/** 数の前のこの字は、数を別のものの続きにする。英字や数字(v1.2)と、時刻や比の後ろ半分(10:30 の 30)。 */
|
|
25
|
+
const CONTINUES_BEFORE = /[A-Za-z0-90-9::]/u;
|
|
26
|
+
/** 桁の語の前に書く位(「1,320百万ユーロ」の百)。 */
|
|
27
|
+
const PLACE = /^[十百千]/u;
|
|
28
|
+
/** 数だけを書いた西暦の年(2026)。後ろに空白と通貨が来ても、年のこと(「2020 USD ベース」)がある。 */
|
|
29
|
+
const YEAR = /^(?:1[89]|2[01])\d{2}$/u;
|
|
30
|
+
|
|
31
|
+
const TRAILING_MARKS = new Set([",", ",", ".", "."]);
|
|
32
|
+
|
|
33
|
+
/** 「1,320.」の終わりの点やカンマは数の一部にしない。 */
|
|
34
|
+
const withoutTrailingMarks = (run: string): string => {
|
|
35
|
+
let end = run.length;
|
|
36
|
+
while (end > 0 && TRAILING_MARKS.has(run.charAt(end - 1))) end -= 1;
|
|
37
|
+
return run.slice(0, end);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** 数の前の通貨。数に触れている短いほう(US$1,320 の $)を取る。英字の通貨は、英字や数字の続きでないものだけ。 */
|
|
41
|
+
const markBefore = (text: string, start: number, marks: readonly string[]): string | undefined => {
|
|
42
|
+
const end = start - (GAP.exec(text.slice(start - 1, start))?.[0].length ?? 0);
|
|
43
|
+
return marks
|
|
44
|
+
.filter((mark) => text.startsWith(mark, end - mark.length) && !(LATIN.test(mark) && WORD_CHAR.test(text.charAt(end - mark.length - 1))))
|
|
45
|
+
.toSorted((left, right) => left.length - right.length)[0];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const leadingGap = (rest: string): number => GAP.exec(rest)?.[0].length ?? 0;
|
|
49
|
+
|
|
50
|
+
type Scale = { readonly length: number; readonly weight: number };
|
|
51
|
+
|
|
52
|
+
const multiplierAt = (text: string, multipliers: readonly Multiplier[]): Multiplier | undefined =>
|
|
53
|
+
multipliers
|
|
54
|
+
.filter((entry) => startsWithUnit(text, 0, entry.pattern) && !(LATIN.test(entry.pattern) && WORD_CHAR.test(text.charAt(entry.pattern.length))))
|
|
55
|
+
.toSorted((left, right) => right.pattern.length - left.pattern.length)[0];
|
|
56
|
+
|
|
57
|
+
/** 数の直後の桁(「千」「百万」「兆」「 million」)。無ければ 1 倍。 */
|
|
58
|
+
const scaleAt = (rest: string, multipliers: readonly Multiplier[]): Scale => {
|
|
59
|
+
const gap = leadingGap(rest);
|
|
60
|
+
const place = PLACE.exec(rest.slice(gap))?.[0] ?? "";
|
|
61
|
+
const placed = place === "" ? undefined : multiplierAt(rest.slice(gap + place.length), multipliers);
|
|
62
|
+
if (placed !== undefined) return { length: gap + place.length + placed.pattern.length, weight: (parseJapaneseNumber(place) ?? 1) * placed.weight };
|
|
63
|
+
const multiplier = multiplierAt(rest.slice(gap), multipliers);
|
|
64
|
+
return multiplier === undefined ? { length: 0, weight: 1 } : { length: gap + multiplier.pattern.length, weight: multiplier.weight };
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** 数の後ろの通貨か単位。長いほう(米ドル)を取る。英字のものは、後ろに英字が続かないものだけ(USDT は USD でない)。 */
|
|
68
|
+
const markAfter = (rest: string, marks: readonly string[]): { readonly mark: string; readonly gap: number } | undefined => {
|
|
69
|
+
const gap = leadingGap(rest);
|
|
70
|
+
const mark = marks
|
|
71
|
+
.filter((entry) => startsWithUnit(rest, gap, entry) && !(LATIN.test(entry) && WORD_CHAR.test(rest.charAt(gap + entry.length))))
|
|
72
|
+
.toSorted((left, right) => right.length - left.length)[0];
|
|
73
|
+
return mark === undefined ? undefined : { mark, gap };
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const amountAt = (text: string, match: RegExpExecArray, vocabulary: AmountVocabulary): CurrencyAmount | undefined => {
|
|
77
|
+
const number = withoutTrailingMarks(match[0]);
|
|
78
|
+
const value = parseJapaneseNumber(number);
|
|
79
|
+
const end = match.index + number.length;
|
|
80
|
+
const before = markBefore(text, match.index, vocabulary.before);
|
|
81
|
+
if (value === undefined || (before === undefined && CONTINUES_BEFORE.test(text.charAt(match.index - 1)))) return undefined;
|
|
82
|
+
const scale = scaleAt(text.slice(end), vocabulary.multipliers);
|
|
83
|
+
if (before !== undefined) return { start: match.index, end: end + scale.length, value: value * scale.weight, unit: before };
|
|
84
|
+
const after = markAfter(text.slice(end + scale.length), vocabulary.after);
|
|
85
|
+
if (after === undefined) return undefined;
|
|
86
|
+
// 空白を挟んだ年は通貨の額と読まない。空白の無い「2000ユーロ」は額のまま。
|
|
87
|
+
if (scale.length === 0 && after.gap > 0 && YEAR.test(toHalfWidth(number))) return undefined;
|
|
88
|
+
return { start: match.index, end: end + scale.length + after.gap + after.mark.length, value: value * scale.weight, unit: after.mark };
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** 文の中の、通貨の書き方で書いた金額と率。値は桁の語を掛けた数(1,320兆円 は 1,320 × 10^12 円)。 */
|
|
92
|
+
export const currencyAmounts = (text: string, vocabulary: AmountVocabulary): CurrencyAmount[] =>
|
|
93
|
+
[...text.matchAll(DIGITS)].flatMap((match) => {
|
|
94
|
+
const amount = amountAt(text, match, vocabulary);
|
|
95
|
+
return amount === undefined ? [] : [amount];
|
|
96
|
+
});
|
package/src/era-year.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { parseJapaneseNumber, toHalfWidth } from "./numbers.ts";
|
|
2
|
+
import { escapeRegExp } from "./regexp.ts";
|
|
3
|
+
|
|
4
|
+
// 元号の年と西暦の年を並べて書いた年(令和6年(2024年)、2024年(令和6年)、令和6(2024)年)。純粋。元号とその元年は語彙表 calendar-era が言う。
|
|
5
|
+
|
|
6
|
+
/** 元号と、その元年の西暦の年(令和は 2019)。 */
|
|
7
|
+
export type Era = { readonly name: string; readonly firstYear: number };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 括弧で言い換えた年の一つ。year は括弧の外に書いた年を西暦にしたもの、glossYear は括弧の中の年を西暦にしたもの。
|
|
11
|
+
* 二つが違えば、どちらかの書き違い。
|
|
12
|
+
*/
|
|
13
|
+
export type GlossedYear = { readonly start: number; readonly end: number; readonly year: number; readonly glossYear: number };
|
|
14
|
+
|
|
15
|
+
const ERA_NUMBER = "(?:[0-90-9]{1,2}|[一二三四五六七八九十]{1,3}|元)";
|
|
16
|
+
const WESTERN = "(?:[0-90-9]{4}|[〇一二三四五六七八九]{4})";
|
|
17
|
+
const OPEN = "[((]";
|
|
18
|
+
const CLOSE = "[))]";
|
|
19
|
+
/** 元号と年の数、年の数と単位のあいだの空白 1 つ(令和 6 年)。 */
|
|
20
|
+
const GAP = "[ \\u3000]?";
|
|
21
|
+
|
|
22
|
+
/** 西暦の年の前に数字が続けば、もっと長い数の一部(12024年)。 */
|
|
23
|
+
const NOT_AFTER_DIGIT = "(?<![0-90-9〇一二三四五六七八九十])";
|
|
24
|
+
|
|
25
|
+
/** 括弧の後ろの単位が「年度」なら、暦の年でなく会計の年(令和6(2024)年度)。 */
|
|
26
|
+
const CALENDAR_YEAR_AFTER = "年(?!度)";
|
|
27
|
+
|
|
28
|
+
const shapes = (eras: string): readonly string[] => {
|
|
29
|
+
const era = `(?<era>${eras})${GAP}(?<n>${ERA_NUMBER})${GAP}`;
|
|
30
|
+
const western = `${NOT_AFTER_DIGIT}(?<w>${WESTERN})`;
|
|
31
|
+
return [
|
|
32
|
+
`${era}年${OPEN}${western}年${CLOSE}`,
|
|
33
|
+
`${era}${OPEN}${western}${CLOSE}${CALENDAR_YEAR_AFTER}`,
|
|
34
|
+
`${western}年${OPEN}${era}年${CLOSE}`,
|
|
35
|
+
`${western}${OPEN}${era}${CLOSE}${CALENDAR_YEAR_AFTER}`,
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** 元号の年の数。元年は 1。 */
|
|
40
|
+
const eraNumber = (written: string): number | undefined => (written === "元" ? 1 : parseJapaneseNumber(toHalfWidth(written)));
|
|
41
|
+
|
|
42
|
+
const KANJI_DIGITS = "〇一二三四五六七八九";
|
|
43
|
+
|
|
44
|
+
/** 西暦の年。漢数字(二〇二四)は位取りでなく一字ずつ読む。 */
|
|
45
|
+
const readWestern = (written: string): number =>
|
|
46
|
+
Number([...toHalfWidth(written)].map((char) => (KANJI_DIGITS.includes(char) ? String(KANJI_DIGITS.indexOf(char)) : char)).join(""));
|
|
47
|
+
|
|
48
|
+
const glossedOf = (match: RegExpExecArray, eras: readonly Era[]): GlossedYear[] => {
|
|
49
|
+
const groups = match.groups ?? {};
|
|
50
|
+
const era = eras.find((candidate) => candidate.name === groups["era"]);
|
|
51
|
+
const number = eraNumber(groups["n"] ?? "");
|
|
52
|
+
const western = readWestern(groups["w"] ?? "");
|
|
53
|
+
if (era === undefined || number === undefined || number < 1) return [];
|
|
54
|
+
const fromEra = era.firstYear + number - 1;
|
|
55
|
+
const eraFirst = match[0].startsWith(era.name);
|
|
56
|
+
const [year, glossYear] = eraFirst ? [fromEra, western] : [western, fromEra];
|
|
57
|
+
return [{ start: match.index, end: match.index + match[0].length, year, glossYear }];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** 文の中の、括弧で言い換えた年を読む関数。書き方ごとに探し、出てきた順に並べる。元号が無ければ何も読まない。 */
|
|
61
|
+
export const glossedYearReader = (eras: readonly Era[]): ((text: string) => GlossedYear[]) => {
|
|
62
|
+
if (eras.length === 0) return () => [];
|
|
63
|
+
const patterns = shapes(eras.map((era) => escapeRegExp(era.name)).join("|")).map((shape) => new RegExp(shape, "gu"));
|
|
64
|
+
return (text) =>
|
|
65
|
+
patterns.flatMap((pattern) => [...text.matchAll(pattern)].flatMap((match) => glossedOf(match, eras))).toSorted((left, right) => left.start - right.start);
|
|
66
|
+
};
|
package/src/lexicons.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { parse } from "yaml";
|
|
2
2
|
import type { Lexicon, LexiconEntry } from "chaffjs/plugin";
|
|
3
3
|
import { PACKAGE_DIR, joinPath, readDir, readText } from "./package-files.ts";
|
|
4
|
+
import type { Era } from "./era-year.ts";
|
|
4
5
|
|
|
5
6
|
const DIR = joinPath(PACKAGE_DIR, "lexicons");
|
|
6
7
|
|
|
7
8
|
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
9
|
|
|
10
|
+
const isStringList = (value: unknown): value is string[] => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
11
|
+
|
|
9
12
|
const POSITIONS = ["before", "after"] as const;
|
|
10
13
|
|
|
11
14
|
const toEntry = (raw: unknown): LexiconEntry | undefined => {
|
|
@@ -14,6 +17,8 @@ const toEntry = (raw: unknown): LexiconEntry | undefined => {
|
|
|
14
17
|
const instead = raw["instead_of"];
|
|
15
18
|
const rewrite = raw["rewrite"];
|
|
16
19
|
const group = raw["group"];
|
|
20
|
+
const genres = raw["genres"];
|
|
21
|
+
const firstYear = raw["first_year"];
|
|
17
22
|
return {
|
|
18
23
|
pattern: raw["pattern"],
|
|
19
24
|
weight: typeof weight === "number" ? weight : undefined,
|
|
@@ -21,6 +26,8 @@ const toEntry = (raw: unknown): LexiconEntry | undefined => {
|
|
|
21
26
|
position: POSITIONS.find((position) => position === raw["position"]),
|
|
22
27
|
rewrite: typeof rewrite === "string" ? rewrite : undefined,
|
|
23
28
|
...(typeof group === "string" ? { group } : {}),
|
|
29
|
+
...(isStringList(genres) ? { genres } : {}),
|
|
30
|
+
...(typeof firstYear === "number" ? { first_year: firstYear } : {}),
|
|
24
31
|
};
|
|
25
32
|
};
|
|
26
33
|
|
|
@@ -38,3 +45,14 @@ export const loadLexicons = (dir: string = DIR): Record<string, Lexicon> =>
|
|
|
38
45
|
return [[raw["id"], raw["entries"].map(toEntry).filter((entry) => entry !== undefined)]];
|
|
39
46
|
}),
|
|
40
47
|
);
|
|
48
|
+
|
|
49
|
+
const CALENDAR_ERA = "calendar-era.yaml";
|
|
50
|
+
|
|
51
|
+
const toEra = (raw: unknown): Era[] =>
|
|
52
|
+
isRecord(raw) && typeof raw["pattern"] === "string" && typeof raw["first_year"] === "number" ? [{ name: raw["pattern"], firstYear: raw["first_year"] }] : [];
|
|
53
|
+
|
|
54
|
+
/** 語彙表 calendar-era の元号と、その元年の西暦の年。first_year の無い元号は西暦にできないので入れない。 */
|
|
55
|
+
export const loadCalendarEras = (dir: string = DIR): Era[] => {
|
|
56
|
+
const raw: unknown = parse(readText(joinPath(dir, CALENDAR_ERA)));
|
|
57
|
+
return isRecord(raw) && Array.isArray(raw["entries"]) ? raw["entries"].flatMap(toEra) : [];
|
|
58
|
+
};
|
package/src/numbers.ts
CHANGED
|
@@ -19,16 +19,20 @@ const step = (acc: Reading, char: string): Reading => {
|
|
|
19
19
|
return { done: acc.done, total: acc.total, current: acc.current * 10 + (DIGIT[char] ?? 0) };
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
/** 算用数字の後ろの桁の語: 万・億、その前の十・百・千(百万 = 10^6、十億)、千だけ(千円単位の表)。 */
|
|
23
|
+
const ARABIC_SCALED = /^(?<n>\d+(?:\.\d+)?)(?<scale>[十百千]?[万億]|千)$/u;
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
26
|
* 番号や数を数にする。全角数字は半角に、漢数字は位取りで読む(十二 = 12、二十一 = 21、百五 = 105、一〇 = 10)。
|
|
24
|
-
*
|
|
27
|
+
* 算用数字と桁の語の組(「10万」、決算の表の「2,400百万」「1,320千」)も読む。小数(「1.5」)も読む。読めないものは undefined。
|
|
25
28
|
* 番号を読み違えると番地が変わり、参照先が無いという誤りを作ってしまう。
|
|
26
29
|
*/
|
|
27
30
|
export const parseJapaneseNumber = (text: string): number | undefined => {
|
|
28
31
|
const half = toHalfWidth(text).replace(/,/gu, "");
|
|
29
32
|
if (/^\d+(?:\.\d+)?$/u.test(half)) return Number(half);
|
|
30
|
-
const
|
|
31
|
-
|
|
33
|
+
const arabicScaled = ARABIC_SCALED.exec(half)?.groups;
|
|
34
|
+
const scale = arabicScaled?.["scale"] === undefined ? undefined : parseJapaneseNumber(arabicScaled["scale"]);
|
|
35
|
+
if (arabicScaled?.["n"] !== undefined && scale !== undefined) return Number(arabicScaled["n"]) * scale;
|
|
32
36
|
if (!/^[〇一二三四五六七八九十百千万億]+$/u.test(text)) return undefined;
|
|
33
37
|
const { done, total, current } = [...text].reduce(step, { done: 0, total: 0, current: 0 });
|
|
34
38
|
return done + total + current;
|