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.
- package/LICENSE +1 -1
- package/README.md +15 -11
- package/builds/de-compromise.cjs +2284 -1216
- package/builds/de-compromise.min.js +3 -1
- package/builds/de-compromise.mjs +3 -1
- package/package.json +42 -39
- package/src/01-one/lexicon/_data.js +22 -22
- package/src/01-one/lexicon/compute/root.js +3 -3
- package/src/01-one/lexicon/lexicon.js +6 -6
- package/src/01-one/lexicon/methods/_data.js +29 -174
- package/src/01-one/lexicon/methods/adjectives/_test-back.js +1 -1
- package/src/01-one/lexicon/methods/adjectives/_test.js +4 -4
- package/src/01-one/lexicon/methods/adjectives/inflect.js +1 -1
- package/src/01-one/lexicon/methods/adjectives/new/adjective.js +1 -1
- package/src/01-one/lexicon/methods/adjectives/new/comparative.js +1 -1
- package/src/01-one/lexicon/methods/adjectives/new/superlative.js +1 -1
- package/src/01-one/lexicon/methods/adjectives/toRoot.js +1 -1
- package/src/01-one/lexicon/methods/nouns/_test-back.js +6 -6
- package/src/01-one/lexicon/methods/nouns/new.js +1 -1
- package/src/01-one/lexicon/methods/nouns/toPlural.js +2 -2
- package/src/01-one/lexicon/methods/nouns/toSingular.js +2 -2
- package/src/01-one/lexicon/methods/verbs/conjugate.js +4 -4
- package/src/01-one/lexicon/methods/verbs/custom/_test-from.js +6 -6
- package/src/01-one/lexicon/methods/verbs/custom/_test-to.js +7 -7
- package/src/01-one/lexicon/methods/verbs/custom/fromPastParticiple.js +1 -1
- package/src/01-one/lexicon/methods/verbs/custom/rules.js +2 -2
- package/src/01-one/lexicon/methods/verbs/custom/toPastParticiple.js +2 -2
- package/src/01-one/lexicon/methods/verbs/irregulars.js +6 -6
- package/src/01-one/lexicon/methods/verbs/toRoot.js +8 -8
- package/src/01-one/splitter/build.js +3 -3
- package/src/01-one/splitter/compute/splitter.js +4 -4
- package/src/01-one/splitter/model/index.js +4 -4
- package/src/01-one/splitter/trie.js +3 -3
- package/src/01-one/tagset/plugin.js +1 -1
- package/src/01-one/tagset/tags/dates.js +10 -0
- package/src/01-one/tagset/tags/misc.js +21 -2
- package/src/01-one/tagset/tags/nouns.js +26 -1
- package/src/01-one/tagset/tags/values.js +10 -0
- package/src/01-one/tagset/tags/verbs.js +18 -0
- package/src/01-one/tokenizer/is-sentence.js +3 -3
- package/src/01-one/tokenizer/unicode.js +2 -2
- package/src/02-two/preTagger/compute/1st-pass/regex.js +4 -4
- package/src/02-two/preTagger/compute/1st-pass/titlecase.js +2 -2
- package/src/02-two/preTagger/compute/1st-pass/year.js +2 -2
- package/src/02-two/preTagger/compute/2nd-pass/acronym.js +3 -3
- package/src/02-two/preTagger/compute/2nd-pass/fallback.js +2 -2
- package/src/02-two/preTagger/compute/2nd-pass/prefix-lookup.js +5 -5
- package/src/02-two/preTagger/compute/2nd-pass/suffix-lookup.js +5 -5
- package/src/02-two/preTagger/compute/index.js +1 -1
- package/src/03-three/adjectives/api.js +3 -3
- package/src/03-three/nouns/api.js +6 -6
- package/src/03-three/numbers/api.js +35 -35
- package/src/03-three/numbers/data.js +2 -2
- package/src/03-three/numbers/format/index.js +2 -2
- package/src/03-three/numbers/format/toText.js +12 -12
- package/src/03-three/numbers/parse/fromText.js +3 -3
- package/src/03-three/numbers/parse/index.js +5 -5
- package/src/03-three/verbs/api.js +1 -1
- package/src/_version.js +1 -1
- package/src/index.js +2 -2
- package/types/index.d.cts +9 -0
- package/types/index.d.ts +2 -2
- package/types/view/de.ts +1 -1
- package/types/view/one.ts +1 -1
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import model from '/Users/spencer/mountain/de-compromise/data/models/adjectives/adjectives.js'
|
|
3
3
|
import convert from './inflect.js'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const all = []
|
|
6
|
+
const suff = ''
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const percent = (part, total) => {
|
|
@@ -24,7 +24,7 @@ const percent = (part, total) => {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const tests = [
|
|
28
28
|
{ prop: 'one', n: 0 },
|
|
29
29
|
{ prop: 'two', n: 1 },
|
|
30
30
|
{ prop: 'three', n: 2 },
|
|
@@ -33,7 +33,7 @@ let tests = [
|
|
|
33
33
|
tests.forEach(obj => {
|
|
34
34
|
let good = 0
|
|
35
35
|
Object.keys(model).forEach(inf => {
|
|
36
|
-
|
|
36
|
+
const have = convert(inf)[obj.prop]
|
|
37
37
|
if (have === model[inf][obj.n]) {
|
|
38
38
|
good += 1
|
|
39
39
|
} else {
|
|
@@ -36,7 +36,7 @@ const toRoot = function (str) {
|
|
|
36
36
|
return str.replace(weise, 'weise')
|
|
37
37
|
}
|
|
38
38
|
for (let i = 0; i < suffixes.length; i += 1) {
|
|
39
|
-
|
|
39
|
+
const suff = suffixes[i]
|
|
40
40
|
if (str.endsWith(suff)) {
|
|
41
41
|
return str.substring(0, str.length - suff.length)
|
|
42
42
|
}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import toRoot from './toRoot.js'
|
|
3
3
|
import model from '/Users/spencer/mountain/de-compromise/data/models/nouns.js'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const all = []
|
|
6
|
+
const suff = ''
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const topk = function (arr) {
|
|
10
|
-
|
|
10
|
+
const obj = {}
|
|
11
11
|
arr.forEach(a => {
|
|
12
12
|
obj[a] = obj[a] || 0
|
|
13
13
|
obj[a] += 1
|
|
14
14
|
})
|
|
15
|
-
|
|
15
|
+
const res = Object.keys(obj).map(k => [k, obj[k]])
|
|
16
16
|
return res.sort((a, b) => (a[1] > b[1] ? -1 : 0))
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -23,12 +23,12 @@ const percent = (part, total) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const ends = []
|
|
27
27
|
let correct = 0
|
|
28
28
|
let total = 0
|
|
29
29
|
Object.keys(model).forEach(inf => {
|
|
30
30
|
model[inf].s.forEach(str => {
|
|
31
|
-
|
|
31
|
+
const have = toRoot(str)
|
|
32
32
|
total += 1
|
|
33
33
|
if (have === inf) {
|
|
34
34
|
correct += 1
|
|
@@ -2,7 +2,7 @@ import { convert } from 'suffix-thumb'
|
|
|
2
2
|
import model from '../models.js'
|
|
3
3
|
|
|
4
4
|
// fallback rules, when no trained model is available
|
|
5
|
-
|
|
5
|
+
const rules = [
|
|
6
6
|
['ein', ''],
|
|
7
7
|
['cht', 'e'],
|
|
8
8
|
['ll', 'e'],
|
|
@@ -34,7 +34,7 @@ const firstForm = function (str) {
|
|
|
34
34
|
return convert(str, model.nouns.plural)
|
|
35
35
|
}
|
|
36
36
|
for (let i = 0; i < rules.length; i += 1) {
|
|
37
|
-
|
|
37
|
+
const [from, to] = rules[i]
|
|
38
38
|
if (str.endsWith(from)) {
|
|
39
39
|
return str + to
|
|
40
40
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { convert, reverse } from 'suffix-thumb'
|
|
2
2
|
import model from '../models.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const pluralRev = model.nouns && model.nouns.plural ? reverse(model.nouns.plural) : null
|
|
5
5
|
|
|
6
6
|
// fallback rules, when no trained model is available
|
|
7
7
|
const leave = [
|
|
@@ -36,7 +36,7 @@ const toSingular = function (str) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
for (let i = 0; i < suffixes.length; i += 1) {
|
|
39
|
-
|
|
39
|
+
const suff = suffixes[i]
|
|
40
40
|
if (str.endsWith(suff)) {
|
|
41
41
|
return str.substring(0, str.length - suff.length)
|
|
42
42
|
}
|
|
@@ -2,10 +2,10 @@ import { convert } from 'suffix-thumb'
|
|
|
2
2
|
import model from '../models.js'
|
|
3
3
|
import getIrregular from './irregulars.js'
|
|
4
4
|
import ppRules from './custom/toPastParticiple.js'
|
|
5
|
-
|
|
5
|
+
const { presentTense, pastTense, subjunctive1, subjunctive2, imperative, presentParticiple, pastParticiple } = model
|
|
6
6
|
|
|
7
7
|
const doEach = function (str, m, tense) {
|
|
8
|
-
|
|
8
|
+
const irr = getIrregular(str, tense)
|
|
9
9
|
if (irr) {
|
|
10
10
|
return {
|
|
11
11
|
first: irr[0],
|
|
@@ -35,7 +35,7 @@ const toPresentParticiple = (str) => {
|
|
|
35
35
|
return getIrregular(str, 'presentParticiple') || convert(str, presentParticiple.presentParticiple)
|
|
36
36
|
}
|
|
37
37
|
const toPastParticiple = (str) => {
|
|
38
|
-
|
|
38
|
+
const irr = getIrregular(str, 'pastParticiple')
|
|
39
39
|
if (irr) {
|
|
40
40
|
return irr
|
|
41
41
|
}
|
|
@@ -45,7 +45,7 @@ const toPastParticiple = (str) => {
|
|
|
45
45
|
return ppRules(str)
|
|
46
46
|
}
|
|
47
47
|
const toImperative = (str) => {
|
|
48
|
-
|
|
48
|
+
const irr = getIrregular(str, 'imperative')
|
|
49
49
|
if (irr) {
|
|
50
50
|
return { secondSingular: irr[0], secondPlural: irr[1] }
|
|
51
51
|
}
|
|
@@ -6,12 +6,12 @@ import fromPastParticiple from './fromPastParticiple.js'
|
|
|
6
6
|
const inspect = ''
|
|
7
7
|
|
|
8
8
|
const topk = function (arr) {
|
|
9
|
-
|
|
9
|
+
const obj = {}
|
|
10
10
|
arr.forEach(a => {
|
|
11
11
|
obj[a] = obj[a] || 0
|
|
12
12
|
obj[a] += 1
|
|
13
13
|
})
|
|
14
|
-
|
|
14
|
+
const res = Object.keys(obj).map(k => [k, obj[k]])
|
|
15
15
|
return res.sort((a, b) => (a[1] > b[1] ? -1 : 0))
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -23,10 +23,10 @@ const percent = (part, total) => {
|
|
|
23
23
|
|
|
24
24
|
// collect errors to look at
|
|
25
25
|
let right = 0
|
|
26
|
-
|
|
26
|
+
const bads = []
|
|
27
27
|
pairs.forEach(a => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const [inf, prt] = a
|
|
29
|
+
const have = fromPastParticiple(prt)
|
|
30
30
|
if (have === inf) {
|
|
31
31
|
right += 1
|
|
32
32
|
} else {
|
|
@@ -37,7 +37,7 @@ pairs.forEach(a => {
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
// let suffs = bads.map(a => a[1].substring(a[1].length - inspect.length, a[1].length))
|
|
40
|
-
|
|
40
|
+
const suffs = bads.map(a => a[1].substring(a[1].length - inspect.length - 4, a[1].length))
|
|
41
41
|
// bads = bads.filter(a => a[2].startsWith('ge') && !a[1].startsWith('ge'))
|
|
42
42
|
// let suffs = bads.map(a => a[0].substring(0, 3))
|
|
43
43
|
console.log(topk(suffs))
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/* eslint-disable no-console, no-unused-vars */
|
|
2
2
|
import pairs from '/Users/spencer/mountain/de-compromise/data/models/verbs/past-participle.js'
|
|
3
3
|
import toPastParticiple from './toPastParticiple.js'
|
|
4
|
-
import fs from 'fs'
|
|
4
|
+
import fs from 'node:fs'
|
|
5
5
|
|
|
6
6
|
const inspect = ''
|
|
7
7
|
|
|
8
8
|
const topk = function (arr) {
|
|
9
|
-
|
|
9
|
+
const obj = {}
|
|
10
10
|
arr.forEach(a => {
|
|
11
11
|
obj[a] = obj[a] || 0
|
|
12
12
|
obj[a] += 1
|
|
13
13
|
})
|
|
14
|
-
|
|
14
|
+
const res = Object.keys(obj).map(k => [k, obj[k]])
|
|
15
15
|
return res.sort((a, b) => (a[1] > b[1] ? -1 : 0))
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -25,8 +25,8 @@ const percent = (part, total) => {
|
|
|
25
25
|
let right = 0
|
|
26
26
|
let bads = []
|
|
27
27
|
pairs.forEach(a => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const [inf, prt] = a
|
|
29
|
+
const have = toPastParticiple(inf)
|
|
30
30
|
if (have === prt) {
|
|
31
31
|
right += 1
|
|
32
32
|
} else {
|
|
@@ -37,8 +37,8 @@ pairs.forEach(a => {
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
// let suffs = bads.map(a => a[1].substring(a[1].length - inspect.length, a[1].length))
|
|
40
|
-
|
|
41
|
-
bads = bads.filter(a => a[2].match(/ssen$/) &&
|
|
40
|
+
const suffs = bads.map(a => a[2].substring(a[2].length - inspect.length - 4, a[2].length))
|
|
41
|
+
bads = bads.filter(a => a[2].match(/ssen$/) && !/ssen$/.test(a[1]))
|
|
42
42
|
// let suffs = bads.map(a => a[0].substring(0, 4))
|
|
43
43
|
// console.log(bads)
|
|
44
44
|
// console.log(topk(suffs))
|
|
@@ -2,7 +2,7 @@ import { prefixes, suffixes } from './rules.js'
|
|
|
2
2
|
|
|
3
3
|
const doSuffix = function (str) {
|
|
4
4
|
for (let i = 0; i < suffixes.length; i += 1) {
|
|
5
|
-
|
|
5
|
+
const [inf, prt] = suffixes[i]
|
|
6
6
|
if (str.endsWith(prt)) {
|
|
7
7
|
return str.substring(0, str.length - prt.length) + inf
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const prefixes = [
|
|
2
2
|
'dazwischen',
|
|
3
3
|
'zusammen',
|
|
4
4
|
'entgegen',
|
|
@@ -103,7 +103,7 @@ let prefixes = [
|
|
|
103
103
|
'an'
|
|
104
104
|
]
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
const suffixes = [
|
|
107
107
|
'bringen|bracht',
|
|
108
108
|
'leichen|lichen',
|
|
109
109
|
'riechen|rochen',
|
|
@@ -21,7 +21,7 @@ const doPrefix = function (str) {
|
|
|
21
21
|
return str
|
|
22
22
|
}
|
|
23
23
|
// otherwse, add 'ge-'
|
|
24
|
-
if (
|
|
24
|
+
if (!/^(über|unt|v|au|miß)/.test(str)) {
|
|
25
25
|
str = 'ge' + str
|
|
26
26
|
}
|
|
27
27
|
return str
|
|
@@ -29,7 +29,7 @@ const doPrefix = function (str) {
|
|
|
29
29
|
|
|
30
30
|
const doSuffix = function (str) {
|
|
31
31
|
for (let i = 0; i < suffixes.length; i += 1) {
|
|
32
|
-
|
|
32
|
+
const [from, to] = suffixes[i]
|
|
33
33
|
if (str.endsWith(from)) {
|
|
34
34
|
return str.substring(0, str.length - from.length) + to
|
|
35
35
|
}
|
|
@@ -152,12 +152,12 @@ const find = function (str) {
|
|
|
152
152
|
if (irregulars.hasOwnProperty(str)) {
|
|
153
153
|
return { base: irregulars[str], prefix: '', separable: false }
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
const m = str.match(inseparable)
|
|
156
156
|
if (m && irregulars.hasOwnProperty(str.substring(m[0].length))) {
|
|
157
157
|
return { base: irregulars[str.substring(m[0].length)], prefix: m[0], separable: false }
|
|
158
158
|
}
|
|
159
159
|
for (let i = 0; i < prefixes.length; i += 1) {
|
|
160
|
-
|
|
160
|
+
const p = prefixes[i]
|
|
161
161
|
if (str.startsWith(p) && irregulars.hasOwnProperty(str.substring(p.length))) {
|
|
162
162
|
return { base: irregulars[str.substring(p.length)], prefix: p, separable: true }
|
|
163
163
|
}
|
|
@@ -168,12 +168,12 @@ const find = function (str) {
|
|
|
168
168
|
// returns conjugated forms for one tense, or null.
|
|
169
169
|
// tense: present | past | subj1 | subj2 | imperative | pastParticiple | presentParticiple
|
|
170
170
|
const getIrregular = function (str, tense) {
|
|
171
|
-
|
|
171
|
+
const found = find(str)
|
|
172
172
|
if (!found || !found.base[tense]) {
|
|
173
173
|
return null
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
const { base, prefix, separable } = found
|
|
176
|
+
const forms = base[tense]
|
|
177
177
|
if (typeof forms === 'string') {
|
|
178
178
|
// participles - 'auf' + 'gestanden', but 'ver' + 'standen'
|
|
179
179
|
if (tense === 'pastParticiple' && separable === false && prefix) {
|
|
@@ -185,7 +185,7 @@ const getIrregular = function (str, tense) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// form → infinitive, for root-recovery
|
|
188
|
-
|
|
188
|
+
const toInfinitive = {}
|
|
189
189
|
Object.keys(irregulars).forEach(inf => {
|
|
190
190
|
Object.keys(irregulars[inf]).forEach(tense => {
|
|
191
191
|
let forms = irregulars[inf][tense]
|
|
@@ -2,7 +2,7 @@ import { convert, reverse } from 'suffix-thumb'
|
|
|
2
2
|
import model from '../models.js'
|
|
3
3
|
import { toInfinitive } from './irregulars.js'
|
|
4
4
|
import ppRules from './custom/fromPastParticiple.js'
|
|
5
|
-
|
|
5
|
+
const { presentTense, pastTense, subjunctive1, subjunctive2, imperative, presentParticiple, pastParticiple } = model
|
|
6
6
|
|
|
7
7
|
// =-=-
|
|
8
8
|
const revAll = function (m) {
|
|
@@ -12,13 +12,13 @@ const revAll = function (m) {
|
|
|
12
12
|
}, {})
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const presentRev = revAll(presentTense)
|
|
16
|
+
const pastRev = revAll(pastTense)
|
|
17
|
+
const subjRev1 = revAll(subjunctive1)
|
|
18
|
+
const subjRev2 = revAll(subjunctive2)
|
|
19
|
+
const impRev = revAll(imperative)
|
|
20
|
+
const presentPartRev = reverse(presentParticiple.presentParticiple)
|
|
21
|
+
const pastPartRev = pastParticiple ? reverse(pastParticiple.pastParticiple) : null
|
|
22
22
|
|
|
23
23
|
const allForms = function (str, form, m) {
|
|
24
24
|
if (toInfinitive.hasOwnProperty(str)) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { addWord } from './trie.js'
|
|
2
2
|
|
|
3
3
|
const buildIndex = function (world) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const words = Object.entries(world.model.one.lexicon)
|
|
5
|
+
const { nouns, values } = world.model.one.splitter
|
|
6
6
|
words.forEach((a) => {
|
|
7
|
-
|
|
7
|
+
const [w, tag] = a
|
|
8
8
|
if (tag === 'TextOrdinal' || tag === 'TextCardinal') {
|
|
9
9
|
addWord(w, values)
|
|
10
10
|
}
|
|
@@ -5,17 +5,17 @@ const hasLink = /^(e[rns]|s|n)/
|
|
|
5
5
|
import { findMatch } from '../trie.js'
|
|
6
6
|
|
|
7
7
|
const findSplits = function (str, root) {
|
|
8
|
-
|
|
8
|
+
const found = []
|
|
9
9
|
while (str.length > 0) {
|
|
10
10
|
let match = findMatch(str, root)
|
|
11
11
|
if (!match) {
|
|
12
12
|
//we done
|
|
13
13
|
// allow a connector - [foo, en, bar]
|
|
14
14
|
if (found.length > 0 && hasLink.test(str)) {
|
|
15
|
-
|
|
15
|
+
const tmp = str.replace(hasLink, '')
|
|
16
16
|
match = findMatch(tmp, root)
|
|
17
17
|
if (match) {
|
|
18
|
-
|
|
18
|
+
const link = str.match(hasLink)[0]
|
|
19
19
|
found.push(link)
|
|
20
20
|
str = str.substr(link.length)
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ const findSplits = function (str, root) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const splitter = function (view) {
|
|
36
|
-
|
|
36
|
+
const { values } = view.model.one.splitter
|
|
37
37
|
view.docs.forEach((terms) => {
|
|
38
38
|
terms.forEach((term) => {
|
|
39
39
|
// split numbers
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// import verbs from './splitter/verbs.js'
|
|
4
4
|
// import adjectives from './splitter/adjectives.js'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const values = { more: [] }
|
|
7
|
+
const nouns = { more: [] }
|
|
8
|
+
const verbs = { more: [] }
|
|
9
|
+
const adjectives = { more: [] }
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
one: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const addWord = function (str, root) {
|
|
2
|
-
|
|
2
|
+
const chars = str.split('')
|
|
3
3
|
let node = root
|
|
4
4
|
chars.forEach(c => {
|
|
5
5
|
node.more[c] = node.more[c] || { more: {} }
|
|
@@ -9,7 +9,7 @@ const addWord = function (str, root) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const makeTrie = function (arr) {
|
|
12
|
-
|
|
12
|
+
const root = {
|
|
13
13
|
more: {}
|
|
14
14
|
}
|
|
15
15
|
arr.forEach(str => addWord(str, root))
|
|
@@ -18,7 +18,7 @@ const makeTrie = function (arr) {
|
|
|
18
18
|
|
|
19
19
|
const findMatch = function (str, root) {
|
|
20
20
|
let match = null
|
|
21
|
-
|
|
21
|
+
const chars = str.split('')
|
|
22
22
|
let node = root
|
|
23
23
|
for (let i = 0; i < chars.length; i += 1) {
|
|
24
24
|
if (!node.more[chars[i]]) {
|
|
@@ -4,7 +4,7 @@ import values from './tags/values.js'
|
|
|
4
4
|
import dates from './tags/dates.js'
|
|
5
5
|
import misc from './tags/misc.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const tags = Object.assign({}, nouns, verbs, values, dates, misc)
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
tags
|
|
@@ -1,44 +1,54 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
Date: {
|
|
3
|
+
aliases: [null, 'Datum'],
|
|
3
4
|
not: ['Verb', 'Adverb', 'Adjective'],
|
|
4
5
|
},
|
|
5
6
|
Month: {
|
|
7
|
+
aliases: [null, 'Monat'],
|
|
6
8
|
is: 'Singular',
|
|
7
9
|
also: ['Date'],
|
|
8
10
|
not: ['Year', 'WeekDay', 'Time'],
|
|
9
11
|
},
|
|
10
12
|
WeekDay: {
|
|
13
|
+
aliases: [null, 'Wochentag'],
|
|
11
14
|
is: 'Noun',
|
|
12
15
|
also: ['Date'],
|
|
13
16
|
},
|
|
14
17
|
Year: {
|
|
18
|
+
aliases: [null, 'Jahr'],
|
|
15
19
|
is: 'Date',
|
|
16
20
|
not: ['RomanNumeral'],
|
|
17
21
|
},
|
|
18
22
|
FinancialQuarter: {
|
|
23
|
+
aliases: [null, 'Quartal'],
|
|
19
24
|
is: 'Date',
|
|
20
25
|
not: 'Fraction',
|
|
21
26
|
},
|
|
22
27
|
// 'easter'
|
|
23
28
|
Holiday: {
|
|
29
|
+
aliases: [null, 'Feiertag'],
|
|
24
30
|
is: 'Date',
|
|
25
31
|
also: ['Noun'],
|
|
26
32
|
},
|
|
27
33
|
// 'summer'
|
|
28
34
|
Season: {
|
|
35
|
+
aliases: [null, 'Jahreszeit'],
|
|
29
36
|
is: 'Date',
|
|
30
37
|
},
|
|
31
38
|
Timezone: {
|
|
39
|
+
aliases: [null, 'Zeitzone'],
|
|
32
40
|
is: 'Noun',
|
|
33
41
|
also: ['Date'],
|
|
34
42
|
not: ['ProperNoun'],
|
|
35
43
|
},
|
|
36
44
|
Time: {
|
|
45
|
+
aliases: [null, 'Uhrzeit'],
|
|
37
46
|
is: 'Date',
|
|
38
47
|
not: ['AtMention'],
|
|
39
48
|
},
|
|
40
49
|
// 'months'
|
|
41
50
|
Duration: {
|
|
51
|
+
aliases: [null, 'Dauer'],
|
|
42
52
|
is: 'Noun',
|
|
43
53
|
also: ['Date'],
|
|
44
54
|
},
|
|
@@ -2,50 +2,66 @@ const anything = ['Noun', 'Verb', 'Adjective', 'Adverb', 'Value', 'QuestionWord'
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
Adjective: {
|
|
5
|
+
aliases: [null, 'Adjektiv'],
|
|
5
6
|
not: ['Noun', 'Verb', 'Adverb', 'Value'],
|
|
6
7
|
},
|
|
7
8
|
Comparable: {
|
|
9
|
+
aliases: [null, 'Steigerbar'],
|
|
8
10
|
is: 'Adjective',
|
|
9
11
|
},
|
|
10
12
|
Comparative: {
|
|
13
|
+
aliases: [null, 'Komparativ'],
|
|
11
14
|
is: 'Adjective',
|
|
12
15
|
},
|
|
13
16
|
Superlative: {
|
|
17
|
+
aliases: [null, 'Superlativ'],
|
|
14
18
|
is: 'Adjective',
|
|
15
19
|
not: ['Comparative'],
|
|
16
20
|
},
|
|
17
|
-
NumberRange: {
|
|
21
|
+
NumberRange: {
|
|
22
|
+
aliases: [null, 'Zahlenbereich'],
|
|
23
|
+
},
|
|
18
24
|
Adverb: {
|
|
19
25
|
not: ['Noun', 'Verb', 'Adjective', 'Value'],
|
|
20
26
|
},
|
|
21
27
|
|
|
22
28
|
Determiner: {
|
|
29
|
+
aliases: [null, 'Artikel', 'Determinativ'],
|
|
23
30
|
not: ['Noun', 'Verb', 'Adjective', 'Adverb', 'QuestionWord', 'Conjunction'], //allow 'a' to be a Determiner/Value
|
|
24
31
|
},
|
|
25
32
|
Conjunction: {
|
|
33
|
+
aliases: [null, 'Konjunktion'],
|
|
26
34
|
not: anything,
|
|
27
35
|
},
|
|
28
36
|
Preposition: {
|
|
37
|
+
aliases: [null, 'Präposition'],
|
|
29
38
|
not: ['Noun', 'Verb', 'Adjective', 'Adverb', 'QuestionWord'],
|
|
30
39
|
},
|
|
31
40
|
QuestionWord: {
|
|
41
|
+
aliases: [null, 'Fragewort'],
|
|
32
42
|
not: ['Determiner'],
|
|
33
43
|
},
|
|
34
44
|
Currency: {
|
|
45
|
+
aliases: [null, 'Währung'],
|
|
35
46
|
is: 'Noun',
|
|
36
47
|
},
|
|
37
48
|
Expression: {
|
|
49
|
+
aliases: [null, 'Interjektion'],
|
|
38
50
|
not: ['Noun', 'Adjective', 'Verb', 'Adverb'],
|
|
39
51
|
},
|
|
40
|
-
Abbreviation: {
|
|
52
|
+
Abbreviation: {
|
|
53
|
+
aliases: [null, 'Abkürzung'],
|
|
54
|
+
},
|
|
41
55
|
Url: {
|
|
42
56
|
not: ['HashTag', 'PhoneNumber', 'Verb', 'Adjective', 'Value', 'AtMention', 'Email'],
|
|
43
57
|
},
|
|
44
58
|
PhoneNumber: {
|
|
59
|
+
aliases: [null, 'Telefonnummer'],
|
|
45
60
|
not: ['HashTag', 'Verb', 'Adjective', 'Value', 'AtMention', 'Email'],
|
|
46
61
|
},
|
|
47
62
|
HashTag: {},
|
|
48
63
|
AtMention: {
|
|
64
|
+
aliases: [null, 'Erwähnung'],
|
|
49
65
|
is: 'Noun',
|
|
50
66
|
not: ['HashTag', 'Email'],
|
|
51
67
|
},
|
|
@@ -59,12 +75,15 @@ export default {
|
|
|
59
75
|
not: ['HashTag', 'Verb', 'Adjective', 'Value', 'AtMention'],
|
|
60
76
|
},
|
|
61
77
|
Acronym: {
|
|
78
|
+
aliases: [null, 'Akronym'],
|
|
62
79
|
not: ['Plural', 'RomanNumeral'],
|
|
63
80
|
},
|
|
64
81
|
Negative: {
|
|
82
|
+
aliases: [null, 'Negation'],
|
|
65
83
|
not: ['Noun', 'Adjective', 'Value'],
|
|
66
84
|
},
|
|
67
85
|
Condition: {
|
|
86
|
+
aliases: [null, 'Bedingung'],
|
|
68
87
|
not: ['Verb', 'Adjective', 'Noun', 'Value'],
|
|
69
88
|
},
|
|
70
89
|
}
|