ezmedicationinput 0.1.44 → 0.1.45
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/index.cjs +18842 -0
- package/dist/index.js +18689 -675
- package/package.json +17 -6
- package/dist/advice-rules.json +0 -772
- package/dist/advice-terminology.json +0 -104
- package/dist/advice.js +0 -1375
- package/dist/context.js +0 -50
- package/dist/event-trigger.d.ts +0 -14
- package/dist/event-trigger.js +0 -501
- package/dist/fhir-translations.js +0 -117
- package/dist/fhir.js +0 -693
- package/dist/format.js +0 -1034
- package/dist/i18n.js +0 -1341
- package/dist/internal-types.d.ts +0 -60
- package/dist/internal-types.js +0 -2
- package/dist/ir.js +0 -178
- package/dist/lexer/lex.js +0 -401
- package/dist/lexer/meaning.js +0 -619
- package/dist/lexer/surface.js +0 -62
- package/dist/lexer/token-types.js +0 -19
- package/dist/maps.js +0 -2226
- package/dist/package.json +0 -3
- package/dist/parser-state.js +0 -441
- package/dist/parser.js +0 -5631
- package/dist/prn.js +0 -59
- package/dist/safety.js +0 -15
- package/dist/schedule.js +0 -1636
- package/dist/segment.js +0 -203
- package/dist/site-phrases.js +0 -344
- package/dist/suggest.js +0 -907
- package/dist/timing-summary.js +0 -138
- package/dist/types.js +0 -276
- package/dist/utils/array.js +0 -11
- package/dist/utils/enum.d.ts +0 -2
- package/dist/utils/enum.js +0 -7
- package/dist/utils/object.js +0 -34
- package/dist/utils/strength.js +0 -149
- package/dist/utils/text.js +0 -48
- package/dist/utils/units.js +0 -82
package/dist/lexer/meaning.js
DELETED
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenWordClass = exports.ConnectorRole = void 0;
|
|
4
|
-
exports.expandDayMeaningRange = expandDayMeaningRange;
|
|
5
|
-
exports.resolveDayMeaning = resolveDayMeaning;
|
|
6
|
-
exports.annotateLexToken = annotateLexToken;
|
|
7
|
-
exports.annotateLexTokens = annotateLexTokens;
|
|
8
|
-
exports.hasConnectorRole = hasConnectorRole;
|
|
9
|
-
exports.hasTokenWordClass = hasTokenWordClass;
|
|
10
|
-
exports.hasDayOfWeekMeaning = hasDayOfWeekMeaning;
|
|
11
|
-
exports.getDayOfWeekMeaning = getDayOfWeekMeaning;
|
|
12
|
-
exports.hasEventTimingMeaning = hasEventTimingMeaning;
|
|
13
|
-
exports.getEventTimingMeaning = getEventTimingMeaning;
|
|
14
|
-
exports.hasTimingAbbreviationMeaning = hasTimingAbbreviationMeaning;
|
|
15
|
-
exports.getTimingAbbreviationMeaning = getTimingAbbreviationMeaning;
|
|
16
|
-
exports.hasRouteMeaning = hasRouteMeaning;
|
|
17
|
-
exports.getRouteMeaning = getRouteMeaning;
|
|
18
|
-
exports.hasSiteMeaningCandidate = hasSiteMeaningCandidate;
|
|
19
|
-
exports.getSiteMeaningCandidates = getSiteMeaningCandidates;
|
|
20
|
-
exports.getPrimarySiteMeaningCandidate = getPrimarySiteMeaningCandidate;
|
|
21
|
-
exports.hasPrnMeaning = hasPrnMeaning;
|
|
22
|
-
exports.hasConnectorMeaning = hasConnectorMeaning;
|
|
23
|
-
exports.isSiteAnchorWord = isSiteAnchorWord;
|
|
24
|
-
exports.isSiteListConnectorWord = isSiteListConnectorWord;
|
|
25
|
-
exports.isSiteSurfaceModifierWord = isSiteSurfaceModifierWord;
|
|
26
|
-
exports.isWorkflowInstructionWord = isWorkflowInstructionWord;
|
|
27
|
-
exports.isApplicationVerbWord = isApplicationVerbWord;
|
|
28
|
-
exports.isAdministrationVerbWord = isAdministrationVerbWord;
|
|
29
|
-
exports.isCountKeywordWord = isCountKeywordWord;
|
|
30
|
-
exports.isMealContextConnectorWord = isMealContextConnectorWord;
|
|
31
|
-
exports.isDayRangeConnectorWord = isDayRangeConnectorWord;
|
|
32
|
-
const maps_1 = require("../maps");
|
|
33
|
-
const array_1 = require("../utils/array");
|
|
34
|
-
const types_1 = require("../types");
|
|
35
|
-
const CONNECTOR_WORDS = new Set([
|
|
36
|
-
"to",
|
|
37
|
-
"in",
|
|
38
|
-
"into",
|
|
39
|
-
"on",
|
|
40
|
-
"onto",
|
|
41
|
-
"at",
|
|
42
|
-
"with",
|
|
43
|
-
"and",
|
|
44
|
-
"or",
|
|
45
|
-
"per",
|
|
46
|
-
"each",
|
|
47
|
-
"every",
|
|
48
|
-
"for",
|
|
49
|
-
"after",
|
|
50
|
-
"before",
|
|
51
|
-
"then"
|
|
52
|
-
]);
|
|
53
|
-
const SITE_ANCHOR_WORDS = new Set([
|
|
54
|
-
"to",
|
|
55
|
-
"in",
|
|
56
|
-
"into",
|
|
57
|
-
"on",
|
|
58
|
-
"onto",
|
|
59
|
-
"at",
|
|
60
|
-
"under",
|
|
61
|
-
"around",
|
|
62
|
-
"behind",
|
|
63
|
-
"above",
|
|
64
|
-
"below",
|
|
65
|
-
"beneath",
|
|
66
|
-
"near"
|
|
67
|
-
]);
|
|
68
|
-
const SITE_LIST_CONNECTOR_WORDS = new Set(["and", "or", "&", "+", ","]);
|
|
69
|
-
const SITE_SURFACE_MODIFIER_WORDS = new Set([
|
|
70
|
-
"left",
|
|
71
|
-
"right",
|
|
72
|
-
"both",
|
|
73
|
-
"bilateral",
|
|
74
|
-
"upper",
|
|
75
|
-
"lower",
|
|
76
|
-
"middle",
|
|
77
|
-
"mid",
|
|
78
|
-
"front",
|
|
79
|
-
"back",
|
|
80
|
-
"behind",
|
|
81
|
-
"around",
|
|
82
|
-
"under",
|
|
83
|
-
"above",
|
|
84
|
-
"below",
|
|
85
|
-
"beneath",
|
|
86
|
-
"near",
|
|
87
|
-
"side",
|
|
88
|
-
"top",
|
|
89
|
-
"external",
|
|
90
|
-
"internal",
|
|
91
|
-
"big",
|
|
92
|
-
"great",
|
|
93
|
-
"affected",
|
|
94
|
-
"intact",
|
|
95
|
-
"of"
|
|
96
|
-
]);
|
|
97
|
-
const WORKFLOW_INSTRUCTION_WORDS = new Set([
|
|
98
|
-
"wash",
|
|
99
|
-
"washing",
|
|
100
|
-
"shower",
|
|
101
|
-
"showering",
|
|
102
|
-
"bath",
|
|
103
|
-
"bathing",
|
|
104
|
-
"shampoo",
|
|
105
|
-
"shampooing",
|
|
106
|
-
"rinse",
|
|
107
|
-
"rinsing",
|
|
108
|
-
"cover",
|
|
109
|
-
"dressing",
|
|
110
|
-
"leave",
|
|
111
|
-
"clean",
|
|
112
|
-
"dry",
|
|
113
|
-
"off",
|
|
114
|
-
"then"
|
|
115
|
-
]);
|
|
116
|
-
const APPLICATION_ROUTE_VERBS = new Set([
|
|
117
|
-
"apply",
|
|
118
|
-
"rub",
|
|
119
|
-
"massage",
|
|
120
|
-
"spread",
|
|
121
|
-
"dab",
|
|
122
|
-
"lather"
|
|
123
|
-
]);
|
|
124
|
-
const ADMINISTRATION_METHOD_WORDS = new Set([
|
|
125
|
-
"apply",
|
|
126
|
-
"rub",
|
|
127
|
-
"massage",
|
|
128
|
-
"spread",
|
|
129
|
-
"dab",
|
|
130
|
-
"lather",
|
|
131
|
-
"spray",
|
|
132
|
-
"take",
|
|
133
|
-
"drink",
|
|
134
|
-
"swallow",
|
|
135
|
-
"use",
|
|
136
|
-
"insert",
|
|
137
|
-
"instill",
|
|
138
|
-
"reapply",
|
|
139
|
-
"wash",
|
|
140
|
-
"shampoo"
|
|
141
|
-
]);
|
|
142
|
-
const ADMINISTRATION_ROUTE_HINTS = {
|
|
143
|
-
apply: types_1.RouteCode["Topical route"],
|
|
144
|
-
rub: types_1.RouteCode["Topical route"],
|
|
145
|
-
massage: types_1.RouteCode["Topical route"],
|
|
146
|
-
spread: types_1.RouteCode["Topical route"],
|
|
147
|
-
dab: types_1.RouteCode["Topical route"],
|
|
148
|
-
lather: types_1.RouteCode["Topical route"],
|
|
149
|
-
reapply: types_1.RouteCode["Topical route"],
|
|
150
|
-
wash: types_1.RouteCode["Topical route"],
|
|
151
|
-
shampoo: types_1.RouteCode["Topical route"],
|
|
152
|
-
take: types_1.RouteCode["Oral route"],
|
|
153
|
-
drink: types_1.RouteCode["Oral route"],
|
|
154
|
-
swallow: types_1.RouteCode["Oral route"]
|
|
155
|
-
};
|
|
156
|
-
const COUNT_KEYWORDS = new Set([
|
|
157
|
-
"time",
|
|
158
|
-
"times",
|
|
159
|
-
"dose",
|
|
160
|
-
"doses",
|
|
161
|
-
"application",
|
|
162
|
-
"applications",
|
|
163
|
-
"use",
|
|
164
|
-
"uses"
|
|
165
|
-
]);
|
|
166
|
-
const MEAL_CONTEXT_CONNECTOR_WORDS = new Set(["and", "or", "&", "+", "plus", ","]);
|
|
167
|
-
const TOKEN_SITE_CANDIDATES = {
|
|
168
|
-
od: [{ text: "right eye", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
169
|
-
re: [{ text: "right eye", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
170
|
-
os: [{ text: "left eye", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
171
|
-
le: [{ text: "left eye", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
172
|
-
ou: [{ text: "both eyes", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
173
|
-
be: [{ text: "both eyes", route: types_1.RouteCode["Ophthalmic route"], source: "abbreviation" }],
|
|
174
|
-
vod: [
|
|
175
|
-
{
|
|
176
|
-
text: "right eye",
|
|
177
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
178
|
-
source: "abbreviation"
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
vos: [
|
|
182
|
-
{
|
|
183
|
-
text: "left eye",
|
|
184
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
185
|
-
source: "abbreviation"
|
|
186
|
-
}
|
|
187
|
-
],
|
|
188
|
-
ivtod: [
|
|
189
|
-
{
|
|
190
|
-
text: "right eye",
|
|
191
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
192
|
-
source: "abbreviation"
|
|
193
|
-
}
|
|
194
|
-
],
|
|
195
|
-
ivtre: [
|
|
196
|
-
{
|
|
197
|
-
text: "right eye",
|
|
198
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
199
|
-
source: "abbreviation"
|
|
200
|
-
}
|
|
201
|
-
],
|
|
202
|
-
ivtos: [
|
|
203
|
-
{
|
|
204
|
-
text: "left eye",
|
|
205
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
206
|
-
source: "abbreviation"
|
|
207
|
-
}
|
|
208
|
-
],
|
|
209
|
-
ivtle: [
|
|
210
|
-
{
|
|
211
|
-
text: "left eye",
|
|
212
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
213
|
-
source: "abbreviation"
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
ivtou: [
|
|
217
|
-
{
|
|
218
|
-
text: "both eyes",
|
|
219
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
220
|
-
source: "abbreviation"
|
|
221
|
-
}
|
|
222
|
-
],
|
|
223
|
-
ivtbe: [
|
|
224
|
-
{
|
|
225
|
-
text: "both eyes",
|
|
226
|
-
route: types_1.RouteCode["Intravitreal route (qualifier value)"],
|
|
227
|
-
source: "abbreviation"
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
};
|
|
231
|
-
const DAY_GROUP_TOKENS = {
|
|
232
|
-
weekend: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
233
|
-
weekends: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
234
|
-
wknd: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
235
|
-
weekdays: [
|
|
236
|
-
types_1.FhirDayOfWeek.Monday,
|
|
237
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
238
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
239
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
240
|
-
types_1.FhirDayOfWeek.Friday
|
|
241
|
-
],
|
|
242
|
-
weekday: [
|
|
243
|
-
types_1.FhirDayOfWeek.Monday,
|
|
244
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
245
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
246
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
247
|
-
types_1.FhirDayOfWeek.Friday
|
|
248
|
-
],
|
|
249
|
-
workday: [
|
|
250
|
-
types_1.FhirDayOfWeek.Monday,
|
|
251
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
252
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
253
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
254
|
-
types_1.FhirDayOfWeek.Friday
|
|
255
|
-
],
|
|
256
|
-
workdays: [
|
|
257
|
-
types_1.FhirDayOfWeek.Monday,
|
|
258
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
259
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
260
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
261
|
-
types_1.FhirDayOfWeek.Friday
|
|
262
|
-
],
|
|
263
|
-
วันธรรมดา: [
|
|
264
|
-
types_1.FhirDayOfWeek.Monday,
|
|
265
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
266
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
267
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
268
|
-
types_1.FhirDayOfWeek.Friday
|
|
269
|
-
],
|
|
270
|
-
วันทำงาน: [
|
|
271
|
-
types_1.FhirDayOfWeek.Monday,
|
|
272
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
273
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
274
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
275
|
-
types_1.FhirDayOfWeek.Friday
|
|
276
|
-
],
|
|
277
|
-
วันหยุด: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
278
|
-
วันเสาร์อาทิตย์: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
279
|
-
สุดสัปดาห์: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
280
|
-
เสาร์อาทิตย์: [types_1.FhirDayOfWeek.Saturday, types_1.FhirDayOfWeek.Sunday],
|
|
281
|
-
จันทร์ถึงศุกร์: [
|
|
282
|
-
types_1.FhirDayOfWeek.Monday,
|
|
283
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
284
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
285
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
286
|
-
types_1.FhirDayOfWeek.Friday
|
|
287
|
-
]
|
|
288
|
-
};
|
|
289
|
-
const DAY_SEQUENCE = [
|
|
290
|
-
types_1.FhirDayOfWeek.Monday,
|
|
291
|
-
types_1.FhirDayOfWeek.Tuesday,
|
|
292
|
-
types_1.FhirDayOfWeek.Wednesday,
|
|
293
|
-
types_1.FhirDayOfWeek.Thursday,
|
|
294
|
-
types_1.FhirDayOfWeek.Friday,
|
|
295
|
-
types_1.FhirDayOfWeek.Saturday,
|
|
296
|
-
types_1.FhirDayOfWeek.Sunday
|
|
297
|
-
];
|
|
298
|
-
const DAY_RANGE_CONNECTOR_WORDS = new Set(["-", "to", "through", "thru", "ถึง", "จนถึง"]);
|
|
299
|
-
var ConnectorRole;
|
|
300
|
-
(function (ConnectorRole) {
|
|
301
|
-
ConnectorRole["General"] = "GENERAL";
|
|
302
|
-
ConnectorRole["SiteAnchor"] = "SITE_ANCHOR";
|
|
303
|
-
ConnectorRole["SiteList"] = "SITE_LIST";
|
|
304
|
-
ConnectorRole["MealContext"] = "MEAL_CONTEXT";
|
|
305
|
-
ConnectorRole["DayRange"] = "DAY_RANGE";
|
|
306
|
-
})(ConnectorRole || (exports.ConnectorRole = ConnectorRole = {}));
|
|
307
|
-
var TokenWordClass;
|
|
308
|
-
(function (TokenWordClass) {
|
|
309
|
-
TokenWordClass["AdministrationVerb"] = "ADMINISTRATION_VERB";
|
|
310
|
-
TokenWordClass["SiteSurfaceModifier"] = "SITE_SURFACE_MODIFIER";
|
|
311
|
-
TokenWordClass["WorkflowInstruction"] = "WORKFLOW_INSTRUCTION";
|
|
312
|
-
TokenWordClass["ApplicationVerb"] = "APPLICATION_VERB";
|
|
313
|
-
TokenWordClass["CountKeyword"] = "COUNT_KEYWORD";
|
|
314
|
-
})(TokenWordClass || (exports.TokenWordClass = TokenWordClass = {}));
|
|
315
|
-
function normalizeMeaningKey(value) {
|
|
316
|
-
return value.toLowerCase().replace(/[.{}]/g, "");
|
|
317
|
-
}
|
|
318
|
-
function pushEnum(values, value) {
|
|
319
|
-
if (!values) {
|
|
320
|
-
return [value];
|
|
321
|
-
}
|
|
322
|
-
if (!(0, array_1.arrayIncludes)(values, value)) {
|
|
323
|
-
values.push(value);
|
|
324
|
-
}
|
|
325
|
-
return values;
|
|
326
|
-
}
|
|
327
|
-
function pushRouteCandidate(candidates, candidate) {
|
|
328
|
-
if (!candidates) {
|
|
329
|
-
return [candidate];
|
|
330
|
-
}
|
|
331
|
-
for (const existing of candidates) {
|
|
332
|
-
if (existing.code === candidate.code && existing.text === candidate.text) {
|
|
333
|
-
return candidates;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
candidates.push(candidate);
|
|
337
|
-
return candidates;
|
|
338
|
-
}
|
|
339
|
-
function expandDayMeaningRange(start, end) {
|
|
340
|
-
const startIndex = DAY_SEQUENCE.indexOf(start);
|
|
341
|
-
const endIndex = DAY_SEQUENCE.indexOf(end);
|
|
342
|
-
if (startIndex < 0 || endIndex < 0) {
|
|
343
|
-
return [start, end];
|
|
344
|
-
}
|
|
345
|
-
if (startIndex <= endIndex) {
|
|
346
|
-
return DAY_SEQUENCE.slice(startIndex, endIndex + 1);
|
|
347
|
-
}
|
|
348
|
-
return [...DAY_SEQUENCE.slice(startIndex), ...DAY_SEQUENCE.slice(0, endIndex + 1)];
|
|
349
|
-
}
|
|
350
|
-
function resolveDayMeaning(tokenLower) {
|
|
351
|
-
const normalized = normalizeMeaningKey(tokenLower);
|
|
352
|
-
const direct = maps_1.DAY_OF_WEEK_TOKENS[normalized];
|
|
353
|
-
if (direct) {
|
|
354
|
-
return [direct];
|
|
355
|
-
}
|
|
356
|
-
const grouped = DAY_GROUP_TOKENS[normalized];
|
|
357
|
-
if (grouped) {
|
|
358
|
-
return grouped.slice();
|
|
359
|
-
}
|
|
360
|
-
const rangeMatch = normalized.match(/^([^-–—~/]+)[-–—~/]([^-–—~/]+)$/);
|
|
361
|
-
if (rangeMatch) {
|
|
362
|
-
const startKey = rangeMatch[1].trim();
|
|
363
|
-
const endKey = rangeMatch[2].trim();
|
|
364
|
-
const start = maps_1.DAY_OF_WEEK_TOKENS[startKey];
|
|
365
|
-
const end = maps_1.DAY_OF_WEEK_TOKENS[endKey];
|
|
366
|
-
if (start && end) {
|
|
367
|
-
return expandDayMeaningRange(start, end);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
const compactConnectorRange = normalized.match(/^(.+?)(ถึง|จนถึง|to|through|thru)(.+)$/u);
|
|
371
|
-
if (compactConnectorRange) {
|
|
372
|
-
const startKey = compactConnectorRange[1].trim();
|
|
373
|
-
const endKey = compactConnectorRange[3].trim();
|
|
374
|
-
const start = maps_1.DAY_OF_WEEK_TOKENS[startKey];
|
|
375
|
-
const end = maps_1.DAY_OF_WEEK_TOKENS[endKey];
|
|
376
|
-
if (start && end) {
|
|
377
|
-
return expandDayMeaningRange(start, end);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return undefined;
|
|
381
|
-
}
|
|
382
|
-
function annotateLexToken(token) {
|
|
383
|
-
const normalized = normalizeMeaningKey(token.lower);
|
|
384
|
-
let annotations;
|
|
385
|
-
const eventTiming = maps_1.EVENT_TIMING_TOKENS[normalized];
|
|
386
|
-
if (eventTiming) {
|
|
387
|
-
annotations = annotations || {};
|
|
388
|
-
annotations.eventTiming = eventTiming;
|
|
389
|
-
}
|
|
390
|
-
const timingAbbreviation = maps_1.TIMING_ABBREVIATIONS[normalized];
|
|
391
|
-
if (timingAbbreviation) {
|
|
392
|
-
annotations = annotations || {};
|
|
393
|
-
annotations.timingAbbreviation = timingAbbreviation;
|
|
394
|
-
}
|
|
395
|
-
const dayOfWeek = resolveDayMeaning(normalized);
|
|
396
|
-
if (dayOfWeek) {
|
|
397
|
-
annotations = annotations || {};
|
|
398
|
-
annotations.dayOfWeek = dayOfWeek;
|
|
399
|
-
}
|
|
400
|
-
const routeSynonym = maps_1.DEFAULT_ROUTE_SYNONYMS[normalized];
|
|
401
|
-
if (routeSynonym) {
|
|
402
|
-
annotations = annotations || {};
|
|
403
|
-
annotations.routeCandidates = pushRouteCandidate(annotations.routeCandidates, Object.assign(Object.assign({}, routeSynonym), { source: "synonym" }));
|
|
404
|
-
}
|
|
405
|
-
const administrationRoute = ADMINISTRATION_ROUTE_HINTS[normalized];
|
|
406
|
-
if (ADMINISTRATION_METHOD_WORDS.has(normalized)) {
|
|
407
|
-
annotations = annotations || {};
|
|
408
|
-
annotations.wordClasses = pushEnum(annotations.wordClasses, TokenWordClass.AdministrationVerb);
|
|
409
|
-
}
|
|
410
|
-
if (administrationRoute) {
|
|
411
|
-
annotations = annotations || {};
|
|
412
|
-
annotations.routeCandidates = pushRouteCandidate(annotations.routeCandidates, {
|
|
413
|
-
code: administrationRoute,
|
|
414
|
-
text: maps_1.ROUTE_TEXT[administrationRoute],
|
|
415
|
-
source: "verb"
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
const siteCandidates = TOKEN_SITE_CANDIDATES[normalized];
|
|
419
|
-
if (siteCandidates) {
|
|
420
|
-
annotations = annotations || {};
|
|
421
|
-
annotations.siteCandidates = siteCandidates.slice();
|
|
422
|
-
}
|
|
423
|
-
if (normalized === "prn" || normalized === "needed") {
|
|
424
|
-
annotations = annotations || {};
|
|
425
|
-
annotations.prn = true;
|
|
426
|
-
}
|
|
427
|
-
if (CONNECTOR_WORDS.has(normalized) || normalized === "," || normalized === ";") {
|
|
428
|
-
annotations = annotations || {};
|
|
429
|
-
annotations.connectorRoles = pushEnum(annotations.connectorRoles, ConnectorRole.General);
|
|
430
|
-
}
|
|
431
|
-
if (SITE_ANCHOR_WORDS.has(normalized)) {
|
|
432
|
-
annotations = annotations || {};
|
|
433
|
-
annotations.connectorRoles = pushEnum(annotations.connectorRoles, ConnectorRole.SiteAnchor);
|
|
434
|
-
}
|
|
435
|
-
if (SITE_LIST_CONNECTOR_WORDS.has(normalized)) {
|
|
436
|
-
annotations = annotations || {};
|
|
437
|
-
annotations.connectorRoles = pushEnum(annotations.connectorRoles, ConnectorRole.SiteList);
|
|
438
|
-
}
|
|
439
|
-
if (MEAL_CONTEXT_CONNECTOR_WORDS.has(normalized)) {
|
|
440
|
-
annotations = annotations || {};
|
|
441
|
-
annotations.connectorRoles = pushEnum(annotations.connectorRoles, ConnectorRole.MealContext);
|
|
442
|
-
}
|
|
443
|
-
if (DAY_RANGE_CONNECTOR_WORDS.has(normalized)) {
|
|
444
|
-
annotations = annotations || {};
|
|
445
|
-
annotations.connectorRoles = pushEnum(annotations.connectorRoles, ConnectorRole.DayRange);
|
|
446
|
-
}
|
|
447
|
-
if (SITE_SURFACE_MODIFIER_WORDS.has(normalized)) {
|
|
448
|
-
annotations = annotations || {};
|
|
449
|
-
annotations.wordClasses = pushEnum(annotations.wordClasses, TokenWordClass.SiteSurfaceModifier);
|
|
450
|
-
}
|
|
451
|
-
if (WORKFLOW_INSTRUCTION_WORDS.has(normalized)) {
|
|
452
|
-
annotations = annotations || {};
|
|
453
|
-
annotations.wordClasses = pushEnum(annotations.wordClasses, TokenWordClass.WorkflowInstruction);
|
|
454
|
-
}
|
|
455
|
-
if (APPLICATION_ROUTE_VERBS.has(normalized)) {
|
|
456
|
-
annotations = annotations || {};
|
|
457
|
-
annotations.wordClasses = pushEnum(annotations.wordClasses, TokenWordClass.ApplicationVerb);
|
|
458
|
-
}
|
|
459
|
-
if (COUNT_KEYWORDS.has(normalized)) {
|
|
460
|
-
annotations = annotations || {};
|
|
461
|
-
annotations.wordClasses = pushEnum(annotations.wordClasses, TokenWordClass.CountKeyword);
|
|
462
|
-
}
|
|
463
|
-
if (!annotations) {
|
|
464
|
-
return token;
|
|
465
|
-
}
|
|
466
|
-
return Object.assign(Object.assign({}, token), { annotations });
|
|
467
|
-
}
|
|
468
|
-
function annotateLexTokens(tokens) {
|
|
469
|
-
return tokens.map((token) => annotateLexToken(token));
|
|
470
|
-
}
|
|
471
|
-
function hasConnectorRole(token, role) {
|
|
472
|
-
var _a;
|
|
473
|
-
return Boolean(((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.connectorRoles) && (0, array_1.arrayIncludes)(token.annotations.connectorRoles, role));
|
|
474
|
-
}
|
|
475
|
-
function hasTokenWordClass(token, wordClass) {
|
|
476
|
-
var _a;
|
|
477
|
-
return Boolean(((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.wordClasses) && (0, array_1.arrayIncludes)(token.annotations.wordClasses, wordClass));
|
|
478
|
-
}
|
|
479
|
-
function hasDayOfWeekMeaning(token) {
|
|
480
|
-
var _a;
|
|
481
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.dayOfWeek) {
|
|
482
|
-
return true;
|
|
483
|
-
}
|
|
484
|
-
return Boolean(token && resolveDayMeaning(token.lower));
|
|
485
|
-
}
|
|
486
|
-
function getDayOfWeekMeaning(token) {
|
|
487
|
-
var _a;
|
|
488
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.dayOfWeek) {
|
|
489
|
-
return token.annotations.dayOfWeek.slice();
|
|
490
|
-
}
|
|
491
|
-
if (!token) {
|
|
492
|
-
return undefined;
|
|
493
|
-
}
|
|
494
|
-
return resolveDayMeaning(token.lower);
|
|
495
|
-
}
|
|
496
|
-
function hasEventTimingMeaning(token) {
|
|
497
|
-
var _a;
|
|
498
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.eventTiming) {
|
|
499
|
-
return true;
|
|
500
|
-
}
|
|
501
|
-
return Boolean(token && maps_1.EVENT_TIMING_TOKENS[normalizeMeaningKey(token.lower)]);
|
|
502
|
-
}
|
|
503
|
-
function getEventTimingMeaning(token) {
|
|
504
|
-
var _a;
|
|
505
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.eventTiming) {
|
|
506
|
-
return token.annotations.eventTiming;
|
|
507
|
-
}
|
|
508
|
-
if (!token) {
|
|
509
|
-
return undefined;
|
|
510
|
-
}
|
|
511
|
-
return maps_1.EVENT_TIMING_TOKENS[normalizeMeaningKey(token.lower)];
|
|
512
|
-
}
|
|
513
|
-
function hasTimingAbbreviationMeaning(token) {
|
|
514
|
-
var _a;
|
|
515
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.timingAbbreviation) {
|
|
516
|
-
return true;
|
|
517
|
-
}
|
|
518
|
-
return Boolean(token && maps_1.TIMING_ABBREVIATIONS[normalizeMeaningKey(token.lower)]);
|
|
519
|
-
}
|
|
520
|
-
function getTimingAbbreviationMeaning(token) {
|
|
521
|
-
var _a;
|
|
522
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.timingAbbreviation) {
|
|
523
|
-
return token.annotations.timingAbbreviation;
|
|
524
|
-
}
|
|
525
|
-
if (!token) {
|
|
526
|
-
return undefined;
|
|
527
|
-
}
|
|
528
|
-
return maps_1.TIMING_ABBREVIATIONS[normalizeMeaningKey(token.lower)];
|
|
529
|
-
}
|
|
530
|
-
function hasRouteMeaning(token) {
|
|
531
|
-
var _a, _b;
|
|
532
|
-
if ((_b = (_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.routeCandidates) === null || _b === void 0 ? void 0 : _b.length) {
|
|
533
|
-
return true;
|
|
534
|
-
}
|
|
535
|
-
return Boolean(token && maps_1.DEFAULT_ROUTE_SYNONYMS[normalizeMeaningKey(token.lower)]);
|
|
536
|
-
}
|
|
537
|
-
function getRouteMeaning(token) {
|
|
538
|
-
var _a, _b;
|
|
539
|
-
if ((_b = (_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.routeCandidates) === null || _b === void 0 ? void 0 : _b.length) {
|
|
540
|
-
return token.annotations.routeCandidates[0];
|
|
541
|
-
}
|
|
542
|
-
if (!token) {
|
|
543
|
-
return undefined;
|
|
544
|
-
}
|
|
545
|
-
const synonym = maps_1.DEFAULT_ROUTE_SYNONYMS[normalizeMeaningKey(token.lower)];
|
|
546
|
-
return synonym
|
|
547
|
-
? Object.assign(Object.assign({}, synonym), { source: "synonym" }) : undefined;
|
|
548
|
-
}
|
|
549
|
-
function hasSiteMeaningCandidate(token) {
|
|
550
|
-
var _a, _b;
|
|
551
|
-
if ((_b = (_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.siteCandidates) === null || _b === void 0 ? void 0 : _b.length) {
|
|
552
|
-
return true;
|
|
553
|
-
}
|
|
554
|
-
return Boolean(token && TOKEN_SITE_CANDIDATES[normalizeMeaningKey(token.lower)]);
|
|
555
|
-
}
|
|
556
|
-
function getSiteMeaningCandidates(token) {
|
|
557
|
-
var _a, _b;
|
|
558
|
-
if ((_b = (_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.siteCandidates) === null || _b === void 0 ? void 0 : _b.length) {
|
|
559
|
-
return token.annotations.siteCandidates.slice();
|
|
560
|
-
}
|
|
561
|
-
if (!token) {
|
|
562
|
-
return undefined;
|
|
563
|
-
}
|
|
564
|
-
const candidates = TOKEN_SITE_CANDIDATES[normalizeMeaningKey(token.lower)];
|
|
565
|
-
return candidates ? candidates.slice() : undefined;
|
|
566
|
-
}
|
|
567
|
-
function getPrimarySiteMeaningCandidate(token) {
|
|
568
|
-
const candidates = getSiteMeaningCandidates(token);
|
|
569
|
-
return candidates && candidates.length > 0 ? candidates[0] : undefined;
|
|
570
|
-
}
|
|
571
|
-
function hasPrnMeaning(token) {
|
|
572
|
-
var _a;
|
|
573
|
-
if ((_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.prn) {
|
|
574
|
-
return true;
|
|
575
|
-
}
|
|
576
|
-
if (!token) {
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
const normalized = normalizeMeaningKey(token.lower);
|
|
580
|
-
return normalized === "prn" || normalized === "needed";
|
|
581
|
-
}
|
|
582
|
-
function hasConnectorMeaning(token) {
|
|
583
|
-
var _a, _b;
|
|
584
|
-
if ((_b = (_a = token === null || token === void 0 ? void 0 : token.annotations) === null || _a === void 0 ? void 0 : _a.connectorRoles) === null || _b === void 0 ? void 0 : _b.length) {
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
if (!token) {
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
const normalized = normalizeMeaningKey(token.lower);
|
|
591
|
-
return CONNECTOR_WORDS.has(normalized) || normalized === "," || normalized === ";";
|
|
592
|
-
}
|
|
593
|
-
function isSiteAnchorWord(word) {
|
|
594
|
-
return SITE_ANCHOR_WORDS.has(normalizeMeaningKey(word));
|
|
595
|
-
}
|
|
596
|
-
function isSiteListConnectorWord(word) {
|
|
597
|
-
return SITE_LIST_CONNECTOR_WORDS.has(normalizeMeaningKey(word));
|
|
598
|
-
}
|
|
599
|
-
function isSiteSurfaceModifierWord(word) {
|
|
600
|
-
return SITE_SURFACE_MODIFIER_WORDS.has(normalizeMeaningKey(word));
|
|
601
|
-
}
|
|
602
|
-
function isWorkflowInstructionWord(word) {
|
|
603
|
-
return WORKFLOW_INSTRUCTION_WORDS.has(normalizeMeaningKey(word));
|
|
604
|
-
}
|
|
605
|
-
function isApplicationVerbWord(word) {
|
|
606
|
-
return APPLICATION_ROUTE_VERBS.has(normalizeMeaningKey(word));
|
|
607
|
-
}
|
|
608
|
-
function isAdministrationVerbWord(word) {
|
|
609
|
-
return ADMINISTRATION_METHOD_WORDS.has(normalizeMeaningKey(word));
|
|
610
|
-
}
|
|
611
|
-
function isCountKeywordWord(word) {
|
|
612
|
-
return COUNT_KEYWORDS.has(normalizeMeaningKey(word));
|
|
613
|
-
}
|
|
614
|
-
function isMealContextConnectorWord(word) {
|
|
615
|
-
return MEAL_CONTEXT_CONNECTOR_WORDS.has(normalizeMeaningKey(word));
|
|
616
|
-
}
|
|
617
|
-
function isDayRangeConnectorWord(word) {
|
|
618
|
-
return DAY_RANGE_CONNECTOR_WORDS.has(normalizeMeaningKey(word));
|
|
619
|
-
}
|
package/dist/lexer/surface.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scanSurfaceTokens = scanSurfaceTokens;
|
|
4
|
-
const text_1 = require("../utils/text");
|
|
5
|
-
const token_types_1 = require("./token-types");
|
|
6
|
-
const SEPARATOR_CHARS = new Set([",", ";", "(", ")"]);
|
|
7
|
-
const PUNCTUATION_CHARS = new Set(["\\", "+", "&"]);
|
|
8
|
-
function classifySurfaceKind(char) {
|
|
9
|
-
if (SEPARATOR_CHARS.has(char)) {
|
|
10
|
-
return token_types_1.SurfaceTokenKind.Separator;
|
|
11
|
-
}
|
|
12
|
-
if (PUNCTUATION_CHARS.has(char)) {
|
|
13
|
-
return token_types_1.SurfaceTokenKind.Punctuation;
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
function isStandaloneSurfaceChar(char) {
|
|
18
|
-
return classifySurfaceKind(char) !== undefined;
|
|
19
|
-
}
|
|
20
|
-
function scanSurfaceTokens(input) {
|
|
21
|
-
const tokens = [];
|
|
22
|
-
let cursor = 0;
|
|
23
|
-
while (cursor < input.length) {
|
|
24
|
-
const char = input[cursor];
|
|
25
|
-
if ((0, text_1.isWhitespaceChar)(char)) {
|
|
26
|
-
cursor += 1;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const standaloneKind = classifySurfaceKind(char);
|
|
30
|
-
if (standaloneKind) {
|
|
31
|
-
tokens.push({
|
|
32
|
-
original: char,
|
|
33
|
-
lower: char.toLowerCase(),
|
|
34
|
-
index: tokens.length,
|
|
35
|
-
kind: standaloneKind,
|
|
36
|
-
start: cursor,
|
|
37
|
-
end: cursor + 1
|
|
38
|
-
});
|
|
39
|
-
cursor += 1;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const start = cursor;
|
|
43
|
-
cursor += 1;
|
|
44
|
-
while (cursor < input.length) {
|
|
45
|
-
const next = input[cursor];
|
|
46
|
-
if ((0, text_1.isWhitespaceChar)(next) || isStandaloneSurfaceChar(next)) {
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
cursor += 1;
|
|
50
|
-
}
|
|
51
|
-
const original = input.slice(start, cursor);
|
|
52
|
-
tokens.push({
|
|
53
|
-
original,
|
|
54
|
-
lower: original.toLowerCase(),
|
|
55
|
-
index: tokens.length,
|
|
56
|
-
kind: token_types_1.SurfaceTokenKind.Text,
|
|
57
|
-
start,
|
|
58
|
-
end: cursor
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return tokens;
|
|
62
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LexKind = exports.SurfaceTokenKind = void 0;
|
|
4
|
-
var SurfaceTokenKind;
|
|
5
|
-
(function (SurfaceTokenKind) {
|
|
6
|
-
SurfaceTokenKind["Text"] = "TEXT";
|
|
7
|
-
SurfaceTokenKind["Separator"] = "SEPARATOR";
|
|
8
|
-
SurfaceTokenKind["Punctuation"] = "PUNCTUATION";
|
|
9
|
-
})(SurfaceTokenKind || (exports.SurfaceTokenKind = SurfaceTokenKind = {}));
|
|
10
|
-
var LexKind;
|
|
11
|
-
(function (LexKind) {
|
|
12
|
-
LexKind["Word"] = "WORD";
|
|
13
|
-
LexKind["Number"] = "NUMBER";
|
|
14
|
-
LexKind["NumberRange"] = "NUMBER_RANGE";
|
|
15
|
-
LexKind["Ordinal"] = "ORDINAL";
|
|
16
|
-
LexKind["TimeLike"] = "TIME_LIKE";
|
|
17
|
-
LexKind["Separator"] = "SEPARATOR";
|
|
18
|
-
LexKind["Punctuation"] = "PUNCTUATION";
|
|
19
|
-
})(LexKind || (exports.LexKind = LexKind = {}));
|