@chaffjs/lang-en 0.15.0 → 0.17.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 (91) hide show
  1. package/dist/citation.d.ts +5 -2
  2. package/dist/citation.d.ts.map +1 -1
  3. package/dist/citation.js +13 -9
  4. package/dist/citation.js.map +1 -1
  5. package/dist/code-citation.d.ts +15 -0
  6. package/dist/code-citation.d.ts.map +1 -0
  7. package/dist/code-citation.js +34 -0
  8. package/dist/code-citation.js.map +1 -0
  9. package/dist/definitions.d.ts.map +1 -1
  10. package/dist/definitions.js +4 -2
  11. package/dist/definitions.js.map +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +10 -4
  15. package/dist/index.js.map +1 -1
  16. package/dist/japanese-run.d.ts +2 -0
  17. package/dist/japanese-run.d.ts.map +1 -0
  18. package/dist/japanese-run.js +9 -0
  19. package/dist/japanese-run.js.map +1 -0
  20. package/dist/label-stop.d.ts +13 -0
  21. package/dist/label-stop.d.ts.map +1 -0
  22. package/dist/label-stop.js +13 -0
  23. package/dist/label-stop.js.map +1 -0
  24. package/dist/lexicons.d.ts.map +1 -1
  25. package/dist/lexicons.js +4 -0
  26. package/dist/lexicons.js.map +1 -1
  27. package/dist/pos.d.ts.map +1 -1
  28. package/dist/pos.js +37 -17
  29. package/dist/pos.js.map +1 -1
  30. package/dist/regexp.d.ts +3 -0
  31. package/dist/regexp.d.ts.map +1 -0
  32. package/dist/regexp.js +3 -0
  33. package/dist/regexp.js.map +1 -0
  34. package/dist/structure.d.ts.map +1 -1
  35. package/dist/structure.js +17 -6
  36. package/dist/structure.js.map +1 -1
  37. package/lexicons/abbreviated-label.yaml +16 -0
  38. package/lexicons/ai-tell.yaml +98 -0
  39. package/lexicons/announcing-opener.yaml +19 -0
  40. package/lexicons/assistant-residue.yaml +55 -0
  41. package/lexicons/contrast-frame.yaml +10 -0
  42. package/lexicons/contrast-lead.yaml +15 -0
  43. package/lexicons/contrast-turn.yaml +11 -0
  44. package/lexicons/count-anchor.yaml +7 -0
  45. package/lexicons/count-counter.yaml +90 -0
  46. package/lexicons/count-hedge.yaml +67 -0
  47. package/lexicons/count-number.yaml +16 -0
  48. package/lexicons/cushion-phrase.yaml +6 -0
  49. package/lexicons/date-change-word.yaml +27 -0
  50. package/lexicons/document-kind.yaml +19 -0
  51. package/lexicons/double-negative.yaml +25 -0
  52. package/lexicons/email-attachment-note.yaml +7 -0
  53. package/lexicons/email-attribution.yaml +7 -0
  54. package/lexicons/email-header-field.yaml +28 -0
  55. package/lexicons/email-written-field.yaml +8 -0
  56. package/lexicons/enumeration-frame.yaml +37 -0
  57. package/lexicons/enumeration-joiner.yaml +9 -0
  58. package/lexicons/enumeration-negation.yaml +13 -0
  59. package/lexicons/figure-elsewhere.yaml +8 -0
  60. package/lexicons/figure-label.yaml +14 -0
  61. package/lexicons/measure-unit.yaml +78 -0
  62. package/lexicons/nominalization-phrase.yaml +27 -0
  63. package/lexicons/numbered-label.yaml +26 -0
  64. package/lexicons/percent-unit.yaml +7 -0
  65. package/lexicons/place-region.yaml +247 -0
  66. package/lexicons/placeholder-word.yaml +17 -0
  67. package/lexicons/range-connector.yaml +12 -0
  68. package/lexicons/range-frame.yaml +9 -0
  69. package/lexicons/requirement-either.yaml +5 -0
  70. package/lexicons/requirement-loophole.yaml +17 -0
  71. package/lexicons/requirement-marker.yaml +9 -0
  72. package/lexicons/requirement-modal-must.yaml +7 -0
  73. package/lexicons/requirement-open-end.yaml +9 -0
  74. package/lexicons/share-exception.yaml +10 -0
  75. package/lexicons/share-label.yaml +12 -0
  76. package/lexicons/spelling-ize.yaml +273 -0
  77. package/lexicons/spelling-variant.yaml +260 -0
  78. package/lexicons/stock-transition.yaml +17 -0
  79. package/lexicons/vague-clause-pointer.yaml +10 -0
  80. package/lexicons/vague-figure-pointer.yaml +14 -0
  81. package/package.json +1 -1
  82. package/src/citation.ts +13 -9
  83. package/src/code-citation.ts +52 -0
  84. package/src/definitions.ts +4 -2
  85. package/src/index.ts +14 -5
  86. package/src/japanese-run.ts +9 -0
  87. package/src/label-stop.ts +25 -0
  88. package/src/lexicons.ts +4 -0
  89. package/src/pos.ts +36 -20
  90. package/src/regexp.ts +2 -0
  91. package/src/structure.ts +22 -6
@@ -0,0 +1,273 @@
1
+ # -ise and -ize (organise / organize, organisation / organization). pattern is -ise, instead_of -ize.
2
+ # Compared apart from spelling-variant: British writing uses both, and Oxford spelling writes -ize with colour.
3
+ id: spelling-ize
4
+ language: en
5
+ entries:
6
+ - pattern: organise
7
+ instead_of: organize
8
+ - pattern: organises
9
+ instead_of: organizes
10
+ - pattern: organised
11
+ instead_of: organized
12
+ - pattern: organising
13
+ instead_of: organizing
14
+ - pattern: organisation
15
+ instead_of: organization
16
+ - pattern: organisations
17
+ instead_of: organizations
18
+ - pattern: organiser
19
+ instead_of: organizer
20
+ - pattern: organisers
21
+ instead_of: organizers
22
+ - pattern: recognise
23
+ instead_of: recognize
24
+ - pattern: recognises
25
+ instead_of: recognizes
26
+ - pattern: recognised
27
+ instead_of: recognized
28
+ - pattern: recognising
29
+ instead_of: recognizing
30
+ - pattern: realise
31
+ instead_of: realize
32
+ - pattern: realises
33
+ instead_of: realizes
34
+ - pattern: realised
35
+ instead_of: realized
36
+ - pattern: realising
37
+ instead_of: realizing
38
+ - pattern: realisation
39
+ instead_of: realization
40
+ - pattern: prioritise
41
+ instead_of: prioritize
42
+ - pattern: prioritises
43
+ instead_of: prioritizes
44
+ - pattern: prioritised
45
+ instead_of: prioritized
46
+ - pattern: prioritising
47
+ instead_of: prioritizing
48
+ - pattern: prioritisation
49
+ instead_of: prioritization
50
+ - pattern: minimise
51
+ instead_of: minimize
52
+ - pattern: minimises
53
+ instead_of: minimizes
54
+ - pattern: minimised
55
+ instead_of: minimized
56
+ - pattern: minimising
57
+ instead_of: minimizing
58
+ - pattern: maximise
59
+ instead_of: maximize
60
+ - pattern: maximises
61
+ instead_of: maximizes
62
+ - pattern: maximised
63
+ instead_of: maximized
64
+ - pattern: maximising
65
+ instead_of: maximizing
66
+ - pattern: optimise
67
+ instead_of: optimize
68
+ - pattern: optimises
69
+ instead_of: optimizes
70
+ - pattern: optimised
71
+ instead_of: optimized
72
+ - pattern: optimising
73
+ instead_of: optimizing
74
+ - pattern: optimisation
75
+ instead_of: optimization
76
+ - pattern: optimisations
77
+ instead_of: optimizations
78
+ - pattern: customise
79
+ instead_of: customize
80
+ - pattern: customises
81
+ instead_of: customizes
82
+ - pattern: customised
83
+ instead_of: customized
84
+ - pattern: customising
85
+ instead_of: customizing
86
+ - pattern: customisation
87
+ instead_of: customization
88
+ - pattern: customisable
89
+ instead_of: customizable
90
+ - pattern: standardise
91
+ instead_of: standardize
92
+ - pattern: standardises
93
+ instead_of: standardizes
94
+ - pattern: standardised
95
+ instead_of: standardized
96
+ - pattern: standardising
97
+ instead_of: standardizing
98
+ - pattern: standardisation
99
+ instead_of: standardization
100
+ - pattern: summarise
101
+ instead_of: summarize
102
+ - pattern: summarises
103
+ instead_of: summarizes
104
+ - pattern: summarised
105
+ instead_of: summarized
106
+ - pattern: summarising
107
+ instead_of: summarizing
108
+ - pattern: emphasise
109
+ instead_of: emphasize
110
+ - pattern: emphasises
111
+ instead_of: emphasizes
112
+ - pattern: emphasised
113
+ instead_of: emphasized
114
+ - pattern: emphasising
115
+ instead_of: emphasizing
116
+ - pattern: authorise
117
+ instead_of: authorize
118
+ - pattern: authorises
119
+ instead_of: authorizes
120
+ - pattern: authorised
121
+ instead_of: authorized
122
+ - pattern: authorising
123
+ instead_of: authorizing
124
+ - pattern: authorisation
125
+ instead_of: authorization
126
+ - pattern: authorisations
127
+ instead_of: authorizations
128
+ - pattern: categorise
129
+ instead_of: categorize
130
+ - pattern: categorises
131
+ instead_of: categorizes
132
+ - pattern: categorised
133
+ instead_of: categorized
134
+ - pattern: categorising
135
+ instead_of: categorizing
136
+ - pattern: categorisation
137
+ instead_of: categorization
138
+ - pattern: finalise
139
+ instead_of: finalize
140
+ - pattern: finalises
141
+ instead_of: finalizes
142
+ - pattern: finalised
143
+ instead_of: finalized
144
+ - pattern: finalising
145
+ instead_of: finalizing
146
+ - pattern: utilise
147
+ instead_of: utilize
148
+ - pattern: utilises
149
+ instead_of: utilizes
150
+ - pattern: utilised
151
+ instead_of: utilized
152
+ - pattern: utilising
153
+ instead_of: utilizing
154
+ - pattern: utilisation
155
+ instead_of: utilization
156
+ - pattern: apologise
157
+ instead_of: apologize
158
+ - pattern: apologises
159
+ instead_of: apologizes
160
+ - pattern: apologised
161
+ instead_of: apologized
162
+ - pattern: apologising
163
+ instead_of: apologizing
164
+ - pattern: criticise
165
+ instead_of: criticize
166
+ - pattern: criticises
167
+ instead_of: criticizes
168
+ - pattern: criticised
169
+ instead_of: criticized
170
+ - pattern: criticising
171
+ instead_of: criticizing
172
+ - pattern: specialise
173
+ instead_of: specialize
174
+ - pattern: specialises
175
+ instead_of: specializes
176
+ - pattern: specialised
177
+ instead_of: specialized
178
+ - pattern: specialising
179
+ instead_of: specializing
180
+ - pattern: specialisation
181
+ instead_of: specialization
182
+ - pattern: visualise
183
+ instead_of: visualize
184
+ - pattern: visualises
185
+ instead_of: visualizes
186
+ - pattern: visualised
187
+ instead_of: visualized
188
+ - pattern: visualising
189
+ instead_of: visualizing
190
+ - pattern: visualisation
191
+ instead_of: visualization
192
+ - pattern: visualisations
193
+ instead_of: visualizations
194
+ - pattern: initialise
195
+ instead_of: initialize
196
+ - pattern: initialises
197
+ instead_of: initializes
198
+ - pattern: initialised
199
+ instead_of: initialized
200
+ - pattern: initialising
201
+ instead_of: initializing
202
+ - pattern: initialisation
203
+ instead_of: initialization
204
+ - pattern: normalise
205
+ instead_of: normalize
206
+ - pattern: normalises
207
+ instead_of: normalizes
208
+ - pattern: normalised
209
+ instead_of: normalized
210
+ - pattern: normalising
211
+ instead_of: normalizing
212
+ - pattern: normalisation
213
+ instead_of: normalization
214
+ - pattern: synchronise
215
+ instead_of: synchronize
216
+ - pattern: synchronises
217
+ instead_of: synchronizes
218
+ - pattern: synchronised
219
+ instead_of: synchronized
220
+ - pattern: synchronising
221
+ instead_of: synchronizing
222
+ - pattern: synchronisation
223
+ instead_of: synchronization
224
+ - pattern: modernise
225
+ instead_of: modernize
226
+ - pattern: modernises
227
+ instead_of: modernizes
228
+ - pattern: modernised
229
+ instead_of: modernized
230
+ - pattern: modernising
231
+ instead_of: modernizing
232
+ - pattern: modernisation
233
+ instead_of: modernization
234
+ - pattern: digitise
235
+ instead_of: digitize
236
+ - pattern: digitises
237
+ instead_of: digitizes
238
+ - pattern: digitised
239
+ instead_of: digitized
240
+ - pattern: digitising
241
+ instead_of: digitizing
242
+ - pattern: digitisation
243
+ instead_of: digitization
244
+ - pattern: localise
245
+ instead_of: localize
246
+ - pattern: localises
247
+ instead_of: localizes
248
+ - pattern: localised
249
+ instead_of: localized
250
+ - pattern: localising
251
+ instead_of: localizing
252
+ - pattern: localisation
253
+ instead_of: localization
254
+ - pattern: centralise
255
+ instead_of: centralize
256
+ - pattern: centralises
257
+ instead_of: centralizes
258
+ - pattern: centralised
259
+ instead_of: centralized
260
+ - pattern: centralising
261
+ instead_of: centralizing
262
+ - pattern: centralisation
263
+ instead_of: centralization
264
+ - pattern: characterise
265
+ instead_of: characterize
266
+ - pattern: characterises
267
+ instead_of: characterizes
268
+ - pattern: characterised
269
+ instead_of: characterized
270
+ - pattern: characterising
271
+ instead_of: characterizing
272
+ - pattern: characterisation
273
+ instead_of: characterization
@@ -0,0 +1,260 @@
1
+ # British and American spellings of the same word (colour / color, centre / center, travelled / traveled, analyse / analyze).
2
+ # pattern is the British spelling, instead_of the American. Neither is wrong: spelling-consistency points at whichever the
3
+ # document uses less. -ise / -ize is in spelling-ize, compared on its own, since Oxford spelling writes colour and organize.
4
+ # Words with another meaning in one variety are left out: meter (a device), check (a verb), tire (a verb), program, license,
5
+ # practice, judgment (a court's), dialog and analog (in software and electronics), analyses (the plural of analysis).
6
+ id: spelling-variant
7
+ language: en
8
+ entries:
9
+ - pattern: colour
10
+ instead_of: color
11
+ - pattern: colours
12
+ instead_of: colors
13
+ - pattern: coloured
14
+ instead_of: colored
15
+ - pattern: colouring
16
+ instead_of: coloring
17
+ - pattern: colourful
18
+ instead_of: colorful
19
+ - pattern: colourless
20
+ instead_of: colorless
21
+ - pattern: favour
22
+ instead_of: favor
23
+ - pattern: favours
24
+ instead_of: favors
25
+ - pattern: favoured
26
+ instead_of: favored
27
+ - pattern: favouring
28
+ instead_of: favoring
29
+ - pattern: favourable
30
+ instead_of: favorable
31
+ - pattern: favourite
32
+ instead_of: favorite
33
+ - pattern: favourites
34
+ instead_of: favorites
35
+ - pattern: honour
36
+ instead_of: honor
37
+ - pattern: honours
38
+ instead_of: honors
39
+ - pattern: honoured
40
+ instead_of: honored
41
+ - pattern: honouring
42
+ instead_of: honoring
43
+ - pattern: honourable
44
+ instead_of: honorable
45
+ - pattern: labour
46
+ instead_of: labor
47
+ - pattern: labours
48
+ instead_of: labors
49
+ - pattern: laboured
50
+ instead_of: labored
51
+ - pattern: labouring
52
+ instead_of: laboring
53
+ - pattern: behaviour
54
+ instead_of: behavior
55
+ - pattern: behaviours
56
+ instead_of: behaviors
57
+ - pattern: behavioural
58
+ instead_of: behavioral
59
+ - pattern: neighbour
60
+ instead_of: neighbor
61
+ - pattern: neighbours
62
+ instead_of: neighbors
63
+ - pattern: neighbourhood
64
+ instead_of: neighborhood
65
+ - pattern: neighbourhoods
66
+ instead_of: neighborhoods
67
+ - pattern: neighbouring
68
+ instead_of: neighboring
69
+ - pattern: humour
70
+ instead_of: humor
71
+ - pattern: humours
72
+ instead_of: humors
73
+ - pattern: rumour
74
+ instead_of: rumor
75
+ - pattern: rumours
76
+ instead_of: rumors
77
+ - pattern: rumoured
78
+ instead_of: rumored
79
+ - pattern: harbour
80
+ instead_of: harbor
81
+ - pattern: harbours
82
+ instead_of: harbors
83
+ - pattern: endeavour
84
+ instead_of: endeavor
85
+ - pattern: endeavours
86
+ instead_of: endeavors
87
+ - pattern: endeavoured
88
+ instead_of: endeavored
89
+ - pattern: endeavouring
90
+ instead_of: endeavoring
91
+ - pattern: flavour
92
+ instead_of: flavor
93
+ - pattern: flavours
94
+ instead_of: flavors
95
+ - pattern: flavoured
96
+ instead_of: flavored
97
+ - pattern: flavouring
98
+ instead_of: flavoring
99
+ - pattern: vapour
100
+ instead_of: vapor
101
+ - pattern: vapours
102
+ instead_of: vapors
103
+ - pattern: savour
104
+ instead_of: savor
105
+ - pattern: savours
106
+ instead_of: savors
107
+ - pattern: savoury
108
+ instead_of: savory
109
+ - pattern: centre
110
+ instead_of: center
111
+ - pattern: centres
112
+ instead_of: centers
113
+ - pattern: centred
114
+ instead_of: centered
115
+ - pattern: theatre
116
+ instead_of: theater
117
+ - pattern: theatres
118
+ instead_of: theaters
119
+ - pattern: fibre
120
+ instead_of: fiber
121
+ - pattern: fibres
122
+ instead_of: fibers
123
+ - pattern: litre
124
+ instead_of: liter
125
+ - pattern: litres
126
+ instead_of: liters
127
+ - pattern: kilometre
128
+ instead_of: kilometer
129
+ - pattern: kilometres
130
+ instead_of: kilometers
131
+ - pattern: centimetre
132
+ instead_of: centimeter
133
+ - pattern: centimetres
134
+ instead_of: centimeters
135
+ - pattern: millimetre
136
+ instead_of: millimeter
137
+ - pattern: millimetres
138
+ instead_of: millimeters
139
+ - pattern: calibre
140
+ instead_of: caliber
141
+ - pattern: sombre
142
+ instead_of: somber
143
+ - pattern: analyse
144
+ instead_of: analyze
145
+ - pattern: analysed
146
+ instead_of: analyzed
147
+ - pattern: analysing
148
+ instead_of: analyzing
149
+ - pattern: analyser
150
+ instead_of: analyzer
151
+ - pattern: analysers
152
+ instead_of: analyzers
153
+ - pattern: paralyse
154
+ instead_of: paralyze
155
+ - pattern: paralysed
156
+ instead_of: paralyzed
157
+ - pattern: paralysing
158
+ instead_of: paralyzing
159
+ - pattern: catalyse
160
+ instead_of: catalyze
161
+ - pattern: catalysed
162
+ instead_of: catalyzed
163
+ - pattern: catalysing
164
+ instead_of: catalyzing
165
+ - pattern: defence
166
+ instead_of: defense
167
+ - pattern: defences
168
+ instead_of: defenses
169
+ - pattern: offence
170
+ instead_of: offense
171
+ - pattern: offences
172
+ instead_of: offenses
173
+ - pattern: pretence
174
+ instead_of: pretense
175
+ - pattern: pretences
176
+ instead_of: pretenses
177
+ - pattern: travelled
178
+ instead_of: traveled
179
+ - pattern: travelling
180
+ instead_of: traveling
181
+ - pattern: traveller
182
+ instead_of: traveler
183
+ - pattern: travellers
184
+ instead_of: travelers
185
+ - pattern: cancelled
186
+ instead_of: canceled
187
+ - pattern: cancelling
188
+ instead_of: canceling
189
+ - pattern: labelled
190
+ instead_of: labeled
191
+ - pattern: labelling
192
+ instead_of: labeling
193
+ - pattern: modelled
194
+ instead_of: modeled
195
+ - pattern: modelling
196
+ instead_of: modeling
197
+ - pattern: signalled
198
+ instead_of: signaled
199
+ - pattern: signalling
200
+ instead_of: signaling
201
+ - pattern: fuelled
202
+ instead_of: fueled
203
+ - pattern: fuelling
204
+ instead_of: fueling
205
+ - pattern: totalled
206
+ instead_of: totaled
207
+ - pattern: totalling
208
+ instead_of: totaling
209
+ - pattern: catalogue
210
+ instead_of: catalog
211
+ - pattern: catalogues
212
+ instead_of: catalogs
213
+ - pattern: catalogued
214
+ instead_of: cataloged
215
+ - pattern: grey
216
+ instead_of: gray
217
+ - pattern: greys
218
+ instead_of: grays
219
+ - pattern: greyer
220
+ instead_of: grayer
221
+ - pattern: greyest
222
+ instead_of: grayest
223
+ - pattern: aluminium
224
+ instead_of: aluminum
225
+ - pattern: enrol
226
+ instead_of: enroll
227
+ - pattern: enrols
228
+ instead_of: enrolls
229
+ - pattern: enrolment
230
+ instead_of: enrollment
231
+ - pattern: enrolments
232
+ instead_of: enrollments
233
+ - pattern: fulfil
234
+ instead_of: fulfill
235
+ - pattern: fulfils
236
+ instead_of: fulfills
237
+ - pattern: fulfilment
238
+ instead_of: fulfillment
239
+ - pattern: instalment
240
+ instead_of: installment
241
+ - pattern: instalments
242
+ instead_of: installments
243
+ - pattern: acknowledgement
244
+ instead_of: acknowledgment
245
+ - pattern: acknowledgements
246
+ instead_of: acknowledgments
247
+ - pattern: ageing
248
+ instead_of: aging
249
+ - pattern: manoeuvre
250
+ instead_of: maneuver
251
+ - pattern: manoeuvres
252
+ instead_of: maneuvers
253
+ - pattern: paediatric
254
+ instead_of: pediatric
255
+ - pattern: paediatrics
256
+ instead_of: pediatrics
257
+ - pattern: anaesthesia
258
+ instead_of: anesthesia
259
+ - pattern: oestrogen
260
+ instead_of: estrogen
@@ -0,0 +1,17 @@
1
+ # Sentence openers that glue without saying how. Words that carry the argument (However, Therefore, Thus) are not here.
2
+ # "In addition," keeps its comma: "In addition to X" opens a phrase, not a transition.
3
+ id: stock-transition
4
+ language: en
5
+ entries:
6
+ - pattern: Additionally
7
+ - pattern: Moreover
8
+ - pattern: Furthermore
9
+ - pattern: In addition,
10
+ - pattern: Notably
11
+ - pattern: Importantly
12
+ - pattern: Crucially
13
+ - pattern: Ultimately
14
+ - pattern: Overall,
15
+ - pattern: In conclusion
16
+ - pattern: In summary
17
+ - pattern: That said
@@ -0,0 +1,10 @@
1
+ # Pointing at a clause by where it is instead of by its number (JIS Z 8301:2019 10.6 avoids "the clause below").
2
+ # instead_of names the kind in the message. Only a document that numbers its clauses or chapters (a numbered article
3
+ # or chapter in its structure tree) is checked. Matched in any case.
4
+ id: vague-clause-pointer
5
+ language: en
6
+ entries:
7
+ - { pattern: the above clause, instead_of: clause }
8
+ - { pattern: the clause above, instead_of: clause }
9
+ - { pattern: the below clause, instead_of: clause }
10
+ - { pattern: the clause below, instead_of: clause }
@@ -0,0 +1,14 @@
1
+ # Pointing at a figure or a table by where it is instead of by its number (JIS Z 8301:2019 10.6 avoids "the figure
2
+ # above"). instead_of names the kind it points at, as figure-label names it (Figure, Table). Only a document that
3
+ # numbers that kind is checked. Matched in any case.
4
+ id: vague-figure-pointer
5
+ language: en
6
+ entries:
7
+ - { pattern: the above figure, instead_of: Figure }
8
+ - { pattern: the figure above, instead_of: Figure }
9
+ - { pattern: the below figure, instead_of: Figure }
10
+ - { pattern: the figure below, instead_of: Figure }
11
+ - { pattern: the above table, instead_of: Table }
12
+ - { pattern: the table above, instead_of: Table }
13
+ - { pattern: the below table, instead_of: Table }
14
+ - { pattern: the table below, instead_of: Table }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaffjs/lang-en",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "English language adapter for chaff",
5
5
  "license": "MIT",
6
6
  "author": "isamu",
package/src/citation.ts CHANGED
@@ -52,17 +52,18 @@ export const listMembers = (rest: string, plural: boolean): ListMember[] =>
52
52
  */
53
53
  const TAG = "(?<tag>[A-Z][A-Z0-9]{1,30})";
54
54
  /**
55
- * "[HTTP-CACHING]" is written like a contract's placeholder "[BUYER-1]". Only the document tells them apart, by listing
56
- * the tag or not, so this tag is a candidate that the core checks against the document (attrs.citedTag).
55
+ * "[HTTP-CACHING]" is written like a contract's placeholder "[BUYER-1]", and a numbered citation "[19]" like a blank to
56
+ * fill in. Only the document tells them apart, by listing the tag or not, so this tag is a candidate that the core checks
57
+ * against the document (attrs.citedTag).
57
58
  */
58
- const HYPHENATED_TAG = "(?<tag>[A-Z][A-Z0-9]{0,30}(?:-[A-Z0-9]{1,30}){1,4})";
59
+ const LISTED_TAG = "(?<tag>\\d{1,3}|[A-Z][A-Z0-9]{0,30}(?:-[A-Z0-9]{1,30}){1,4})";
59
60
  const tagAfter = (tag: string): RegExp => new RegExp(`^\\[${tag}\\]`, "u");
60
61
  /** "[HTTP], Section 12.1": the tag written just before the reference. */
61
62
  const tagBefore = (tag: string): RegExp => new RegExp(`\\[${tag}\\],?\\s?$`, "u");
62
63
  const TAG_AFTER = tagAfter(TAG);
63
64
  const TAG_BEFORE = tagBefore(TAG);
64
- const HYPHENATED_AFTER = tagAfter(HYPHENATED_TAG);
65
- const HYPHENATED_BEFORE = tagBefore(HYPHENATED_TAG);
65
+ const LISTED_AFTER = tagAfter(LISTED_TAG);
66
+ const LISTED_BEFORE = tagBefore(LISTED_TAG);
66
67
  const TAG_REACH = 40;
67
68
 
68
69
  const tagEndingAt = (pattern: RegExp, text: string, start: number): string | undefined =>
@@ -120,9 +121,12 @@ export const citedDocumentAfter = (text: string, end: number): string | undefine
120
121
  return words.length === 1 && SELF.has(name) ? undefined : name;
121
122
  };
122
123
 
123
- /** A hyphenated tag right after a reference ("Section 4.2.3 of [HTTP-CACHING]") or just before it ("[HTTP-CACHING], Section 4"). */
124
- export const hyphenatedTagAround = (text: string, start: number, end: number): string | undefined => {
124
+ /**
125
+ * A tag that names another document only if this document lists it, right after a reference ("Section 4.2.3 of
126
+ * [HTTP-CACHING]", "Section 4.2.2.17 of [19]") or just before it ("[HTTP-CACHING], Section 4", "[23], Section 2.17").
127
+ */
128
+ export const listedTagAround = (text: string, start: number, end: number): string | undefined => {
125
129
  const named = afterOf(text, end);
126
- const following = named === undefined ? undefined : HYPHENATED_AFTER.exec(named)?.groups?.["tag"];
127
- return following ?? tagEndingAt(HYPHENATED_BEFORE, text, start);
130
+ const following = named === undefined ? undefined : LISTED_AFTER.exec(named)?.groups?.["tag"];
131
+ return following ?? tagEndingAt(LISTED_BEFORE, text, start);
128
132
  };
@@ -0,0 +1,52 @@
1
+ import type { Lexicon, LexiconEntry } from "chaffjs/plugin";
2
+ import { escapeRegExp } from "./regexp.ts";
3
+
4
+ // "35 CFR §122", "42 U.S.C. § 1983", "RFC 1122, Section 3.3.4.2": a section of a code or a numbered document named
5
+ // right before the reference, not of this document. Which names are codes is the lexicon's (document-kind).
6
+
7
+ /** Built once from the lexicon; each pattern is undefined when the lexicon names no code of its shape. */
8
+ export type CodeVocabulary = {
9
+ readonly before: RegExp | undefined;
10
+ readonly numberedBefore: RegExp | undefined;
11
+ /** The name of a code that takes a title number, at the start of the text and ending at a word boundary. */
12
+ readonly titled: RegExp | undefined;
13
+ };
14
+
15
+ /** The code's title number ("35 CFR"), then the name, then at most a second "§" ("§§ 1981 and 1983") up to the reference. */
16
+ const TITLE_NUMBER = String.raw`(?:\d{1,3}\s+)?`;
17
+ const SECOND_SIGN = String.raw`\s*(?:§\s*)?$`;
18
+ /** The document's own number after its name, then a comma, an opening parenthesis or a space up to the reference. */
19
+ const OWN_NUMBER = String.raw`\s+\d{1,5}`;
20
+ const NUMBER_TO_REFERENCE = String.raw`(?:,\s*|\s*\(\s*|\s+)(?:§\s*)?$`;
21
+ const NOT_INSIDE_A_WORD = String.raw`(?<![\p{L}\p{N}_.])`;
22
+ const WORD_ENDS = String.raw`(?![\p{L}\p{N}_])`;
23
+
24
+ /** "35 CFR " is a few characters. Only this much before a reference is read, however long the line. */
25
+ const REACH = 40;
26
+
27
+ const namesOf = (entries: readonly LexiconEntry[]): string | undefined => {
28
+ const names = entries.map((entry) => entry.pattern).toSorted((left, right) => right.length - left.length);
29
+ return names.length === 0 ? undefined : `(?:${names.map(escapeRegExp).join("|")})`;
30
+ };
31
+
32
+ /** An entry with position "before" is a name written before its own number ("RFC 1122"); the others follow a title number. */
33
+ export const codeVocabulary = (lexicons: Readonly<Record<string, Lexicon>>): CodeVocabulary => {
34
+ const entries = lexicons["document-kind"] ?? [];
35
+ const titled = namesOf(entries.filter((entry) => entry.position !== "before"));
36
+ const numbered = namesOf(entries.filter((entry) => entry.position === "before"));
37
+ return {
38
+ before: titled === undefined ? undefined : new RegExp(String.raw`${NOT_INSIDE_A_WORD}(?<code>${TITLE_NUMBER}${titled})${SECOND_SIGN}`, "u"),
39
+ numberedBefore:
40
+ numbered === undefined ? undefined : new RegExp(String.raw`${NOT_INSIDE_A_WORD}(?<code>${numbered}${OWN_NUMBER})${NUMBER_TO_REFERENCE}`, "u"),
41
+ titled: titled === undefined ? undefined : new RegExp(String.raw`^${titled}${WORD_ENDS}`, "u"),
42
+ };
43
+ };
44
+
45
+ /** The code named right before the reference at `start`, or undefined when none is. */
46
+ export const citedCodeBefore = (text: string, start: number, vocabulary: CodeVocabulary): string | undefined => {
47
+ const before = text.slice(Math.max(0, start - REACH), start);
48
+ return vocabulary.before?.exec(before)?.groups?.["code"] ?? vocabulary.numberedBefore?.exec(before)?.groups?.["code"];
49
+ };
50
+
51
+ /** "40 CFR § 163.25" at the start of a heading: the text after the number starts with a code named after a title number. */
52
+ export const titledCodeAt = (rest: string, vocabulary: CodeVocabulary): boolean => vocabulary.titled?.test(rest) === true;
@@ -37,7 +37,9 @@ export const definitions = (text: string): Mention[] =>
37
37
  const term = match.groups?.["term"];
38
38
  if (term === undefined) return [];
39
39
  const end = match.index + match[0].length;
40
- const namesAParty = match[0].startsWith("(") && APPLIES.test(text);
41
- return [{ start: match.index, end, attrs: { term, ...(isPointer(text, end) || namesAParty ? { scope: "local" } : {}) } }];
40
+ const inline = match[0].startsWith("(");
41
+ const namesAParty = inline && APPLIES.test(text);
42
+ const scope = isPointer(text, end) || namesAParty ? { scope: "local" } : {};
43
+ return [{ start: match.index, end, attrs: { term, ...scope, ...(inline ? { placement: "inline" } : {}) } }];
42
44
  }),
43
45
  );