tpmkms_4wp 9.3.0-beta.50 → 9.3.0-beta.52

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/common/dates.js CHANGED
@@ -14,7 +14,35 @@ const helpers = require('./helpers')
14
14
  const template = {
15
15
  configs: [
16
16
  "setidsuffix _dates",
17
+ ({config}) => {
18
+ const months = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]
19
+ config.addSemantic({
20
+ match: ({context}) => {
21
+ if (!context.makeObject) {
22
+ return
23
+ }
24
+ return months.includes(context.value)
25
+ },
26
+ apply: ({context}) => {
27
+ context.initial.month_ordinal = months.findIndex((month) => month == context.value) + 1
28
+ },
29
+ })
30
+ },
17
31
  "january, february, march, april, may, june, july, august, september, october, november and december are months",
32
+ ({config}) => {
33
+ const days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
34
+ config.addSemantic({
35
+ match: ({context}) => {
36
+ if (!context.makeObject) {
37
+ return
38
+ }
39
+ return days.includes(context.value)
40
+ },
41
+ apply: ({context}) => {
42
+ context.initial.day_ordinal = days.findIndex((day) => day == context.value) + 1
43
+ },
44
+ })
45
+ },
18
46
  "monday, tuesday, wednesday, thursday, friday, saturday and sunday are days",
19
47
  "ac, bc, bce and ad are eras",
20
48
  // "ac, bc,, bce,, and ad are eras",
@@ -142,6 +170,12 @@ const template = {
142
170
  convolution: true,
143
171
  before: ['preposition', 'monthDay_dates'],
144
172
  isA: ['date_dates'],
173
+ evaluator: ({context}) => {
174
+ const year = context.year.value
175
+ const day = context.day.value
176
+ const month_ordinal = context.month.month_ordinal
177
+ context.evalue = new Date(year, month_ordinal-1, day).toISOString()
178
+ },
145
179
  localHierarchy: [
146
180
  ['ordinal', 'dayNumber_dates'],
147
181
  ],
@@ -169,20 +203,31 @@ const template = {
169
203
  }
170
204
  },
171
205
  (args) => {
172
- const as = ['jan', 'feb', 'mar', 'apr', 'jun', 'jul', 'aug', 'sept', 'oct', 'nov', 'dec']
173
- const ms = ['january', 'february', 'march', 'april', 'june', 'july', 'august', 'september', 'october', 'november', 'december']
174
- // args.makeObject({...args, context: { word: as[i], value: `${ms[i]}_dates`}, types: [`${ms[i]}_dates`]})
175
- for (let i = 0; i < as.length; ++i) {
176
- const word = as[i]
177
- const id = `${ms[i]}_dates`
178
- args.addWords(id, word, { value: id, abbreviation: word })
206
+ {
207
+ const as = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sept', 'oct', 'nov', 'dec']
208
+ const ms = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']
209
+ // args.makeObject({...args, context: { word: as[i], value: `${ms[i]}_dates`}, types: [`${ms[i]}_dates`]})
210
+ for (let i = 0; i < as.length; ++i) {
211
+ const word = as[i]
212
+ if (word == 'may') {
213
+ continue
214
+ }
215
+ const id = `${ms[i]}_dates`
216
+ args.addWords(id, word, { value: id, abbreviation: word, month_ordinal: i+1 })
217
+ }
218
+ }
219
+
220
+ {
221
+ const as = ['sun', 'mon', 'tues', 'weds', 'thurs', 'fri', 'sat']
222
+ const ms = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
223
+ // args.makeObject({...args, context: { word: as[i], value: `${ms[i]}_dates`}, types: [`${ms[i]}_dates`]})
224
+ for (let i = 0; i < as.length; ++i) {
225
+ const word = as[i]
226
+ const id = `${ms[i]}_dates`
227
+ args.addWords(id, word, { value: id, abbreviation: word, day_ordinal: i+1 })
228
+ }
179
229
  }
180
230
 
181
- /*
182
- const word = 'bc'
183
- const synonym = 'bce'
184
- args.makeObject({...args, context: { word: synonym, value: `${synonym}_dates`}, types: [`${word}_dates`]})
185
- */
186
231
  },
187
232
  "resetIdSuffix",
188
233
  ],
@@ -198,7 +243,21 @@ knowledgeModule( {
198
243
  name: './dates.test.json',
199
244
  contents: dates_tests,
200
245
  checks: {
201
- context: defaultContextCheck(['day', 'month', 'year', 'era']),
246
+ context: defaultContextCheck([
247
+ 'month', 'day', 'year', 'era', 'month_ordinal', 'day_ordinal',
248
+ {
249
+ month: [
250
+ 'month_ordinal',
251
+ ],
252
+ day: [
253
+ 'day_ordinal',
254
+ ],
255
+ date: [
256
+ 'month_ordinal',
257
+ 'day_ordinal',
258
+ ],
259
+ },
260
+ ]),
202
261
  },
203
262
  },
204
263
  template: {