@chaffjs/lang-en 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.
Files changed (59) hide show
  1. package/dist/definitions.d.ts.map +1 -1
  2. package/dist/definitions.js +18 -6
  3. package/dist/definitions.js.map +1 -1
  4. package/dist/emphasis.d.ts +8 -0
  5. package/dist/emphasis.d.ts.map +1 -1
  6. package/dist/emphasis.js +18 -0
  7. package/dist/emphasis.js.map +1 -1
  8. package/dist/pos.d.ts.map +1 -1
  9. package/dist/pos.js +6 -3
  10. package/dist/pos.js.map +1 -1
  11. package/lexicons/advice-opener.yaml +12 -0
  12. package/lexicons/any-year-marker.yaml +22 -2
  13. package/lexicons/breakdown-partial-word.yaml +14 -0
  14. package/lexicons/capacity-marker.yaml +7 -0
  15. package/lexicons/capital-phrase.yaml +7 -0
  16. package/lexicons/carrier-name.yaml +11 -0
  17. package/lexicons/citation-series.yaml +11 -0
  18. package/lexicons/closing-balance-label.yaml +3 -0
  19. package/lexicons/concrete-deadline.yaml +1 -0
  20. package/lexicons/contraction.yaml +4 -3
  21. package/lexicons/dated-pair-label.yaml +35 -5
  22. package/lexicons/dated-pair-version-word.yaml +7 -0
  23. package/lexicons/dated-signer-label.yaml +11 -0
  24. package/lexicons/dated-span-label.yaml +4 -2
  25. package/lexicons/defined-elsewhere.yaml +12 -0
  26. package/lexicons/fact-attribute.yaml +22 -0
  27. package/lexicons/fact-document-term.yaml +6 -0
  28. package/lexicons/fact-per-unit.yaml +10 -0
  29. package/lexicons/fact-term-restating.yaml +10 -0
  30. package/lexicons/heading-announcer.yaml +46 -0
  31. package/lexicons/instruction-verb.yaml +10 -0
  32. package/lexicons/legal-form.yaml +28 -0
  33. package/lexicons/name-determiner.yaml +25 -0
  34. package/lexicons/name-prefix.yaml +7 -0
  35. package/lexicons/name-title-joiner.yaml +3 -1
  36. package/lexicons/page-marker.yaml +8 -0
  37. package/lexicons/piece-count-column.yaml +19 -0
  38. package/lexicons/placeholder-word.yaml +12 -0
  39. package/lexicons/proper-name-word.yaml +10 -2
  40. package/lexicons/reference-label.yaml +26 -0
  41. package/lexicons/reference-list-joint.yaml +16 -0
  42. package/lexicons/request-condition.yaml +3 -0
  43. package/lexicons/request-contact.yaml +11 -0
  44. package/lexicons/request-deadline.yaml +2 -0
  45. package/lexicons/request-invitation.yaml +10 -0
  46. package/lexicons/request-timing.yaml +11 -0
  47. package/lexicons/requirement-loophole.yaml +3 -0
  48. package/lexicons/section-name-noun.yaml +10 -0
  49. package/lexicons/street-suffix.yaml +16 -0
  50. package/lexicons/tax-code.yaml +7 -0
  51. package/lexicons/timed-pair-label.yaml +8 -0
  52. package/lexicons/total-back-reference.yaml +16 -0
  53. package/lexicons/total-breakdown-lead.yaml +9 -0
  54. package/lexicons/unnumbered-heading.yaml +13 -0
  55. package/lexicons/vague-word-term-of-art.yaml +21 -0
  56. package/package.json +1 -1
  57. package/src/definitions.ts +17 -6
  58. package/src/emphasis.ts +22 -0
  59. package/src/pos.ts +6 -3
@@ -0,0 +1,46 @@
1
+ # Words in a section's first sentence that announce or point at the section instead of saying something about its
2
+ # subject (This section covers installation. Charges are described below.). heading-echo still reports a sentence whose
3
+ # only predicate is one of these; a sentence with a verb or a copula's complement of its own (All charges include sales
4
+ # tax.) states a fact and is not reported. Matched against the word's base form. group copula: a linking verb, whose
5
+ # complement on the given side is the predicate. group negation: a word that denies what the copula links (There are no
6
+ # issues.), which is a claim. An imperative with one of these verbs (Give feedback in private.) is still reported.
7
+ id: heading-announcer
8
+ language: en
9
+ entries:
10
+ - pattern: be
11
+ group: copula
12
+ position: after
13
+ - pattern: "no"
14
+ group: negation
15
+ - pattern: not
16
+ group: negation
17
+ - pattern: never
18
+ group: negation
19
+ - pattern: n't
20
+ group: negation
21
+ - pattern: cover
22
+ - pattern: describe
23
+ - pattern: explain
24
+ - pattern: list
25
+ - pattern: outline
26
+ - pattern: introduce
27
+ - pattern: discuss
28
+ - pattern: summarize
29
+ - pattern: summarise
30
+ - pattern: show
31
+ - pattern: detail
32
+ - pattern: provide
33
+ - pattern: contain
34
+ - pattern: give
35
+ - pattern: tell
36
+ - pattern: mention
37
+ - pattern: read
38
+ - pattern: let
39
+ - pattern: see
40
+ - pattern: refer
41
+ - pattern: below
42
+ - pattern: following
43
+ - pattern: follow
44
+ - pattern: section
45
+ - pattern: chapter
46
+ - pattern: page
@@ -0,0 +1,10 @@
1
+ # Verbs that open an instruction (Click Save, Scroll down) but that the tagger's dictionary knows only as nouns or not
2
+ # at all. list-item-form-mix reads a list item opening with one as opening with a verb. A word the tagger already reads
3
+ # as a verb (select, tap) needs no entry. Matched in lower case.
4
+ id: instruction-verb
5
+ language: en
6
+ entries:
7
+ - pattern: click
8
+ - pattern: scroll
9
+ - pattern: swipe
10
+ - pattern: toggle
@@ -0,0 +1,28 @@
1
+ # Legal forms written in capitals after a company's name (JVLS, LLC; TRATON SE; GitLab Singapore PTE. LTD.). Part of the
2
+ # name, not an acronym to spell out; read only right after a capitalised word or a closing bracket. CO counts only with its
3
+ # period (CO., LTD.) and NV is left out: both are also US states (Denver, CO 80202). Matched as written.
4
+ id: legal-form
5
+ language: en
6
+ entries:
7
+ - pattern: "LLC"
8
+ - pattern: "LLP"
9
+ - pattern: "LP"
10
+ - pattern: "INC"
11
+ - pattern: "LTD"
12
+ - pattern: "PLC"
13
+ - pattern: "CORP"
14
+ - pattern: "CO."
15
+ - pattern: "SE"
16
+ - pattern: "AG"
17
+ - pattern: "KG"
18
+ - pattern: "BV"
19
+ - pattern: "SA"
20
+ - pattern: "SAS"
21
+ - pattern: "SPA"
22
+ - pattern: "PTE"
23
+ - pattern: "PTY"
24
+ - pattern: "GK"
25
+ - pattern: "KK"
26
+ - pattern: "AB"
27
+ - pattern: "ASA"
28
+ - pattern: "OYJ"
@@ -0,0 +1,25 @@
1
+ # Words that open a noun phrase (the, this, each, our). Capitalised at the start of a sentence (The SE team), they are still
2
+ # not part of a company's name, so a legal form right after one is read as an acronym. Matched without regard to case.
3
+ id: name-determiner
4
+ language: en
5
+ entries:
6
+ - pattern: "the"
7
+ - pattern: "a"
8
+ - pattern: "an"
9
+ - pattern: "this"
10
+ - pattern: "that"
11
+ - pattern: "these"
12
+ - pattern: "those"
13
+ - pattern: "each"
14
+ - pattern: "every"
15
+ - pattern: "any"
16
+ - pattern: "no"
17
+ - pattern: "some"
18
+ - pattern: "all"
19
+ - pattern: "our"
20
+ - pattern: "your"
21
+ - pattern: "their"
22
+ - pattern: "its"
23
+ - pattern: "his"
24
+ - pattern: "her"
25
+ - pattern: "my"
@@ -0,0 +1,7 @@
1
+ # Words written before a capitalised word to make a name (HM Revenue & Customs, HM Treasury, HMS Victory). Matched as written.
2
+ id: name-prefix
3
+ language: en
4
+ entries:
5
+ - pattern: "HM"
6
+ - pattern: "HMS"
7
+ - pattern: "HRH"
@@ -1,9 +1,11 @@
1
1
  # Small words inside a Title Case name ("Foundations of Statistics", "Bank of the West"). name-variant reads capitalised
2
2
  # words across them as one name when it compares names written with the same words in another order. "and", "to" and
3
- # "with" are left out: across them stand two names ("Texas and Florida"), not one.
3
+ # "with" are left out: across them stand two names ("Texas and Florida"), not one. An article (group: article) joins only
4
+ # right after another small word ("of the"): alone it starts a new phrase ("this Agreement the Stockholders").
4
5
  id: name-title-joiner
5
6
  language: en
6
7
  entries:
7
8
  - pattern: of
8
9
  - pattern: for
9
10
  - pattern: the
11
+ group: article
@@ -0,0 +1,8 @@
1
+ # Page markers a converted print edition leaves inside a sentence: the Federal Register's web edition
2
+ # ("remediation ( printed page 52044) workflows") and the GPO text edition ("[[Page 52044]]"). max-sentence-length does
3
+ # not count them. "#" stands for the page number, and a space for any run of spaces, none included.
4
+ id: page-marker
5
+ language: en
6
+ entries:
7
+ - pattern: "( printed page #)"
8
+ - pattern: "[[Page #]]"
@@ -0,0 +1,19 @@
1
+ # A quantity column that counts whatever its row hires or buys: "4 days" for the car, then "1" for one child seat
2
+ # (number-without-unit). group: column is the column's heading; group: period is a unit of a hired period. In a column
3
+ # whose other values carry a period unit, a bare whole number is a count of pieces, not a value that lost its unit.
4
+ id: piece-count-column
5
+ language: en
6
+ entries:
7
+ - { pattern: Quantity, group: column }
8
+ - { pattern: Qty, group: column }
9
+ - { pattern: Qty., group: column }
10
+ - { pattern: day, group: period }
11
+ - { pattern: days, group: period }
12
+ - { pattern: night, group: period }
13
+ - { pattern: nights, group: period }
14
+ - { pattern: week, group: period }
15
+ - { pattern: weeks, group: period }
16
+ - { pattern: month, group: period }
17
+ - { pattern: months, group: period }
18
+ - { pattern: hour, group: period }
19
+ - { pattern: hours, group: period }
@@ -25,3 +25,15 @@ entries:
25
25
  group: marker
26
26
  - pattern: FIXME
27
27
  group: marker
28
+ # group: template — a word that, in a heading, says the section is a template ("## Template", "# Sample letter").
29
+ # Blanks under that heading (to the next heading at its depth or above) are what the template is for, so they are not reported.
30
+ - pattern: template
31
+ group: template
32
+ - pattern: templates
33
+ group: template
34
+ - pattern: sample letter
35
+ group: template
36
+ - pattern: model letter
37
+ group: template
38
+ - pattern: model form
39
+ group: template
@@ -1,6 +1,7 @@
1
1
  # Words that make a capitalised run a name, not a term the document defines: of a law or a document (the Federal Trade
2
- # Commission Act, Acceptable Use Policies, the GitHub Privacy Statement), of a body (the Department of Commerce), of a place
3
- # (the State of New York), of the parties (the Parties, the Indemnifying Party), and words English capitalises by convention (the Internet). undefined-term leaves every run that
2
+ # Commission Act, Acceptable Use Policies, the GitHub Privacy Statement), of a body (the Department of Commerce, the World
3
+ # Health Organization), of a place (the State of New York), of the parties (the Parties, the Indemnifying Party), of an office
4
+ # (the Chief Executive Officer, the President), and words English capitalises by convention (the Internet, the Web, acts of God). undefined-term leaves every run that
4
5
  # holds one of these, in its singular or plural form, as it leaves places (place-region), weekdays and months, company
5
6
  # forms and party roles. Matched as written, word by word.
6
7
  id: proper-name-word
@@ -43,6 +44,8 @@ entries:
43
44
  - pattern: Foundation
44
45
  - pattern: Association
45
46
  - pattern: Institute
47
+ - pattern: Organization
48
+ - pattern: Organisation
46
49
  - pattern: University
47
50
  - pattern: List
48
51
  - pattern: State
@@ -52,4 +55,9 @@ entries:
52
55
  - pattern: Republic
53
56
  - pattern: Kingdom
54
57
  - pattern: Internet
58
+ - pattern: Web
59
+ - pattern: God
60
+ - pattern: Officer
61
+ - pattern: President
62
+ - pattern: Director
55
63
  - pattern: Party
@@ -122,6 +122,13 @@ entries:
122
122
  - { pattern: sku, group: item }
123
123
  - { pattern: product code, group: item }
124
124
  - { pattern: product code is, group: item }
125
+ # A product's model. Like item codes, two labelled or tabled models are two products and are never compared.
126
+ - { pattern: model, group: model }
127
+ - { pattern: model is, group: model }
128
+ - { pattern: model number, group: model }
129
+ - { pattern: model number is, group: model }
130
+ - { pattern: model no., group: model }
131
+ - { pattern: model no, group: model }
125
132
  # A vehicle's plate. A bare "Registration" is not one: an attendee's registration is written so too.
126
133
  - { pattern: registration plate, group: vehicle }
127
134
  - { pattern: registration plate is, group: vehicle }
@@ -149,3 +156,22 @@ entries:
149
156
  - { pattern: member no, group: member }
150
157
  - { pattern: customer number, group: customer }
151
158
  - { pattern: customer number is, group: customer }
159
+ # An incident's number. A postmortem and a support ticket may be numbered apart from the incident, so each is a group of its own.
160
+ # A bare "incident" is not a label (an incident in March); a code with no label is still compared with the one labelled code it swaps to.
161
+ - { pattern: incident number, group: incident }
162
+ - { pattern: incident number is, group: incident }
163
+ - { pattern: incident no., group: incident }
164
+ - { pattern: incident no, group: incident }
165
+ - { pattern: incident id, group: incident }
166
+ - { pattern: incident id is, group: incident }
167
+ - { pattern: postmortem id, group: postmortem }
168
+ - { pattern: postmortem id is, group: postmortem }
169
+ - { pattern: postmortem number, group: postmortem }
170
+ - { pattern: postmortem number is, group: postmortem }
171
+ - { pattern: ticket, group: ticket }
172
+ - { pattern: ticket number, group: ticket }
173
+ - { pattern: ticket number is, group: ticket }
174
+ - { pattern: ticket no., group: ticket }
175
+ - { pattern: ticket no, group: ticket }
176
+ - { pattern: ticket id, group: ticket }
177
+ - { pattern: ticket id is, group: ticket }
@@ -0,0 +1,16 @@
1
+ # Words and marks that, alone between two references, make them one list or range (reference-title-mismatch): "sections 9
2
+ # to 11 (stay of legal proceedings)". A name in brackets after such a list names the group, not the last section. A bare
3
+ # comma is not one: "Subject to section 5, section 7 (Pricing) applies" names section 7 alone; a list ends in "and" or "or".
4
+ # Japanese has no such list: in 第三条、第三十九条(第七項を除く。) the bracket binds to the article right before it.
5
+ id: reference-list-joint
6
+ language: en
7
+ entries:
8
+ - pattern: "and"
9
+ - pattern: "or"
10
+ - pattern: ", and"
11
+ - pattern: ", or"
12
+ - pattern: "and/or"
13
+ - pattern: "to"
14
+ - pattern: "through"
15
+ - pattern: "-"
16
+ - pattern: –
@@ -13,3 +13,6 @@ entries:
13
13
  - pattern: as needed
14
14
  - pattern: where needed
15
15
  - pattern: if needed
16
+ - pattern: those who wish
17
+ - pattern: anyone who wishes
18
+ - pattern: anyone interested
@@ -0,0 +1,11 @@
1
+ # Labels of a contact line ("Phone:", "Fax:"), counted only when a colon follows. A request in the same sentence as that line
2
+ # says how to reach the writer.
3
+ id: request-contact
4
+ language: en
5
+ entries:
6
+ - pattern: phone
7
+ - pattern: tel
8
+ - pattern: telephone
9
+ - pattern: fax
10
+ - pattern: email
11
+ - pattern: e-mail
@@ -65,3 +65,5 @@ entries:
65
65
  - pattern: dec
66
66
  - pattern: immediately
67
67
  - pattern: urgently
68
+ - pattern: any time
69
+ - pattern: anytime
@@ -0,0 +1,10 @@
1
+ # Invitation verbs. Right at the request ("please come", "please join us"), coming is the reader's choice: nothing is to be finished.
2
+ id: request-invitation
3
+ language: en
4
+ entries:
5
+ - pattern: come
6
+ - pattern: join us
7
+ - pattern: visit
8
+ - pattern: drop by
9
+ - pattern: stop by
10
+ - pattern: consult
@@ -0,0 +1,11 @@
1
+ # Words in the request that say when relative to something else ("after you submit", "in advance"). The date is not
2
+ # given, but when to act is. Counted only in the request itself: the next sentence's "after that" is about something else.
3
+ id: request-timing
4
+ language: en
5
+ entries:
6
+ - pattern: after you
7
+ - pattern: once you
8
+ - pattern: in advance
9
+ - pattern: beforehand
10
+ - pattern: at the time of
11
+ - pattern: upon receipt
@@ -5,7 +5,10 @@ language: en
5
5
  entries:
6
6
  - pattern: as far as possible
7
7
  - pattern: as much as possible
8
+ # group: time is a loophole about when. A number of days in the same sentence (concrete-deadline) bounds it:
9
+ # "as soon as possible, but in any event no later than two Business Days after".
8
10
  - pattern: as soon as possible
11
+ group: time
9
12
  - pattern: as fast as possible
10
13
  - pattern: to the extent possible
11
14
  - pattern: if possible
@@ -0,0 +1,10 @@
1
+ # Nouns that turn "section N" into the name of a thing defined by another Act: "a section 21 notice", "a section 8 form".
2
+ # dangling-reference reads every "section 21" in a document that writes "section 21 notice" as that Act's section, not
3
+ # one of its own. Only the lower-case "section" counts: a contract's "Section 5 notice" points into the contract.
4
+ id: section-name-noun
5
+ language: en
6
+ entries:
7
+ - pattern: notice
8
+ - pattern: notices
9
+ - pattern: form
10
+ - pattern: forms
@@ -0,0 +1,16 @@
1
+ # Street types written short and in capitals after a street number and name (512 Bayshore DR). Read only there. Matched as written.
2
+ id: street-suffix
3
+ language: en
4
+ entries:
5
+ - pattern: "DR"
6
+ - pattern: "ST"
7
+ - pattern: "AVE"
8
+ - pattern: "BLVD"
9
+ - pattern: "RD"
10
+ - pattern: "LN"
11
+ - pattern: "CT"
12
+ - pattern: "PKWY"
13
+ - pattern: "HWY"
14
+ - pattern: "PL"
15
+ - pattern: "SQ"
16
+ - pattern: "TER"
@@ -0,0 +1,7 @@
1
+ # Names of taxes a reader knows by their short form (VAT, GST). Like common acronyms, they are not asked to be spelled out.
2
+ # Matched as written.
3
+ id: tax-code
4
+ language: en
5
+ entries:
6
+ - pattern: "VAT"
7
+ - pattern: "GST"
@@ -52,3 +52,11 @@ entries:
52
52
  - { pattern: "Finish", group: span, position: after }
53
53
  - { pattern: "Finishes", group: span, position: after }
54
54
  - { pattern: "Expected finish", group: span, position: after }
55
+ # An incident report: the incident starts, then it is detected. "Resolved" is left out: an incident can clear before anyone notices.
56
+ - { pattern: "Started", group: incident, position: before }
57
+ - { pattern: "Start time", group: incident, position: before }
58
+ - { pattern: "Began", group: incident, position: before }
59
+ - { pattern: "Incident start", group: incident, position: before }
60
+ - { pattern: "Detected", group: incident, position: after }
61
+ - { pattern: "Detection time", group: incident, position: after }
62
+ - { pattern: "Time detected", group: incident, position: after }
@@ -0,0 +1,16 @@
1
+ # Words that open a sentence and point back to the total of the sentence before, just before a breakdown phrase
2
+ # ("The project costs a total of $12,000. This consists of $5,000 for design and $6,000 for development.").
3
+ # total-mismatch reads the next sentence's breakdown only when nothing, or one of these, comes before the phrase:
4
+ # "The maintenance plan consists of ..." is about another item.
5
+ id: total-back-reference
6
+ language: en
7
+ entries:
8
+ - pattern: this
9
+ - pattern: it
10
+ - pattern: that
11
+ - pattern: the total
12
+ - pattern: this total
13
+ - pattern: this amount
14
+ - pattern: the amount
15
+ - pattern: this sum
16
+ - pattern: the sum
@@ -0,0 +1,9 @@
1
+ # Marks that, right after the amount of a total phrase, start the list of every item of that total
2
+ # ("a total of $12,000: $5,000 for design and $6,000 for development").
3
+ # total-mismatch compares the total with the items up to the end of the sentence. "Including" and "of which" are left out: they may name only some of the items.
4
+ id: total-breakdown-lead
5
+ language: en
6
+ entries:
7
+ - pattern: ":"
8
+ - pattern: "—"
9
+ - pattern: "–"
@@ -25,3 +25,16 @@ entries:
25
25
  - pattern: Foreword
26
26
  - pattern: Changelog
27
27
  - pattern: Revision History
28
+ # The contact block at the end of a press release or a notice.
29
+ - pattern: Contact
30
+ - pattern: Contacts
31
+ - pattern: Media contact
32
+ - pattern: Media contacts
33
+ - pattern: Press contact
34
+ - pattern: Press contacts
35
+ # The standard closing sections of an HMRC notice, after its numbered parts.
36
+ - pattern: Your rights and obligations
37
+ - pattern: Help us improve this notice
38
+ - pattern: Putting things right
39
+ - pattern: How we use your information
40
+ - pattern: How HMRC uses your information
@@ -0,0 +1,21 @@
1
+ # Terms of art that hold a vague word. In the genres listed, law and practice give them a meaning ("reasonable" is the
2
+ # standard a court applies, "best efforts" a known degree of effort, "from time to time" means as amended), so
3
+ # vague-word-density does not count a vague word inside one there. Elsewhere the same words are counted.
4
+ id: vague-word-term-of-art
5
+ language: en
6
+ entries:
7
+ - pattern: reasonable
8
+ genres: [legal]
9
+ - pattern: reasonably
10
+ genres: [legal]
11
+ - pattern: best efforts
12
+ genres: [legal]
13
+ - pattern: best effort
14
+ genres: [legal]
15
+ - pattern: from time to time
16
+ genres: [legal]
17
+ # The test for injunctive relief: damages that cannot adequately compensate the harm.
18
+ - pattern: adequately compensate
19
+ genres: [legal]
20
+ - pattern: adequate remedy
21
+ genres: [legal]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaffjs/lang-en",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "English language adapter for chaff",
5
5
  "license": "MIT",
6
6
  "author": "isamu",
@@ -6,8 +6,8 @@ import { readsAsExample } from "./example-name.ts";
6
6
 
7
7
  const DEFINITIONS = [
8
8
  /["“](?<term>[^"”\n]{1,60})["”] (?:means|shall mean|refers to|has the meaning)\b/gu,
9
- /\((?:the |these |this |hereinafter |each,? an? |collectively,? the )?["“](?<term>[^"”\n]{1,60})["”]\)/gu,
10
- /\(hereinafter referred to as ["“](?<term>[^"”\n]{1,60})["”]\)/gu,
9
+ /\((?:the |these |this |each,? an? |collectively,? the )?["“](?<term>[^"”\n]{1,60})["”]\)/gu,
10
+ /\(hereinafter (?:referred to as |called )?(?:the )?["“](?<term>[^"”\n]{1,60})["”]\)/gu,
11
11
  ];
12
12
 
13
13
  /**
@@ -42,15 +42,24 @@ const BARE = /^\(["“]/u;
42
42
  const BRACKET = /\((?<inside>[^()\n]{1,300})\)/gu;
43
43
  const QUOTED_NAME = /["“](?<term>[^"”\n]{1,60})["”]/gu;
44
44
  /** What may come before the first name: (the "Company", (each, a "Party", (collectively, the "Parties". */
45
- const LIST_LEAD = /^(?:the |collectively,? the |each,? an? )?$/u;
45
+ const LIST_LEAD = /^(?:the |hereinafter (?:the )?|collectively,? the |each,? an? )?$/u;
46
46
  /** What may come between two names: a comma, and or or, and the. */
47
47
  const LIST_JOINT = /^(?:, (?:and |or )?| and | or )(?:the )?$/u;
48
48
  /** A list of names starts with a capitalised one ("Pinecone"); ("mine", "not mine", "yours") quotes examples. */
49
49
  const CAPITALISED = /^\p{Lu}/u;
50
50
 
51
+ /**
52
+ * After a party's name, the name of all the parties: (the "Company" and, together with Parent, the "Parties"). The first
53
+ * name is the party's; the rest must end on a capitalised quoted name, so a bracket that trails off is not read.
54
+ */
55
+ const TOGETHER_WITH = /^[,;]? and,? (?:together|collectively) with /u;
56
+
51
57
  type QuotedName = { readonly term: string; readonly start: number; readonly end: number };
52
58
 
53
- /** The quoted names of a bracket that holds nothing but two or more names, joined as a list; otherwise none. */
59
+ /**
60
+ * The quoted names of a bracket that holds nothing but two or more names joined as a list, or a name followed by the
61
+ * name of all the parties; otherwise none.
62
+ */
54
63
  const namesInList = (inside: string): QuotedName[] => {
55
64
  const names = [...inside.matchAll(QUOTED_NAME)].map((match) => ({
56
65
  term: match.groups?.["term"] ?? "",
@@ -58,9 +67,11 @@ const namesInList = (inside: string): QuotedName[] => {
58
67
  end: match.index + match[0].length,
59
68
  }));
60
69
  const [first] = names;
61
- if (first === undefined || names.length < 2 || !CAPITALISED.test(first.term) || !LIST_LEAD.test(inside.slice(0, first.start))) return [];
70
+ if (first === undefined || !CAPITALISED.test(first.term) || !LIST_LEAD.test(inside.slice(0, first.start))) return [];
71
+ if (names.length < 2 || inside.slice(names.at(-1)?.end ?? 0) !== "") return [];
72
+ if (TOGETHER_WITH.test(inside.slice(first.end))) return names.every((name) => CAPITALISED.test(name.term)) ? names : [];
62
73
  const joined = names.slice(1).every((name, index) => LIST_JOINT.test(inside.slice(names[index]?.end ?? 0, name.start)));
63
- return joined && inside.slice(names.at(-1)?.end ?? 0) === "" ? names : [];
74
+ return joined ? names : [];
64
75
  };
65
76
 
66
77
  /**
package/src/emphasis.ts CHANGED
@@ -33,6 +33,23 @@ export const isEmphasisedAdverb = (surface: string, tagsOf: TagsOf): boolean =>
33
33
  return tags.length > 0 && tags.every((tag) => ADVERB_TAGS.has(tag));
34
34
  };
35
35
 
36
+ /** Shorter capitals that spell a word are acronyms too often (PIE, GUT, JAR, TAP): only words this long are read from the vocabulary alone. */
37
+ const ORDINARY_WORD_MIN_LENGTH = 4;
38
+
39
+ /** Penn tags of the open word classes: common noun, verb, adjective, adverb. */
40
+ const OPEN_CLASS_TAG = /^(?:NNS?|VB[DGNPZ]?|JJ[RS]?|RB[RS]?)$/u;
41
+
42
+ /**
43
+ * The tagger's vocabulary knows the lower-case word as an ordinary English word (start, return, none, thank, safe) and never as
44
+ * a proper noun. Acronyms the vocabulary holds are proper nouns or absent (NASA, NIST, HTTP), so these capitals spell the word.
45
+ * A word that is also an acronym (FAST the telescope) is given up: precision first, and only meaning tells the two apart.
46
+ */
47
+ export const isCapitalisedOrdinaryWord = (surface: string, tagsOf: TagsOf): boolean => {
48
+ if (!CAPITALS.test(surface) || [...surface].length < ORDINARY_WORD_MIN_LENGTH) return false;
49
+ const tags = tagsOf(surface.toLowerCase()) ?? [];
50
+ return tags.some((tag) => OPEN_CLASS_TAG.test(tag)) && !tags.some((tag) => tag.startsWith("NNP"));
51
+ };
52
+
36
53
  /** After a verb, a word the tagger read as a noun must also be a verb in the dictionary (DID form), or it is what the capitals name (DID token). */
37
54
  const canFollowVerb = (next: TaggedWord, tagsOf: TagsOf): boolean => !next.pos.startsWith("NN") || (tagsOf(next.value.toLowerCase()) ?? []).includes("VB");
38
55
 
@@ -60,6 +77,11 @@ type WordSpan = { readonly start: number; readonly end: number };
60
77
 
61
78
  export const standsAlone = (text: string, span: WordSpan): boolean => !JOINED.test(text.charAt(span.start - 1)) && !JOINED.test(text.charAt(span.end));
62
79
 
80
+ const HYPHENS = /[-‐‑]/u;
81
+
82
+ /** A word hyphened to another (LAST-ACK, DRUM-TAPS) is one part of a compound, which the vocabulary does not hold as a whole. */
83
+ export const isHyphenated = (text: string, span: WordSpan): boolean => HYPHENS.test(text.charAt(span.start - 1)) || HYPHENS.test(text.charAt(span.end));
84
+
63
85
  /** A capitals word the sentence reads as an English word (not the adverb-only case above), so emphasis and not an acronym. */
64
86
  export const isEmphasisedWord = (tagged: readonly TaggedWord[], at: number, tagsOf: TagsOf): boolean => {
65
87
  const surface = tagged[at]?.value ?? "";
package/src/pos.ts CHANGED
@@ -4,7 +4,7 @@ import { loadLexicons } from "./lexicons.ts";
4
4
  import { blankLongRuns } from "./long-runs.ts";
5
5
  import { capitalisedGuessedVerbsAsNames, isOrdinaryWord, lowercasedAt, properNounChecked, rereadAt, sentenceInitialCommonWord } from "./proper-noun.ts";
6
6
  import { isStativeParticiple, stativeVocabulary } from "./stative-participle.ts";
7
- import { isEmphasisedAdverb, isEmphasisedWord, standsAlone } from "./emphasis.ts";
7
+ import { isCapitalisedOrdinaryWord, isEmphasisedAdverb, isEmphasisedWord, isHyphenated, standsAlone } from "./emphasis.ts";
8
8
  import { gerundFeatures } from "./gerund.ts";
9
9
  import { winkLexiconWords, winkPosTagger, winkWordNet } from "./wink-modules.ts";
10
10
 
@@ -252,11 +252,14 @@ export const isReady = (): boolean => state.ready !== undefined;
252
252
 
253
253
  /**
254
254
  * 大文字で強調した副詞(NEVER)は、解析器が名前と付けても副詞。文の中で前置詞や動詞として読めた語(AFTER the departure、
255
- * a hurricane DID form)は、解析器の読みのまま。どちらも Emph=Yes で、略語ではないと detector に伝える。
255
+ * a hurricane DID form)と、語彙が普通の語として知る 4 文字以上の語(START、RETURN)は、解析器の読みのまま。どれも Emph=Yes で、
256
+ * 略語ではないと detector に伝える。
256
257
  */
257
258
  const withEmphasis = (token: Token, text: string, tagged: readonly Tagged[], at: number): Token => {
258
259
  if (isEmphasisedAdverb(token.surface, state.vocabulary)) return { ...token, pos: "ADV", lemma: token.surface.toLowerCase(), features: { Emph: "Yes" } };
259
- if (!standsAlone(text, token.span) || !isEmphasisedWord(tagged, at, state.vocabulary)) return token;
260
+ const ordinary = isCapitalisedOrdinaryWord(token.surface, state.vocabulary) && !isHyphenated(text, token.span);
261
+ const readAsWord = ordinary || (standsAlone(text, token.span) && isEmphasisedWord(tagged, at, state.vocabulary));
262
+ if (!readAsWord) return token;
260
263
  return { ...token, lemma: (token.lemma ?? token.surface).toLowerCase(), features: { ...token.features, Emph: "Yes" } };
261
264
  };
262
265