@chaffjs/lang-en 0.21.0 → 0.23.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/browser/package-files.d.ts +6 -0
- package/dist/browser/package-files.d.ts.map +1 -0
- package/dist/browser/package-files.js +10 -0
- package/dist/browser/package-files.js.map +1 -0
- package/dist/browser/wink-modules.d.ts +3 -0
- package/dist/browser/wink-modules.d.ts.map +1 -0
- package/dist/browser/wink-modules.js +7 -0
- package/dist/browser/wink-modules.js.map +1 -0
- package/dist/dates.d.ts.map +1 -1
- package/dist/dates.js +54 -2
- package/dist/dates.js.map +1 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +46 -3
- package/dist/definitions.js.map +1 -1
- package/dist/dictionary.d.ts.map +1 -1
- package/dist/dictionary.js +3 -5
- package/dist/dictionary.js.map +1 -1
- package/dist/gerund.d.ts +7 -0
- package/dist/gerund.d.ts.map +1 -0
- package/dist/gerund.js +14 -0
- package/dist/gerund.js.map +1 -0
- package/dist/lexicons.d.ts.map +1 -1
- package/dist/lexicons.js +4 -6
- package/dist/lexicons.js.map +1 -1
- package/dist/package-files.d.ts +7 -0
- package/dist/package-files.d.ts.map +1 -0
- package/dist/package-files.js +12 -0
- package/dist/package-files.js.map +1 -0
- package/dist/pos.d.ts.map +1 -1
- package/dist/pos.js +5 -5
- package/dist/pos.js.map +1 -1
- package/dist/wink-modules.d.ts +5 -0
- package/dist/wink-modules.d.ts.map +1 -0
- package/dist/wink-modules.js +8 -0
- package/dist/wink-modules.js.map +1 -0
- package/lexicons/breakdown-gap-joiner.yaml +8 -0
- package/lexicons/breakdown-phrase.yaml +11 -0
- package/lexicons/calendar-name.yaml +22 -0
- package/lexicons/company-form.yaml +15 -0
- package/lexicons/comparative-baseline.yaml +41 -0
- package/lexicons/concrete-deadline.yaml +19 -0
- package/lexicons/deadline-permission.yaml +7 -0
- package/lexicons/demonstrative-not-opener.yaml +125 -0
- package/lexicons/demonstrative-opener.yaml +10 -0
- package/lexicons/discount-word.yaml +10 -0
- package/lexicons/extra-word.yaml +1 -0
- package/lexicons/generic-heading-label.yaml +13 -0
- package/lexicons/party-role.yaml +23 -0
- package/lexicons/party-short-name.yaml +7 -0
- package/lexicons/quote-attribution.yaml +21 -0
- package/lexicons/total-phrase.yaml +11 -0
- package/lexicons/unit-symbol.yaml +32 -0
- package/lexicons/vague-deadline.yaml +16 -0
- package/lexicons/year-reference.yaml +52 -0
- package/package.json +7 -1
- package/src/browser/package-files.ts +15 -0
- package/src/browser/wink-modules.ts +9 -0
- package/src/browser/wink.d.ts +10 -0
- package/src/dates.ts +56 -2
- package/src/definitions.ts +54 -3
- package/src/dictionary.ts +3 -5
- package/src/gerund.ts +15 -0
- package/src/lexicons.ts +4 -6
- package/src/package-files.ts +16 -0
- package/src/pos.ts +5 -6
- package/src/wink-modules.ts +11 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Words comparative-without-baseline reads: a comparison that names nothing to compare with ("The new engine is faster.").
|
|
2
|
+
# more: the word that makes a comparative of an adjective ("is more efficient.").
|
|
3
|
+
# comparative: one-word comparatives read when they close a clause after a verb ("is faster.", "runs better,").
|
|
4
|
+
# baseline: words that name what is compared with. One in the same sentence or the one before, and the comparison has
|
|
5
|
+
# its baseline.
|
|
6
|
+
# condition: a word before the comparative that puts it under a condition or a hypothesis ("if it looks better", "would be
|
|
7
|
+
# easier"); the comparison is then with the case without it.
|
|
8
|
+
id: comparative-baseline
|
|
9
|
+
language: en
|
|
10
|
+
entries:
|
|
11
|
+
- { pattern: more, group: more }
|
|
12
|
+
- { pattern: faster, group: comparative }
|
|
13
|
+
- { pattern: better, group: comparative }
|
|
14
|
+
- { pattern: quicker, group: comparative }
|
|
15
|
+
- { pattern: easier, group: comparative }
|
|
16
|
+
- { pattern: simpler, group: comparative }
|
|
17
|
+
- { pattern: cheaper, group: comparative }
|
|
18
|
+
- { pattern: safer, group: comparative }
|
|
19
|
+
- { pattern: smarter, group: comparative }
|
|
20
|
+
- { pattern: stronger, group: comparative }
|
|
21
|
+
- { pattern: smoother, group: comparative }
|
|
22
|
+
- { pattern: than, group: baseline }
|
|
23
|
+
- { pattern: before, group: baseline }
|
|
24
|
+
- { pattern: previous, group: baseline }
|
|
25
|
+
- { pattern: previously, group: baseline }
|
|
26
|
+
- { pattern: earlier, group: baseline }
|
|
27
|
+
- { pattern: prior, group: baseline }
|
|
28
|
+
- { pattern: old, group: baseline }
|
|
29
|
+
- { pattern: older, group: baseline }
|
|
30
|
+
- { pattern: original, group: baseline }
|
|
31
|
+
- { pattern: existing, group: baseline }
|
|
32
|
+
- { pattern: compared, group: baseline }
|
|
33
|
+
- { pattern: versus, group: baseline }
|
|
34
|
+
- { pattern: vs, group: baseline }
|
|
35
|
+
- { pattern: if, group: condition }
|
|
36
|
+
- { pattern: unless, group: condition }
|
|
37
|
+
- { pattern: would, group: condition }
|
|
38
|
+
- { pattern: "'d", group: condition }
|
|
39
|
+
- { pattern: could, group: condition }
|
|
40
|
+
- { pattern: might, group: condition }
|
|
41
|
+
- { pattern: may, group: condition }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# How a time limit stated as a number is written. A sentence holding one has a deadline, and vague-deadline leaves it; the
|
|
2
|
+
# document's count of these sentences is what its vague limits are compared with. "within … days" is a frame: "days" within
|
|
3
|
+
# a few words after "within". A bare unit ("24 hours a day", "on business days") is not a deadline, so units stand only in frames.
|
|
4
|
+
id: concrete-deadline
|
|
5
|
+
language: en
|
|
6
|
+
entries:
|
|
7
|
+
- pattern: within … day
|
|
8
|
+
- pattern: within … hours
|
|
9
|
+
- pattern: within … week
|
|
10
|
+
- pattern: within … month
|
|
11
|
+
- pattern: no later than
|
|
12
|
+
- pattern: business day of
|
|
13
|
+
- pattern: days of
|
|
14
|
+
- pattern: days after
|
|
15
|
+
- pattern: days before
|
|
16
|
+
- pattern: days prior
|
|
17
|
+
- pattern: days following
|
|
18
|
+
- pattern: days from
|
|
19
|
+
- pattern: days' notice
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Words that make a sentence a right rather than a duty ("We may promptly suspend your account"). A vague limit in such a
|
|
2
|
+
# sentence sets no deadline anyone must meet, so vague-deadline leaves it.
|
|
3
|
+
id: deadline-permission
|
|
4
|
+
language: en
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: may
|
|
7
|
+
- pattern: can
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Openings with This, That or It that do not point back at the sentence before: the document itself ("This Agreement
|
|
2
|
+
# may be modified…", "This section explains…"), an "it" that stands for what follows ("It is worth noting that…"), and a
|
|
3
|
+
# "that" that opens a clause ("That the plan failed is clear"). An "it" before an adjective listed here is read as standing
|
|
4
|
+
# for what follows; one that points back there is missed, never misreported. demonstrative-opener-run does not count a
|
|
5
|
+
# sentence that opens with one.
|
|
6
|
+
id: demonstrative-not-opener
|
|
7
|
+
language: en
|
|
8
|
+
entries:
|
|
9
|
+
- pattern: this agreement
|
|
10
|
+
- pattern: these terms
|
|
11
|
+
- pattern: this document
|
|
12
|
+
- pattern: this section
|
|
13
|
+
- pattern: this subsection
|
|
14
|
+
- pattern: this chapter
|
|
15
|
+
- pattern: this part
|
|
16
|
+
- pattern: this article
|
|
17
|
+
- pattern: this policy
|
|
18
|
+
- pattern: this statement
|
|
19
|
+
- pattern: this notice
|
|
20
|
+
- pattern: this report
|
|
21
|
+
- pattern: this paper
|
|
22
|
+
- pattern: this page
|
|
23
|
+
- pattern: this guide
|
|
24
|
+
- pattern: this memo
|
|
25
|
+
- pattern: this specification
|
|
26
|
+
- pattern: this rfc
|
|
27
|
+
- pattern: this act
|
|
28
|
+
- pattern: this appendix
|
|
29
|
+
- pattern: it should be noted
|
|
30
|
+
- pattern: it seems
|
|
31
|
+
- pattern: it appears
|
|
32
|
+
- pattern: it turns out
|
|
33
|
+
- pattern: it is worth
|
|
34
|
+
- pattern: it was worth
|
|
35
|
+
- pattern: it is important
|
|
36
|
+
- pattern: it was important
|
|
37
|
+
- pattern: it is possible
|
|
38
|
+
- pattern: it was possible
|
|
39
|
+
- pattern: it is impossible
|
|
40
|
+
- pattern: it was impossible
|
|
41
|
+
- pattern: it is necessary
|
|
42
|
+
- pattern: it was necessary
|
|
43
|
+
- pattern: it is likely
|
|
44
|
+
- pattern: it was likely
|
|
45
|
+
- pattern: it is unlikely
|
|
46
|
+
- pattern: it was unlikely
|
|
47
|
+
- pattern: it is clear
|
|
48
|
+
- pattern: it was clear
|
|
49
|
+
- pattern: it is unclear
|
|
50
|
+
- pattern: it was unclear
|
|
51
|
+
- pattern: it is obvious
|
|
52
|
+
- pattern: it was obvious
|
|
53
|
+
- pattern: it is evident
|
|
54
|
+
- pattern: it was evident
|
|
55
|
+
- pattern: it is recommended
|
|
56
|
+
- pattern: it was recommended
|
|
57
|
+
- pattern: it is reasonable
|
|
58
|
+
- pattern: it was reasonable
|
|
59
|
+
- pattern: it is helpful
|
|
60
|
+
- pattern: it was helpful
|
|
61
|
+
- pattern: it is useful
|
|
62
|
+
- pattern: it was useful
|
|
63
|
+
- pattern: it is essential
|
|
64
|
+
- pattern: it was essential
|
|
65
|
+
- pattern: it is difficult
|
|
66
|
+
- pattern: it was difficult
|
|
67
|
+
- pattern: it is easy
|
|
68
|
+
- pattern: it was easy
|
|
69
|
+
- pattern: it is hard
|
|
70
|
+
- pattern: it was hard
|
|
71
|
+
- pattern: it is true
|
|
72
|
+
- pattern: it was true
|
|
73
|
+
- pattern: it is natural
|
|
74
|
+
- pattern: it was natural
|
|
75
|
+
- pattern: it is common
|
|
76
|
+
- pattern: it was common
|
|
77
|
+
- pattern: it is rare
|
|
78
|
+
- pattern: it was rare
|
|
79
|
+
- pattern: it is advisable
|
|
80
|
+
- pattern: it was advisable
|
|
81
|
+
- pattern: it is better
|
|
82
|
+
- pattern: it was better
|
|
83
|
+
- pattern: it is best
|
|
84
|
+
- pattern: it was best
|
|
85
|
+
- pattern: it is enough
|
|
86
|
+
- pattern: it was enough
|
|
87
|
+
- pattern: it is fair
|
|
88
|
+
- pattern: it was fair
|
|
89
|
+
- pattern: it is safe
|
|
90
|
+
- pattern: it was safe
|
|
91
|
+
- pattern: it is tempting
|
|
92
|
+
- pattern: it was tempting
|
|
93
|
+
- pattern: it is interesting
|
|
94
|
+
- pattern: it was interesting
|
|
95
|
+
- pattern: it is surprising
|
|
96
|
+
- pattern: it was surprising
|
|
97
|
+
- pattern: it is known
|
|
98
|
+
- pattern: it was known
|
|
99
|
+
- pattern: it is expected
|
|
100
|
+
- pattern: it was expected
|
|
101
|
+
- pattern: it is assumed
|
|
102
|
+
- pattern: it was assumed
|
|
103
|
+
- pattern: it is noted
|
|
104
|
+
- pattern: it was noted
|
|
105
|
+
- pattern: it's worth
|
|
106
|
+
- pattern: that the
|
|
107
|
+
- pattern: that a
|
|
108
|
+
- pattern: that an
|
|
109
|
+
- pattern: that it
|
|
110
|
+
- pattern: that this
|
|
111
|
+
- pattern: that these
|
|
112
|
+
- pattern: that there
|
|
113
|
+
- pattern: that we
|
|
114
|
+
- pattern: that they
|
|
115
|
+
- pattern: that he
|
|
116
|
+
- pattern: that she
|
|
117
|
+
- pattern: that i
|
|
118
|
+
- pattern: that you
|
|
119
|
+
- pattern: that our
|
|
120
|
+
- pattern: that their
|
|
121
|
+
- pattern: that such
|
|
122
|
+
- pattern: that no
|
|
123
|
+
- pattern: that any
|
|
124
|
+
- pattern: that some
|
|
125
|
+
- pattern: that all
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Sentence-opening words that point back (This, That, These, Those, It). demonstrative-opener-run counts the sentences in
|
|
2
|
+
# a row, in one paragraph, that open with one of these.
|
|
3
|
+
id: demonstrative-opener
|
|
4
|
+
language: en
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: This
|
|
7
|
+
- pattern: That
|
|
8
|
+
- pattern: These
|
|
9
|
+
- pattern: Those
|
|
10
|
+
- pattern: It
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Words just before an amount that take it off a total ("a discount of $10"). total-mismatch subtracts it when it adds the items of a total in a sentence.
|
|
2
|
+
id: discount-word
|
|
3
|
+
language: en
|
|
4
|
+
entries:
|
|
5
|
+
- pattern: discount
|
|
6
|
+
- pattern: credit
|
|
7
|
+
- pattern: less
|
|
8
|
+
- pattern: minus
|
|
9
|
+
- pattern: deduction
|
|
10
|
+
- pattern: rebate
|
package/lexicons/extra-word.yaml
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Heading labels that say nothing about the section. numbered-generic-heading points at a heading that is only one of
|
|
2
|
+
# these and a number ("Benefit 1", "Tip 2"). Step, lesson, reason and feature labels are left out: in a procedure, a course,
|
|
3
|
+
# an argument or a specification the numbered unit is itself the content and is cited by its number.
|
|
4
|
+
id: generic-heading-label
|
|
5
|
+
language: en
|
|
6
|
+
entries:
|
|
7
|
+
- pattern: Benefit
|
|
8
|
+
- pattern: Advantage
|
|
9
|
+
- pattern: Disadvantage
|
|
10
|
+
- pattern: Point
|
|
11
|
+
- pattern: Key point
|
|
12
|
+
- pattern: Tip
|
|
13
|
+
- pattern: Takeaway
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Role words for a party to a contract. In a document that gave its parties short names, party-role-name points at one of
|
|
2
|
+
# these written instead, unless the document defines it. Words for people who are not parties (subcontractor) are left out.
|
|
3
|
+
id: party-role
|
|
4
|
+
language: en
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: Service Provider
|
|
7
|
+
- pattern: Provider
|
|
8
|
+
- pattern: Supplier
|
|
9
|
+
- pattern: Vendor
|
|
10
|
+
- pattern: Contractor
|
|
11
|
+
- pattern: Customer
|
|
12
|
+
- pattern: Client
|
|
13
|
+
- pattern: Company
|
|
14
|
+
- pattern: Licensor
|
|
15
|
+
- pattern: Licensee
|
|
16
|
+
- pattern: Discloser
|
|
17
|
+
- pattern: Recipient
|
|
18
|
+
- pattern: Disclosing Party
|
|
19
|
+
- pattern: Receiving Party
|
|
20
|
+
- pattern: Buyer
|
|
21
|
+
- pattern: Seller
|
|
22
|
+
- pattern: Purchaser
|
|
23
|
+
- pattern: Operator
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Words that give a quotation to someone. A quotation in the same sentence is then someone's words, not the writer's own
|
|
2
|
+
# or a title (quote-without-source). position: before is a cue that stands before the quotation (according to X, "…"); the others
|
|
3
|
+
# stand on either side (X said, "…" / "…," X said).
|
|
4
|
+
id: quote-attribution
|
|
5
|
+
language: en
|
|
6
|
+
entries:
|
|
7
|
+
- pattern: said
|
|
8
|
+
- pattern: says
|
|
9
|
+
- pattern: once said
|
|
10
|
+
- pattern: wrote
|
|
11
|
+
- pattern: writes
|
|
12
|
+
- pattern: put it
|
|
13
|
+
- pattern: puts it
|
|
14
|
+
- { pattern: according to, position: before }
|
|
15
|
+
- pattern: stated
|
|
16
|
+
- pattern: remarked
|
|
17
|
+
- pattern: famously
|
|
18
|
+
- { pattern: in the words of, position: before }
|
|
19
|
+
- pattern: quoted
|
|
20
|
+
- pattern: argued
|
|
21
|
+
- pattern: observed
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Words a total amount follows directly in a sentence ("for a total of $9,000"). total-mismatch compares the amount with the
|
|
2
|
+
# sum of the items listed before the words. A total at the start of a list or table line is total-label.
|
|
3
|
+
id: total-phrase
|
|
4
|
+
language: en
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: a total of
|
|
7
|
+
- pattern: total of
|
|
8
|
+
- pattern: totaling
|
|
9
|
+
- pattern: totalling
|
|
10
|
+
- pattern: "in total:"
|
|
11
|
+
- pattern: "total:"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Unit symbols written after a number (5 GB, 5GB). unit-spacing-consistency points at the way a document uses less: with
|
|
2
|
+
# a space between the number and the symbol, or without. Only symbols: a unit written as a word (5 hours) always takes a
|
|
3
|
+
# space. One-letter symbols (m, s, g) are left out, since "5s" and "1990s" are also plurals and decades. The percent sign
|
|
4
|
+
# is left out too: many styles that space units write 10% unspaced. Matched as written, case and all.
|
|
5
|
+
id: unit-symbol
|
|
6
|
+
language: en
|
|
7
|
+
entries:
|
|
8
|
+
- pattern: KB
|
|
9
|
+
- pattern: kB
|
|
10
|
+
- pattern: MB
|
|
11
|
+
- pattern: GB
|
|
12
|
+
- pattern: TB
|
|
13
|
+
- pattern: PB
|
|
14
|
+
- pattern: Kbps
|
|
15
|
+
- pattern: Mbps
|
|
16
|
+
- pattern: Gbps
|
|
17
|
+
- pattern: km
|
|
18
|
+
- pattern: cm
|
|
19
|
+
- pattern: mm
|
|
20
|
+
- pattern: kg
|
|
21
|
+
- pattern: mg
|
|
22
|
+
- pattern: ms
|
|
23
|
+
- pattern: Hz
|
|
24
|
+
- pattern: kHz
|
|
25
|
+
- pattern: MHz
|
|
26
|
+
- pattern: GHz
|
|
27
|
+
- pattern: kW
|
|
28
|
+
- pattern: kWh
|
|
29
|
+
- pattern: mL
|
|
30
|
+
- pattern: px
|
|
31
|
+
- pattern: dpi
|
|
32
|
+
- pattern: fps
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Time limits that leave the deadline to the reader. An obligation written with one of these alone cannot be shown to be met or
|
|
2
|
+
# missed (vague-deadline). "Immediately" means at once and leaves no period, so it is not here.
|
|
3
|
+
id: vague-deadline
|
|
4
|
+
language: en
|
|
5
|
+
entries:
|
|
6
|
+
- pattern: promptly
|
|
7
|
+
- pattern: as soon as practicable
|
|
8
|
+
- pattern: as soon as reasonably practicable
|
|
9
|
+
- pattern: as soon as possible
|
|
10
|
+
- pattern: within a reasonable time
|
|
11
|
+
- pattern: within a reasonable period
|
|
12
|
+
- pattern: without undue delay
|
|
13
|
+
- pattern: in a timely manner
|
|
14
|
+
- pattern: forthwith
|
|
15
|
+
- pattern: without delay
|
|
16
|
+
- pattern: without unreasonable delay
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Words beside a date that give its year in words. date-without-year does not report a yearless date with one of these
|
|
2
|
+
# next to it: "June 30 of that year" has a year, and "by April 15 each year" or "annually, by October 30" is every year's.
|
|
3
|
+
# An entry stands after the date unless it says before; one before may end a few characters short of the date.
|
|
4
|
+
id: year-reference
|
|
5
|
+
language: en
|
|
6
|
+
entries:
|
|
7
|
+
- pattern: of each year
|
|
8
|
+
position: after
|
|
9
|
+
- pattern: of every year
|
|
10
|
+
position: after
|
|
11
|
+
- pattern: each year
|
|
12
|
+
position: after
|
|
13
|
+
- pattern: every year
|
|
14
|
+
position: after
|
|
15
|
+
- pattern: annually
|
|
16
|
+
position: after
|
|
17
|
+
- pattern: of that year
|
|
18
|
+
position: after
|
|
19
|
+
- pattern: of the same year
|
|
20
|
+
position: after
|
|
21
|
+
- pattern: of the following year
|
|
22
|
+
position: after
|
|
23
|
+
- pattern: of the next year
|
|
24
|
+
position: after
|
|
25
|
+
- pattern: of the previous year
|
|
26
|
+
position: after
|
|
27
|
+
- pattern: of the preceding year
|
|
28
|
+
position: after
|
|
29
|
+
- pattern: of this year
|
|
30
|
+
position: after
|
|
31
|
+
- pattern: of next year
|
|
32
|
+
position: after
|
|
33
|
+
- pattern: of last year
|
|
34
|
+
position: after
|
|
35
|
+
- pattern: of the fiscal year
|
|
36
|
+
position: after
|
|
37
|
+
- pattern: annually
|
|
38
|
+
position: before
|
|
39
|
+
- pattern: each year
|
|
40
|
+
position: before
|
|
41
|
+
- pattern: every year
|
|
42
|
+
position: before
|
|
43
|
+
- pattern: that year
|
|
44
|
+
position: before
|
|
45
|
+
- pattern: the same year
|
|
46
|
+
position: before
|
|
47
|
+
- pattern: this year
|
|
48
|
+
position: before
|
|
49
|
+
- pattern: next year
|
|
50
|
+
position: before
|
|
51
|
+
- pattern: last year
|
|
52
|
+
position: before
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaffjs/lang-en",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "English language adapter for chaff",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "isamu",
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"browser": {
|
|
15
|
+
"./src/package-files.ts": "./src/browser/package-files.ts",
|
|
16
|
+
"./src/wink-modules.ts": "./src/browser/wink-modules.ts",
|
|
17
|
+
"./dist/package-files.js": "./dist/browser/package-files.js",
|
|
18
|
+
"./dist/wink-modules.js": "./dist/browser/wink-modules.js"
|
|
19
|
+
},
|
|
14
20
|
"files": [
|
|
15
21
|
"LICENSE",
|
|
16
22
|
"README.md",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { packageFiles } from "chaffjs/browser-files";
|
|
2
|
+
|
|
3
|
+
// package-files.ts in a build without a file system: this package's lexicons and word list from memory, rooted at
|
|
4
|
+
// /@chaffjs/lang-en.
|
|
5
|
+
|
|
6
|
+
const files = packageFiles("@chaffjs/lang-en");
|
|
7
|
+
|
|
8
|
+
export const PACKAGE_DIR = files.root;
|
|
9
|
+
|
|
10
|
+
/** Paths here are made only from PACKAGE_DIR and file names, so joining them needs no normalising. */
|
|
11
|
+
export const joinPath = (...parts: readonly string[]): string => parts.join("/");
|
|
12
|
+
|
|
13
|
+
export const readText = (path: string): string => files.readText(path);
|
|
14
|
+
|
|
15
|
+
export const readDir = (path: string): string[] => files.readDir(path);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import winkPosTaggerModule from "wink-pos-tagger";
|
|
2
|
+
import winkLexicon from "wink-lexicon/src/lexicon.js";
|
|
3
|
+
|
|
4
|
+
// wink-modules.ts in a bundle: the tagger and its vocabulary bundled. The vocabulary is the module the tagger itself
|
|
5
|
+
// imports, so the bundle holds it once.
|
|
6
|
+
|
|
7
|
+
export const winkPosTagger = (): unknown => winkPosTaggerModule;
|
|
8
|
+
|
|
9
|
+
export const winkLexiconWords = (): unknown => winkLexicon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// wink ships no types. The browser build imports these two CommonJS modules and reads them as unknown.
|
|
2
|
+
declare module "wink-pos-tagger" {
|
|
3
|
+
const factory: unknown;
|
|
4
|
+
export default factory;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module "wink-lexicon/src/lexicon.js" {
|
|
8
|
+
const words: unknown;
|
|
9
|
+
export default words;
|
|
10
|
+
}
|
package/src/dates.ts
CHANGED
|
@@ -41,8 +41,61 @@ const monthYear = (text: string, at: number, end: number, month: number): Mentio
|
|
|
41
41
|
return { start: before?.start ?? at, end: end + found[0].length, attrs: { value } };
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/** "March 5", not "March 5.5", "March 5:30" or "March 50". */
|
|
45
|
+
const DAY_AFTER = /^ (?<d>\d{1,2})(?:st|nd|rd|th)?(?![\w%]|[.,:]\d)/u;
|
|
46
|
+
const LAST_DAY = 31;
|
|
47
|
+
/** "Rule 3 May Apply", a title-case heading: "May" before a capitalised word may be the modal, not the month after a day. */
|
|
48
|
+
const MODAL_AFTER = /^May [A-Z]/u;
|
|
49
|
+
/** "SEP 2 form", "MAY 2 servers": a capitalised month with a day and no year is more often a code or a shout than a date. */
|
|
50
|
+
const ALL_CAPS = /^[A-Z]+$/u;
|
|
51
|
+
/** The days listed after the first, "March 5, 6 and 7, 2026": ", 6". */
|
|
52
|
+
const LISTED_DAYS = /^(?:,\s*\d{1,2}(?:st|nd|rd|th)?)*/u;
|
|
53
|
+
const LINK = /^,?\s*(?:[-–—]|to|through|until|till|and|or|&)\s*/u;
|
|
54
|
+
const LEADING_MONTH = /^[A-Z][a-z]{2,8}\.?\s+/u;
|
|
55
|
+
const LATER_DAY = /^\d{1,2}(?:st|nd|rd|th)?/u;
|
|
56
|
+
const TRAILING_MONTH = /^\s+[A-Z][a-z]{2,8}\.?/u;
|
|
57
|
+
const YEAR_NEXT = /^,?\s+\d{4}\b/u;
|
|
58
|
+
const YEAR_LATER_REACH = 60;
|
|
59
|
+
|
|
60
|
+
/** What follows a match of `pattern` at the start of `text`, or `text` itself when `pattern` is optional and absent. */
|
|
61
|
+
const after = (text: string | undefined, pattern: RegExp, optional = false): string | undefined => {
|
|
62
|
+
if (text === undefined) return undefined;
|
|
63
|
+
const found = pattern.exec(text);
|
|
64
|
+
if (found === null) return optional ? text : undefined;
|
|
65
|
+
return text.slice(found[0].length);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* "March 5 – 7, 2026", "5 March to 7 April 2026", "March 5, 6 and 7, 2026": the year written once, at the end of the
|
|
70
|
+
* range or the list, belongs to this date too, so it is not read as one without a year.
|
|
71
|
+
*/
|
|
72
|
+
const yearLater = (text: string): boolean => {
|
|
73
|
+
const linked = after(after(text, LISTED_DAYS, true), LINK);
|
|
74
|
+
const day = after(after(linked, LEADING_MONTH, true), LATER_DAY);
|
|
75
|
+
const rest = after(day, TRAILING_MONTH, true);
|
|
76
|
+
return rest !== undefined && YEAR_NEXT.test(rest);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** "2025 Dec 18" and "1872 February 4" (a citation's or an astronomer's order) carry their year in front; "Figure 3 5 May" is no date. */
|
|
80
|
+
const YEAR_OR_NUMBER_BEFORE = /\d,?\s*$/u;
|
|
81
|
+
|
|
82
|
+
const isDay = (day: string): boolean => Number(day) >= 1 && Number(day) <= LAST_DAY;
|
|
83
|
+
|
|
84
|
+
/** "March 5" or "5 March" with no year → 03-05. */
|
|
85
|
+
const monthDay = (text: string, at: number, end: number, month: number): Mention | undefined => {
|
|
86
|
+
const after = DAY_AFTER.exec(text.slice(end, end + 8));
|
|
87
|
+
const afterDay = after?.groups?.["d"];
|
|
88
|
+
const before = afterDay === undefined && !MODAL_AFTER.test(text.slice(at, end + 2)) ? dayBefore(text, at) : undefined;
|
|
89
|
+
const day = afterDay ?? before?.day;
|
|
90
|
+
const start = before?.start ?? at;
|
|
91
|
+
if (day === undefined || !isDay(day) || YEAR_OR_NUMBER_BEFORE.test(text.slice(Math.max(0, start - 6), start))) return undefined;
|
|
92
|
+
const dateEnd = after === null ? end : end + after[0].length;
|
|
93
|
+
if (yearLater(text.slice(dateEnd, dateEnd + YEAR_LATER_REACH))) return undefined;
|
|
94
|
+
return { start, end: dateEnd, attrs: { value: `${pad(String(month))}-${pad(day)}` } };
|
|
95
|
+
};
|
|
96
|
+
|
|
44
97
|
/**
|
|
45
|
-
* A month name alone is not a date: "May" is also the modal verb, so it counts only with a year beside it.
|
|
98
|
+
* A month name alone is not a date: "May" is also the modal verb, so it counts only with a year beside it, or a day.
|
|
46
99
|
* The month is found first and its neighbours read with anchored patterns, never one long alternation.
|
|
47
100
|
*/
|
|
48
101
|
const namedDate = (text: string, match: RegExpExecArray): Mention | undefined => {
|
|
@@ -51,7 +104,8 @@ const namedDate = (text: string, match: RegExpExecArray): Mention | undefined =>
|
|
|
51
104
|
const month = full === 0 ? (ABBREVIATED.get(word) ?? 0) : full;
|
|
52
105
|
if (month === 0) return undefined;
|
|
53
106
|
const end = match.index + match[0].length + (full === 0 && text.charAt(match.index + match[0].length) === "." ? 1 : 0);
|
|
54
|
-
|
|
107
|
+
const dated = monthDayYear(text, match.index, end, month) ?? monthYear(text, match.index, end, month);
|
|
108
|
+
return dated ?? (ALL_CAPS.test(match[0]) ? undefined : monthDay(text, match.index, end, month));
|
|
55
109
|
};
|
|
56
110
|
|
|
57
111
|
const hyphenatedDate = (match: RegExpExecArray): Mention[] => {
|
package/src/definitions.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CHAPTER_DEPTH, PART_DEPTH } from "./depth.ts";
|
|
|
5
5
|
|
|
6
6
|
const DEFINITIONS = [
|
|
7
7
|
/["“](?<term>[^"”\n]{1,60})["”] (?:means|shall mean|refers to|has the meaning)\b/gu,
|
|
8
|
-
/\((?:the |hereinafter )?["“](?<term>[^"”\n]{1,60})["”]\)/gu,
|
|
8
|
+
/\((?:the |these |this |hereinafter |each,? an? |collectively,? the )?["“](?<term>[^"”\n]{1,60})["”]\)/gu,
|
|
9
9
|
/\(hereinafter referred to as ["“](?<term>[^"”\n]{1,60})["”]\)/gu,
|
|
10
10
|
];
|
|
11
11
|
|
|
@@ -31,7 +31,54 @@ export const definitionScopeDepth = (text: string): number | undefined =>
|
|
|
31
31
|
const POINTER = /^ has the meaning given (?:in|by)\b/u;
|
|
32
32
|
const isPointer = (text: string, end: number): boolean => POINTER.test(text.slice(end - " has the meaning".length));
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/** ("Seller") has no word that says it defines: the same parentheses quote an example ("silently fails"). */
|
|
35
|
+
const BARE = /^\(["“]/u;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A bracket that gives one thing several names: ("Pinecone", "we" or "us"), (the "Company", "we", "us", or "our"). The
|
|
39
|
+
* first name is the inline definition (it follows the long name); the others are defined there too.
|
|
40
|
+
*/
|
|
41
|
+
const BRACKET = /\((?<inside>[^()\n]{1,300})\)/gu;
|
|
42
|
+
const QUOTED_NAME = /["“](?<term>[^"”\n]{1,60})["”]/gu;
|
|
43
|
+
/** What may come before the first name: (the "Company", (each, a "Party", (collectively, the "Parties". */
|
|
44
|
+
const LIST_LEAD = /^(?:the |collectively,? the |each,? an? )?$/u;
|
|
45
|
+
/** What may come between two names: a comma, and or or, and the. */
|
|
46
|
+
const LIST_JOINT = /^(?:, (?:and |or )?| and | or )(?:the )?$/u;
|
|
47
|
+
/** A list of names starts with a capitalised one ("Pinecone"); ("mine", "not mine", "yours") quotes examples. */
|
|
48
|
+
const CAPITALISED = /^\p{Lu}/u;
|
|
49
|
+
|
|
50
|
+
type QuotedName = { readonly term: string; readonly start: number; readonly end: number };
|
|
51
|
+
|
|
52
|
+
/** The quoted names of a bracket that holds nothing but two or more names, joined as a list; otherwise none. */
|
|
53
|
+
const namesInList = (inside: string): QuotedName[] => {
|
|
54
|
+
const names = [...inside.matchAll(QUOTED_NAME)].map((match) => ({
|
|
55
|
+
term: match.groups?.["term"] ?? "",
|
|
56
|
+
start: match.index,
|
|
57
|
+
end: match.index + match[0].length,
|
|
58
|
+
}));
|
|
59
|
+
const [first] = names;
|
|
60
|
+
if (first === undefined || names.length < 2 || !CAPITALISED.test(first.term) || !LIST_LEAD.test(inside.slice(0, first.start))) return [];
|
|
61
|
+
const joined = names.slice(1).every((name, index) => LIST_JOINT.test(inside.slice(names[index]?.end ?? 0, name.start)));
|
|
62
|
+
return joined && inside.slice(names.at(-1)?.end ?? 0) === "" ? names : [];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A bracket that gives one thing several names: ("Pinecone", "we" or "us"), (the "Company", "we", "us", or "our"). The
|
|
67
|
+
* first name is the inline definition (it follows the long name); the others are defined there too.
|
|
68
|
+
*/
|
|
69
|
+
const nameListDefinitions = (text: string): Mention[] =>
|
|
70
|
+
[...text.matchAll(BRACKET)].flatMap((match) => {
|
|
71
|
+
const inside = match.groups?.["inside"] ?? "";
|
|
72
|
+
const bare = BARE.test(match[0]) ? { form: "bare" } : {};
|
|
73
|
+
const scope = APPLIES.test(text) ? { scope: "local" } : {};
|
|
74
|
+
return namesInList(inside).map((name, index) => {
|
|
75
|
+
const start = index === 0 ? match.index : match.index + 1 + name.start;
|
|
76
|
+
const end = index === 0 ? match.index + match[0].length : match.index + 1 + name.end;
|
|
77
|
+
return { start, end, attrs: { term: name.term, ...scope, ...(index === 0 ? { placement: "inline" } : {}), ...bare } };
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const patternDefinitions = (text: string): Mention[] =>
|
|
35
82
|
DEFINITIONS.flatMap((pattern) =>
|
|
36
83
|
[...text.matchAll(pattern)].flatMap((match) => {
|
|
37
84
|
const term = match.groups?.["term"];
|
|
@@ -40,6 +87,10 @@ export const definitions = (text: string): Mention[] =>
|
|
|
40
87
|
const inline = match[0].startsWith("(");
|
|
41
88
|
const namesAParty = inline && APPLIES.test(text);
|
|
42
89
|
const scope = isPointer(text, end) || namesAParty ? { scope: "local" } : {};
|
|
43
|
-
|
|
90
|
+
const bare = BARE.test(match[0]) ? { form: "bare" } : {};
|
|
91
|
+
return [{ start: match.index, end, attrs: { term, ...scope, ...(inline ? { placement: "inline" } : {}), ...bare } }];
|
|
44
92
|
}),
|
|
45
93
|
);
|
|
94
|
+
|
|
95
|
+
export const definitions = (text: string): Mention[] =>
|
|
96
|
+
[...patternDefinitions(text), ...nameListDefinitions(text)].toSorted((left, right) => left.start - right.start);
|
package/src/dictionary.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { PACKAGE_DIR, joinPath, readText } from "./package-files.ts";
|
|
4
2
|
|
|
5
3
|
// The English word list (lexicons/dictionary.txt, built by scripts/en-dictionary.ts). It is large, so it is read only
|
|
6
4
|
// when a rule asks for it, and once.
|
|
7
5
|
|
|
8
|
-
const FILE =
|
|
6
|
+
const FILE = joinPath(PACKAGE_DIR, "lexicons", "dictionary.txt");
|
|
9
7
|
|
|
10
8
|
const loaded: { words: ReadonlySet<string> | undefined } = { words: undefined };
|
|
11
9
|
|
|
@@ -14,7 +12,7 @@ const wordsIn = (text: string): ReadonlySet<string> => new Set(text.split("\n").
|
|
|
14
12
|
export const dictionary = (): ReadonlySet<string> => {
|
|
15
13
|
if (loaded.words !== undefined) return loaded.words;
|
|
16
14
|
try {
|
|
17
|
-
loaded.words = wordsIn(
|
|
15
|
+
loaded.words = wordsIn(readText(FILE));
|
|
18
16
|
} catch (error) {
|
|
19
17
|
throw new Error(`${FILE}: cannot read the English word list`, { cause: error });
|
|
20
18
|
}
|
package/src/gerund.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// An -ing form the dictionary knows as a noun and not as an adjective (heading, finding, setting) can head a noun phrase.
|
|
2
|
+
|
|
3
|
+
const COMMON_NOUN_TAGS: ReadonlySet<string> = new Set(["NN", "NNS"]);
|
|
4
|
+
const ADJECTIVE_TAGS: ReadonlySet<string> = new Set(["JJ", "JJR", "JJS"]);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The tagger reads "A heading counts" as article + gerund + plural noun, but "heading" is also a noun, so "counts" may be its
|
|
8
|
+
* verb. AlsoNoun=Yes says so. The dictionary gives most gerunds a noun reading too (the running of), so a gerund that is
|
|
9
|
+
* also an adjective (missing, growing) stays a modifier: "a missing values" is a slip.
|
|
10
|
+
*/
|
|
11
|
+
export const gerundFeatures = (surface: string, tagsOf: (word: string) => readonly string[] | undefined): Readonly<Record<string, string>> => {
|
|
12
|
+
const tags = tagsOf(surface.toLowerCase()) ?? [];
|
|
13
|
+
const nounOnly = tags.some((tag) => COMMON_NOUN_TAGS.has(tag)) && !tags.some((tag) => ADJECTIVE_TAGS.has(tag));
|
|
14
|
+
return nounOnly ? { VerbForm: "Ger", AlsoNoun: "Yes" } : { VerbForm: "Ger" };
|
|
15
|
+
};
|