de-compromise 0.1.1 → 0.1.2

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 (64) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -11
  3. package/builds/de-compromise.cjs +2284 -1216
  4. package/builds/de-compromise.min.js +3 -1
  5. package/builds/de-compromise.mjs +3 -1
  6. package/package.json +42 -39
  7. package/src/01-one/lexicon/_data.js +22 -22
  8. package/src/01-one/lexicon/compute/root.js +3 -3
  9. package/src/01-one/lexicon/lexicon.js +6 -6
  10. package/src/01-one/lexicon/methods/_data.js +29 -174
  11. package/src/01-one/lexicon/methods/adjectives/_test-back.js +1 -1
  12. package/src/01-one/lexicon/methods/adjectives/_test.js +4 -4
  13. package/src/01-one/lexicon/methods/adjectives/inflect.js +1 -1
  14. package/src/01-one/lexicon/methods/adjectives/new/adjective.js +1 -1
  15. package/src/01-one/lexicon/methods/adjectives/new/comparative.js +1 -1
  16. package/src/01-one/lexicon/methods/adjectives/new/superlative.js +1 -1
  17. package/src/01-one/lexicon/methods/adjectives/toRoot.js +1 -1
  18. package/src/01-one/lexicon/methods/nouns/_test-back.js +6 -6
  19. package/src/01-one/lexicon/methods/nouns/new.js +1 -1
  20. package/src/01-one/lexicon/methods/nouns/toPlural.js +2 -2
  21. package/src/01-one/lexicon/methods/nouns/toSingular.js +2 -2
  22. package/src/01-one/lexicon/methods/verbs/conjugate.js +4 -4
  23. package/src/01-one/lexicon/methods/verbs/custom/_test-from.js +6 -6
  24. package/src/01-one/lexicon/methods/verbs/custom/_test-to.js +7 -7
  25. package/src/01-one/lexicon/methods/verbs/custom/fromPastParticiple.js +1 -1
  26. package/src/01-one/lexicon/methods/verbs/custom/rules.js +2 -2
  27. package/src/01-one/lexicon/methods/verbs/custom/toPastParticiple.js +2 -2
  28. package/src/01-one/lexicon/methods/verbs/irregulars.js +6 -6
  29. package/src/01-one/lexicon/methods/verbs/toRoot.js +8 -8
  30. package/src/01-one/splitter/build.js +3 -3
  31. package/src/01-one/splitter/compute/splitter.js +4 -4
  32. package/src/01-one/splitter/model/index.js +4 -4
  33. package/src/01-one/splitter/trie.js +3 -3
  34. package/src/01-one/tagset/plugin.js +1 -1
  35. package/src/01-one/tagset/tags/dates.js +10 -0
  36. package/src/01-one/tagset/tags/misc.js +21 -2
  37. package/src/01-one/tagset/tags/nouns.js +26 -1
  38. package/src/01-one/tagset/tags/values.js +10 -0
  39. package/src/01-one/tagset/tags/verbs.js +18 -0
  40. package/src/01-one/tokenizer/is-sentence.js +3 -3
  41. package/src/01-one/tokenizer/unicode.js +2 -2
  42. package/src/02-two/preTagger/compute/1st-pass/regex.js +4 -4
  43. package/src/02-two/preTagger/compute/1st-pass/titlecase.js +2 -2
  44. package/src/02-two/preTagger/compute/1st-pass/year.js +2 -2
  45. package/src/02-two/preTagger/compute/2nd-pass/acronym.js +3 -3
  46. package/src/02-two/preTagger/compute/2nd-pass/fallback.js +2 -2
  47. package/src/02-two/preTagger/compute/2nd-pass/prefix-lookup.js +5 -5
  48. package/src/02-two/preTagger/compute/2nd-pass/suffix-lookup.js +5 -5
  49. package/src/02-two/preTagger/compute/index.js +1 -1
  50. package/src/03-three/adjectives/api.js +3 -3
  51. package/src/03-three/nouns/api.js +6 -6
  52. package/src/03-three/numbers/api.js +35 -35
  53. package/src/03-three/numbers/data.js +2 -2
  54. package/src/03-three/numbers/format/index.js +2 -2
  55. package/src/03-three/numbers/format/toText.js +12 -12
  56. package/src/03-three/numbers/parse/fromText.js +3 -3
  57. package/src/03-three/numbers/parse/index.js +5 -5
  58. package/src/03-three/verbs/api.js +1 -1
  59. package/src/_version.js +1 -1
  60. package/src/index.js +2 -2
  61. package/types/index.d.cts +9 -0
  62. package/types/index.d.ts +2 -2
  63. package/types/view/de.ts +1 -1
  64. package/types/view/one.ts +1 -1
@@ -2,6 +2,7 @@ const entity = ['Person', 'Place', 'Organization']
2
2
 
3
3
  export default {
4
4
  Noun: {
5
+ aliases: [null, 'Nomen', 'Substantiv'],
5
6
  not: ['Verb', 'Adjective', 'Adverb', 'Value', 'Determiner'],
6
7
  },
7
8
  Singular: {
@@ -9,6 +10,7 @@ export default {
9
10
  not: ['Plural'],
10
11
  },
11
12
  ProperNoun: {
13
+ aliases: [null, 'Eigenname'],
12
14
  is: 'Noun',
13
15
  },
14
16
  Person: {
@@ -17,34 +19,42 @@ export default {
17
19
  not: ['Place', 'Organization', 'Date'],
18
20
  },
19
21
  FirstName: {
22
+ aliases: [null, 'Vorname'],
20
23
  is: 'Person',
21
24
  },
22
25
  MaleName: {
26
+ aliases: [null, 'Männername'],
23
27
  is: 'FirstName',
24
28
  not: ['FemaleName', 'LastName'],
25
29
  },
26
30
  FemaleName: {
31
+ aliases: [null, 'Frauenname'],
27
32
  is: 'FirstName',
28
33
  not: ['MaleName', 'LastName'],
29
34
  },
30
35
  LastName: {
36
+ aliases: [null, 'Nachname'],
31
37
  is: 'Person',
32
38
  not: ['FirstName'],
33
39
  },
34
40
  Honorific: {
41
+ aliases: [null, 'Titel'],
35
42
  is: 'Noun',
36
43
  not: ['FirstName', 'LastName', 'Value'],
37
44
  },
38
45
  Place: {
46
+ aliases: [null, 'Ort'],
39
47
  is: 'Singular',
40
48
  not: ['Person', 'Organization'],
41
49
  },
42
50
  Country: {
51
+ aliases: [null, 'Land'],
43
52
  is: 'Place',
44
53
  also: ['ProperNoun'],
45
54
  not: ['City'],
46
55
  },
47
56
  City: {
57
+ aliases: [null, 'Stadt'],
48
58
  is: 'Place',
49
59
  also: ['ProperNoun'],
50
60
  not: ['Country'],
@@ -54,19 +64,24 @@ export default {
54
64
  also: ['ProperNoun'],
55
65
  },
56
66
  Address: {
67
+ aliases: [null, 'Adresse'],
57
68
  // is: 'Place',
58
69
  },
59
70
  Organization: {
71
+ aliases: [null, 'Organisation'],
60
72
  is: 'ProperNoun',
61
73
  not: ['Person', 'Place'],
62
74
  },
63
75
  SportsTeam: {
76
+ aliases: [null, 'Mannschaft'],
64
77
  is: 'Organization',
65
78
  },
66
79
  School: {
80
+ aliases: [null, 'Schule'],
67
81
  is: 'Organization',
68
82
  },
69
83
  Company: {
84
+ aliases: [null, 'Unternehmen'],
70
85
  is: 'Organization',
71
86
  },
72
87
  Plural: {
@@ -74,9 +89,11 @@ export default {
74
89
  not: ['Singular'],
75
90
  },
76
91
  Uncountable: {
92
+ aliases: [null, 'Unzählbar'],
77
93
  is: 'Noun',
78
94
  },
79
95
  Pronoun: {
96
+ aliases: [null, 'Pronomen'],
80
97
  is: 'Noun',
81
98
  not: entity,
82
99
  },
@@ -85,31 +102,39 @@ export default {
85
102
  not: entity,
86
103
  },
87
104
  Activity: {
105
+ aliases: [null, 'Aktivität'],
88
106
  is: 'Noun',
89
107
  not: ['Person', 'Place'],
90
108
  },
91
109
  Unit: {
110
+ aliases: [null, 'Einheit'],
92
111
  is: 'Noun',
93
112
  not: entity,
94
113
  },
95
114
  Demonym: {
115
+ aliases: [null, 'Einwohnername'],
96
116
  is: 'Noun',
97
117
  also: ['ProperNoun'],
98
118
  not: entity,
99
119
  },
100
120
  // standalone — 'meinem' is #Possessive as both a determiner ('meinem Freund')
101
121
  // and a pronoun ('das ist meins')
102
- Possessive: {},
122
+ Possessive: {
123
+ aliases: [null, 'Possessiv'],
124
+ },
103
125
  // german genders
104
126
  MaleNoun: {
127
+ aliases: [null, 'Maskulinum'],
105
128
  is: 'Noun',
106
129
  not: ['FemaleNoun', 'NeuterNoun'],
107
130
  },
108
131
  FemaleNoun: {
132
+ aliases: [null, 'Femininum'],
109
133
  is: 'Noun',
110
134
  not: ['MaleNoun', 'NeuterNoun'],
111
135
  },
112
136
  NeuterNoun: {
137
+ aliases: [null, 'Neutrum'],
113
138
  is: 'Noun',
114
139
  not: ['MaleNoun', 'FemaleNoun'],
115
140
  },
@@ -1,27 +1,34 @@
1
1
  export default {
2
2
  Value: {
3
+ aliases: [null, 'Zahl'],
3
4
  not: ['Verb', 'Adjective', 'Adverb'],
4
5
  },
5
6
  Ordinal: {
7
+ aliases: [null, 'Ordinalzahl'],
6
8
  is: 'Value',
7
9
  not: ['Cardinal'],
8
10
  },
9
11
  Cardinal: {
12
+ aliases: [null, 'Kardinalzahl'],
10
13
  is: 'Value',
11
14
  not: ['Ordinal'],
12
15
  },
13
16
  Fraction: {
17
+ aliases: [null, 'Bruchzahl'],
14
18
  is: 'Value',
15
19
  not: ['Noun'],
16
20
  },
17
21
  Multiple: {
22
+ aliases: [null, 'Vielfaches'],
18
23
  is: 'Value',
19
24
  },
20
25
  RomanNumeral: {
26
+ aliases: [null, 'RömischeZahl'],
21
27
  is: 'Cardinal',
22
28
  not: ['TextValue'],
23
29
  },
24
30
  TextValue: {
31
+ aliases: [null, 'Zahlwort'],
25
32
  is: 'Value',
26
33
  not: ['NumericValue'],
27
34
  },
@@ -35,13 +42,16 @@ export default {
35
42
  },
36
43
 
37
44
  NumericValue: {
45
+ aliases: [null, 'Numerisch'],
38
46
  is: 'Value',
39
47
  not: ['TextValue'],
40
48
  },
41
49
  Money: {
50
+ aliases: [null, 'Geld'],
42
51
  is: 'Cardinal',
43
52
  },
44
53
  Percent: {
54
+ aliases: [null, 'Prozent'],
45
55
  is: 'Value',
46
56
  },
47
57
  }
@@ -3,62 +3,80 @@ export default {
3
3
  not: ['Noun', 'Adjective', 'Adverb', 'Value', 'Expression'],
4
4
  },
5
5
  PresentTense: {
6
+ aliases: [null, 'Präsens'],
6
7
  is: 'Verb',
7
8
  not: ['PastTense'],
8
9
  },
9
10
  Infinitive: {
11
+ aliases: [null, 'Infinitiv'],
10
12
  is: 'PresentTense',
11
13
  not: ['Gerund'],
12
14
  },
13
15
  Imperative: {
16
+ aliases: [null, 'Imperativ'],
14
17
  is: 'Infinitive',
15
18
  },
16
19
  Subjunctive: {
20
+ aliases: [null, 'Konjunktiv'],
17
21
  is: 'Verb',
18
22
  },
19
23
  Participle: {
24
+ aliases: [null, 'Partizip'],
20
25
  is: 'Verb',
21
26
  },
22
27
  Gerund: {
23
28
  is: 'PresentTense',
24
29
  not: ['Copula'],
25
30
  },
31
+ // any past form - 'ging', and also 'gegangen'
26
32
  PastTense: {
33
+ aliases: [null, 'Vergangenheit'],
27
34
  is: 'Verb',
28
35
  not: ['PresentTense', 'Gerund'],
29
36
  },
30
37
  Copula: {
38
+ aliases: [null, 'Kopula'],
31
39
  is: 'Verb',
32
40
  },
33
41
  Modal: {
42
+ aliases: [null, 'Modalverb'],
34
43
  is: 'Verb',
35
44
  not: ['Infinitive'],
36
45
  },
37
46
  PerfectTense: {
47
+ aliases: [null, 'Perfekt'],
38
48
  is: 'Verb',
39
49
  not: ['Gerund'],
40
50
  },
41
51
  Pluperfect: {
52
+ aliases: [null, 'Plusquamperfekt'],
42
53
  is: 'Verb',
43
54
  },
44
55
  PhrasalVerb: {
56
+ aliases: [null, 'Partikelverb'],
45
57
  is: 'Verb',
46
58
  },
59
+ // a separable prefix - the 'an' in 'ich rufe dich an'
47
60
  Particle: {
61
+ aliases: [null, 'Verbpartikel'],
48
62
  is: 'PhrasalVerb',
49
63
  not: ['PastTense', 'PresentTense', 'Copula', 'Gerund'],
50
64
  },
51
65
  Auxiliary: {
66
+ aliases: [null, 'Hilfsverb'],
52
67
  is: 'Verb',
53
68
  not: ['PastTense', 'PresentTense', 'Gerund', 'Conjunction'],
54
69
  },
55
70
  FirstPerson: {
71
+ aliases: [null, 'ErstePerson'],
56
72
  is: 'Verb'
57
73
  },
58
74
  SecondPerson: {
75
+ aliases: [null, 'ZweitePerson'],
59
76
  is: 'Verb'
60
77
  },
61
78
  ThirdPerson: {
79
+ aliases: [null, 'DrittePerson'],
62
80
  is: 'Verb'
63
81
  },
64
82
  }
@@ -21,9 +21,9 @@ const isSentence = function (str, abbrevs) {
21
21
  if (hasEllipse.test(str) === true) {
22
22
  return false
23
23
  }
24
- let txt = str.replace(/[.!?\u203D\u2E18\u203C\u2047-\u2049] *$/, '')
25
- let words = txt.split(' ')
26
- let lastWord = words[words.length - 1].toLowerCase()
24
+ const txt = str.replace(/[.!?\u203D\u2E18\u203C\u2047-\u2049] *$/, '')
25
+ const words = txt.split(' ')
26
+ const lastWord = words[words.length - 1].toLowerCase()
27
27
  // check for 'Mr.'
28
28
  if (abbrevs.hasOwnProperty(lastWord) === true) {
29
29
  return false
@@ -10,7 +10,7 @@
10
10
  // ü | Ü
11
11
  // ß
12
12
 
13
- let compact = {
13
+ const compact = {
14
14
  '!': '¡',
15
15
  '?': '¿Ɂ',
16
16
  '"': '“”"❝❞',
@@ -46,7 +46,7 @@ let compact = {
46
46
  ß: 'β' //greek beta to german Eszett surrogate
47
47
  }
48
48
  //decompress data into two hashes
49
- let unicode = {}
49
+ const unicode = {}
50
50
  Object.keys(compact).forEach(function (k) {
51
51
  compact[k].split('').forEach(function (s) {
52
52
  unicode[s] = k
@@ -13,10 +13,10 @@ const doRegs = function (str, regs) {
13
13
  }
14
14
 
15
15
  const checkRegex = function (terms, i, world) {
16
- let setTag = world.methods.one.setTag
17
- let term = terms[i]
18
- let { regexText, regexNormal, regexNumbers } = world.model.two
19
- let normal = term.machine || term.normal
16
+ const setTag = world.methods.one.setTag
17
+ const term = terms[i]
18
+ const { regexText, regexNormal, regexNumbers } = world.model.two
19
+ const normal = term.machine || term.normal
20
20
  let text = term.text
21
21
  // keep dangling apostrophe?
22
22
  if (hasApostrophe.test(term.post) && !hasApostrophe.test(term.pre)) {
@@ -4,8 +4,8 @@ const isTitleCase = function (str) {
4
4
 
5
5
  // add a noun to any non-0 index titlecased word, with no existing tag
6
6
  const titleCaseNoun = function (terms, i, world) {
7
- let setTag = world.methods.one.setTag
8
- let term = terms[i]
7
+ const setTag = world.methods.one.setTag
8
+ const term = terms[i]
9
9
  // don't over-write any tags
10
10
  // if (term.tags.size > 0) {
11
11
  // return
@@ -28,10 +28,10 @@ const seemsOkay = function (term) {
28
28
 
29
29
  // recognize '1993' as a year
30
30
  const tagYear = function (terms, i, world) {
31
- let setTag = world.methods.one.setTag
31
+ const setTag = world.methods.one.setTag
32
32
  const term = terms[i]
33
33
  if (term.tags.has('NumericValue') && term.tags.has('Cardinal') && term.normal.length === 4) {
34
- let num = Number(term.normal)
34
+ const num = Number(term.normal)
35
35
  // number between 1400 and 2100
36
36
  if (num && !isNaN(num)) {
37
37
  if (num > min && num < max) {
@@ -12,7 +12,7 @@ const oneLetterWord = {
12
12
  }
13
13
  // just uppercase acronyms, no periods - 'UNOCHA'
14
14
  const isNoPeriodAcronym = function (term, model) {
15
- let str = term.text
15
+ const str = term.text
16
16
  // ensure it's all upper-case
17
17
  if (isUpperCase.test(str) === false) {
18
18
  return false
@@ -49,8 +49,8 @@ const isNoPeriodAcronym = function (term, model) {
49
49
  }
50
50
 
51
51
  const isAcronym = function (terms, i, world) {
52
- let setTag = world.methods.one.setTag
53
- let term = terms[i]
52
+ const setTag = world.methods.one.setTag
53
+ const term = terms[i]
54
54
  //these are not acronyms
55
55
  if (term.tags.has('RomanNumeral') || term.tags.has('Acronym')) {
56
56
  return null
@@ -7,8 +7,8 @@ const hasNoVerb = function (terms) {
7
7
  }
8
8
 
9
9
  const fallback = function (terms, i, world) {
10
- let setTag = world.methods.one.setTag
11
- let term = terms[i]
10
+ const setTag = world.methods.one.setTag
11
+ const term = terms[i]
12
12
  if (term.tags.size === 0) {
13
13
 
14
14
  // is it first-word titlecase?
@@ -7,9 +7,9 @@ const prefixLoop = function (str = '', prefixes = []) {
7
7
  max = len - 3
8
8
  }
9
9
  for (let i = max; i > 2; i -= 1) {
10
- let prefix = str.substring(0, i)
10
+ const prefix = str.substring(0, i)
11
11
  if (prefixes[prefix.length].hasOwnProperty(prefix) === true) {
12
- let tag = prefixes[prefix.length][prefix]
12
+ const tag = prefixes[prefix.length][prefix]
13
13
  return tag
14
14
  }
15
15
  }
@@ -18,10 +18,10 @@ const prefixLoop = function (str = '', prefixes = []) {
18
18
 
19
19
  // give 'overwork' the same tag as 'work'
20
20
  const checkPrefix = function (terms, i, world) {
21
- let setTag = world.methods.one.setTag
22
- let term = terms[i]
21
+ const setTag = world.methods.one.setTag
22
+ const term = terms[i]
23
23
  if (term.tags.size === 0) {
24
- let tag = prefixLoop(term.normal, world.model.two.prefixPatterns)
24
+ const tag = prefixLoop(term.normal, world.model.two.prefixPatterns)
25
25
  if (tag !== null) {
26
26
  setTag([term], tag, world, false, '2-prefix')
27
27
  term.confidence = 0.5
@@ -7,10 +7,10 @@ const suffixLoop = function (str = '', suffixes = []) {
7
7
  max = len - 1
8
8
  }
9
9
  for (let i = max; i > 1; i -= 1) {
10
- let suffix = str.substr(len - i, len)
10
+ const suffix = str.substr(len - i, len)
11
11
  if (suffixes[suffix.length].hasOwnProperty(suffix) === true) {
12
12
  // console.log(suffix)
13
- let tag = suffixes[suffix.length][suffix]
13
+ const tag = suffixes[suffix.length][suffix]
14
14
  return tag
15
15
  }
16
16
  }
@@ -19,9 +19,9 @@ const suffixLoop = function (str = '', suffixes = []) {
19
19
 
20
20
  // decide tag from the ending of the word
21
21
  const suffixCheck = function (terms, i, world) {
22
- let setTag = world.methods.one.setTag
23
- let suffixes = world.model.two.suffixPatterns
24
- let term = terms[i]
22
+ const setTag = world.methods.one.setTag
23
+ const suffixes = world.model.two.suffixPatterns
24
+ const term = terms[i]
25
25
  if (term.tags.size === 0) {
26
26
  let tag = suffixLoop(term.normal, suffixes)
27
27
  if (tag !== null) {
@@ -32,7 +32,7 @@ const secondPass = function (terms, world) {
32
32
 
33
33
 
34
34
  const tagger = function (view) {
35
- let world = view.world
35
+ const world = view.world
36
36
  view.docs.forEach(terms => {
37
37
  firstPass(terms, world)
38
38
  secondPass(terms, world)
@@ -16,9 +16,9 @@ const api = function (View) {
16
16
  const methods = this.methods.two.transform.adjective
17
17
  const { inflect, toRoot } = methods
18
18
  return getNth(this, n).map(m => {
19
- let str = getRoot(m, methods)
20
- let root = toRoot(str) || str
21
- let res = inflect(root)
19
+ const str = getRoot(m, methods)
20
+ const root = toRoot(str) || str
21
+ const res = inflect(root)
22
22
  res.infinitive = root
23
23
  return res
24
24
  }, [])
@@ -17,7 +17,7 @@ const matchCase = function (m, str) {
17
17
  // 'hunde' → 'hund' → 'hunde' round-trips, so it is already a plural,
18
18
  // even when the tagger could not tell - 'die Hunde' vs 'der Kunde'
19
19
  const isPluralForm = function (methods, str) {
20
- let single = methods.toSingular(str)
20
+ const single = methods.toSingular(str)
21
21
  return single !== str && methods.toPlural(single).one === str
22
22
  }
23
23
 
@@ -30,7 +30,7 @@ const api = function (View) {
30
30
  conjugate(n) {
31
31
  const methods = this.methods.two.transform.noun
32
32
  return getNth(this, n).map(m => {
33
- let root = getRoot(m)
33
+ const root = getRoot(m)
34
34
  return {
35
35
  singular: root,
36
36
  plural: methods.toPlural(root).one,
@@ -47,19 +47,19 @@ const api = function (View) {
47
47
  if (isPluralForm(methods, m.text('normal'))) {
48
48
  return m
49
49
  }
50
- let str = getRoot(m)
51
- let plural = methods.toPlural(str).one
50
+ const str = getRoot(m)
51
+ const plural = methods.toPlural(str).one
52
52
  return m.replaceWith(matchCase(m, plural))
53
53
  })
54
54
  }
55
55
  toSingular(n) {
56
56
  const methods = this.methods.two.transform.noun
57
57
  return getNth(this, n).not('#Singular').map(m => {
58
- let str = m.text('normal')
58
+ const str = m.text('normal')
59
59
  if (!m.has('#Plural') && !isPluralForm(methods, str)) {
60
60
  return m
61
61
  }
62
- let singular = methods.toSingular(str)
62
+ const singular = methods.toSingular(str)
63
63
  return m.replaceWith(matchCase(m, singular))
64
64
  })
65
65
  }
@@ -18,10 +18,10 @@ const api = function (View) {
18
18
  return getNth(this, n).map(parse).map(o => o.num)
19
19
  }
20
20
  json(n) {
21
- let doc = getNth(this, n)
21
+ const doc = getNth(this, n)
22
22
  return doc.map(p => {
23
- let json = p.toView().json(n)[0]
24
- let parsed = parse(p)
23
+ const json = p.toView().json(n)[0]
24
+ const parsed = parse(p)
25
25
  json.number = {
26
26
  prefix: parsed.prefix,
27
27
  num: parsed.num,
@@ -46,14 +46,14 @@ const api = function (View) {
46
46
 
47
47
  /** convert to numeric form like '8' or '8th' */
48
48
  toNumber() {
49
- let m = this.if('#TextValue')
50
- let res = m.map(val => {
51
- let obj = parse(val)
49
+ const m = this.if('#TextValue')
50
+ const res = m.map(val => {
51
+ const obj = parse(val)
52
52
  if (obj.num === null) {
53
53
  return val
54
54
  }
55
- let fmt = val.has('#Ordinal') ? 'Ordinal' : 'Cardinal'
56
- let str = format(obj, fmt)
55
+ const fmt = val.has('#Ordinal') ? 'Ordinal' : 'Cardinal'
56
+ const str = format(obj, fmt)
57
57
  if (str) {
58
58
  val.replaceWith(str, { tags: true })
59
59
  val.tag('NumericValue')
@@ -64,17 +64,17 @@ const api = function (View) {
64
64
  }
65
65
  /** convert to numeric form like 'eight' or 'eighth' */
66
66
  toText() {
67
- let m = this
68
- let res = m.map(val => {
67
+ const m = this
68
+ const res = m.map(val => {
69
69
  if (val.has('#TextValue')) {
70
70
  return val
71
71
  }
72
- let obj = parse(val)
72
+ const obj = parse(val)
73
73
  if (obj.num === null) {
74
74
  return val
75
75
  }
76
- let fmt = val.has('#Ordinal') ? 'TextOrdinal' : 'TextCardinal'
77
- let str = format(obj, fmt)
76
+ const fmt = val.has('#Ordinal') ? 'TextOrdinal' : 'TextCardinal'
77
+ const str = format(obj, fmt)
78
78
  if (str) {
79
79
  val.replaceWith(str, { tags: true })
80
80
  val.tag('TextValue')
@@ -85,17 +85,17 @@ const api = function (View) {
85
85
  }
86
86
  /** convert ordinal to cardinal form, like 'eight', or '8' */
87
87
  toCardinal() {
88
- let m = this
89
- let res = m.map(val => {
88
+ const m = this
89
+ const res = m.map(val => {
90
90
  if (!val.has('#Ordinal')) {
91
91
  return val
92
92
  }
93
- let obj = parse(val)
93
+ const obj = parse(val)
94
94
  if (obj.num === null) {
95
95
  return val
96
96
  }
97
- let fmt = val.has('#TextValue') ? 'TextCardinal' : 'Cardinal'
98
- let str = format(obj, fmt)
97
+ const fmt = val.has('#TextValue') ? 'TextCardinal' : 'Cardinal'
98
+ const str = format(obj, fmt)
99
99
  if (str) {
100
100
  val.replaceWith(str, { tags: true })
101
101
  val.tag('Cardinal')
@@ -106,17 +106,17 @@ const api = function (View) {
106
106
  }
107
107
  /** convert cardinal to ordinal form, like 'eighth', or '8th' */
108
108
  toOrdinal() {
109
- let m = this
110
- let res = m.map(val => {
109
+ const m = this
110
+ const res = m.map(val => {
111
111
  if (val.has('#Ordinal')) {
112
112
  return val
113
113
  }
114
- let obj = parse(val)
114
+ const obj = parse(val)
115
115
  if (obj.num === null) {
116
116
  return val
117
117
  }
118
- let fmt = val.has('#TextValue') ? 'TextOrdinal' : 'Ordinal'
119
- let str = format(obj, fmt)
118
+ const fmt = val.has('#TextValue') ? 'TextOrdinal' : 'Ordinal'
119
+ const str = format(obj, fmt)
120
120
  if (str) {
121
121
  val.replaceWith(str, { tags: true })
122
122
  val.tag('Ordinal')
@@ -129,28 +129,28 @@ const api = function (View) {
129
129
  /** return only numbers that are == n */
130
130
  isEqual(n) {
131
131
  return this.filter((val) => {
132
- let num = parse(val).num
132
+ const num = parse(val).num
133
133
  return num === n
134
134
  })
135
135
  }
136
136
  /** return only numbers that are > n*/
137
137
  greaterThan(n) {
138
138
  return this.filter((val) => {
139
- let num = parse(val).num
139
+ const num = parse(val).num
140
140
  return num > n
141
141
  })
142
142
  }
143
143
  /** return only numbers that are < n*/
144
144
  lessThan(n) {
145
145
  return this.filter((val) => {
146
- let num = parse(val).num
146
+ const num = parse(val).num
147
147
  return num < n
148
148
  })
149
149
  }
150
150
  /** return only numbers > min and < max */
151
151
  between(min, max) {
152
152
  return this.filter((val) => {
153
- let num = parse(val).num
153
+ const num = parse(val).num
154
154
  return num > min && num < max
155
155
  })
156
156
  }
@@ -162,9 +162,9 @@ const api = function (View) {
162
162
  if (typeof n === 'string') {
163
163
  n = parse(n).num
164
164
  }
165
- let m = this
166
- let res = m.map((val) => {
167
- let obj = parse(val)
165
+ const m = this
166
+ const res = m.map((val) => {
167
+ const obj = parse(val)
168
168
  obj.num = n
169
169
  if (obj.num === null) {
170
170
  return val
@@ -195,9 +195,9 @@ const api = function (View) {
195
195
  if (typeof n === 'string') {
196
196
  n = parse(n).num
197
197
  }
198
- let m = this
199
- let res = m.map((val) => {
200
- let obj = parse(val)
198
+ const m = this
199
+ const res = m.map((val) => {
200
+ const obj = parse(val)
201
201
  if (obj.num === null) {
202
202
  return val
203
203
  }
@@ -206,7 +206,7 @@ const api = function (View) {
206
206
  if (obj.isText) {
207
207
  fmt = val.has('#Ordinal') ? 'TextOrdinal' : 'TextCardinal'
208
208
  }
209
- let str = format(obj, fmt)
209
+ const str = format(obj, fmt)
210
210
  if (str) {
211
211
  val.replaceWith(str, { tags: true })
212
212
  // handle plural/singular unit
@@ -230,7 +230,7 @@ const api = function (View) {
230
230
  }
231
231
  // overloaded - keep Numbers class
232
232
  update(pointer) {
233
- let m = new Numbers(this.document, pointer)
233
+ const m = new Numbers(this.document, pointer)
234
234
  m._cache = this._cache // share this full thing
235
235
  return m
236
236
  }