compromise-speech 0.1.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +89 -21
- package/builds/compromise-speech.cjs +483 -279
- package/builds/compromise-speech.min.js +1 -1
- package/builds/compromise-speech.mjs +1 -1
- package/package.json +47 -26
- package/src/_version.js +1 -0
- package/src/api.js +5 -5
- package/src/plugin.js +9 -3
- package/src/{compute/soundsLike → sounds-like}/transformations.js +1 -1
- package/src/syllables/index.js +12 -0
- package/src/syllables/split/_lib.js +32 -0
- package/src/syllables/split/find-cuts/00-exceptions.js +81 -0
- package/src/syllables/split/find-cuts/01-vowel-span.js +155 -0
- package/src/syllables/split/find-cuts/02-boundaries.js +86 -0
- package/src/syllables/split/find-cuts/_compound-prefixes.js +22 -0
- package/src/syllables/split/find-cuts/index.js +27 -0
- package/src/syllables/split/index.js +22 -0
- package/types/index.d.cts +9 -0
- package/{index.d.ts → types/index.d.ts} +1 -1
- package/demo/index.html +0 -28
- package/rollup.config.js +0 -23
- package/scratch.js +0 -17
- package/src/compute/index.js +0 -7
- package/src/compute/syllables/index.js +0 -13
- package/src/compute/syllables/postProcess.js +0 -107
- package/src/compute/syllables/syllables.js +0 -90
- package/tests/_lib.js +0 -15
- package/tests/soundsLike.test.js +0 -21
- package/tests/syllables.test.js +0 -73
- /package/src/{compute/soundsLike → sounds-like}/index.js +0 -0
- /package/src/{compute/soundsLike → sounds-like}/metaphone.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Match a compound's left component, including its silent e.
|
|
2
|
+
// Both vowel counting and boundary placement use these same spelling rules.
|
|
3
|
+
const compoundPrefixes = [
|
|
4
|
+
/^note(?=book)/, // note-book: silent e and a boundary after the complete base
|
|
5
|
+
/^side(?=kick|line|show|step|stream|track|walk|water|way|winder|wise)/,
|
|
6
|
+
/^some(?=bod|one|time|where)/,
|
|
7
|
+
/^none(?=such)/, // none-such retains the silent e of none
|
|
8
|
+
/^goose(?=berr)/, // goose-berry and goose-berries
|
|
9
|
+
/^above(?=board|ground)/,
|
|
10
|
+
/^a?fore(?=clos|taste|said|mentioned)/,
|
|
11
|
+
/^ware(?=house|housing)/,
|
|
12
|
+
/^space(?=port|ship)/,
|
|
13
|
+
/^race(?=horse)/,
|
|
14
|
+
/^lake(?=side)/,
|
|
15
|
+
/^white(?=side)/,
|
|
16
|
+
/^state(?=side)/,
|
|
17
|
+
/^juke(?=box)/,
|
|
18
|
+
/^police(?=woman|women|man|men)/,
|
|
19
|
+
/^(?:sale|spoke)s?(?=woman|women|man|men)/,
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
export default compoundPrefixes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import checkExceptions from './00-exceptions.js'
|
|
2
|
+
import vowelSpan from './01-vowel-span.js'
|
|
3
|
+
import pickBoundaries from './02-boundaries.js'
|
|
4
|
+
|
|
5
|
+
const findCuts = str => {
|
|
6
|
+
// Exact exceptions and their plural forms take priority over spelling rules.
|
|
7
|
+
const found = checkExceptions(str)
|
|
8
|
+
if (found !== null) {
|
|
9
|
+
return found
|
|
10
|
+
}
|
|
11
|
+
// Keep apostrophe suffixes intact so vowel rules can recognize an extra syllable.
|
|
12
|
+
const vowelSpans = vowelSpan(str)
|
|
13
|
+
const cuts = pickBoundaries(str, vowelSpans)
|
|
14
|
+
// An exception may supply base-word cuts without overriding a syllabic suffix.
|
|
15
|
+
const key = str.replace(/['’](?:s|d|ll|re|ve)$/, '')
|
|
16
|
+
// Without a suffix, the initial lookup already checked this word.
|
|
17
|
+
if (key === str) {
|
|
18
|
+
return cuts
|
|
19
|
+
}
|
|
20
|
+
const baseCuts = checkExceptions(key)
|
|
21
|
+
if (baseCuts !== null) {
|
|
22
|
+
return baseCuts.concat(cuts.filter(cut => cut >= key.length))
|
|
23
|
+
}
|
|
24
|
+
return cuts
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default findCuts
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import findCuts from './find-cuts/index.js'
|
|
2
|
+
import { applyCuts, normalize, pushCutsBack } from './_lib.js'
|
|
3
|
+
|
|
4
|
+
// Pass the original term text through; the tokenizer owns pre/post punctuation.
|
|
5
|
+
const splitTerm = (term, options = {}) => {
|
|
6
|
+
if (!term.text) {
|
|
7
|
+
return []
|
|
8
|
+
}
|
|
9
|
+
let str = term.text
|
|
10
|
+
if (options.normalize) {
|
|
11
|
+
str = term.normal || term.text
|
|
12
|
+
}
|
|
13
|
+
// we can split on a normalized string
|
|
14
|
+
const { clean, prefix } = normalize(str)
|
|
15
|
+
let cuts = findCuts(clean)
|
|
16
|
+
if (prefix && prefix.length > 0) {
|
|
17
|
+
cuts = pushCutsBack(cuts, prefix)
|
|
18
|
+
}
|
|
19
|
+
return applyCuts(str, cuts)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default splitTerm
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type esmPlugin from './index.d.ts' with { 'resolution-mode': 'import' }
|
|
2
|
+
import type * as types from './index.d.ts' with { 'resolution-mode': 'import' }
|
|
3
|
+
|
|
4
|
+
declare const plugin: typeof esmPlugin
|
|
5
|
+
declare namespace plugin {
|
|
6
|
+
export type SpeechMethods = types.SpeechMethods
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export = plugin
|
package/demo/index.html
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
|
|
6
|
-
<script src="https://unpkg.com/compromise"></script>
|
|
7
|
-
<!-- <script src="https://unpkg.com/compromise-speech"></script> -->
|
|
8
|
-
<script src="../builds/compromise-speech.min.js"></script>
|
|
9
|
-
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
<p>compromise-speech demo:</p>
|
|
14
|
-
<ul>
|
|
15
|
-
<kbd>chocolate microscopes </kbd>
|
|
16
|
-
<pre id="res">loading</pre>
|
|
17
|
-
</ul>
|
|
18
|
-
|
|
19
|
-
<script defer>
|
|
20
|
-
nlp.plugin(compromiseSpeech) // window.compromiseSpeech
|
|
21
|
-
let txt = document.querySelector('kbd').innerText
|
|
22
|
-
let doc = nlp(txt)
|
|
23
|
-
let json = doc.syllables()
|
|
24
|
-
document.querySelector('#res').innerHTML = JSON.stringify(json, null, 2)
|
|
25
|
-
</script>
|
|
26
|
-
</body>
|
|
27
|
-
|
|
28
|
-
</html>
|
package/rollup.config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { terser } from 'rollup-plugin-terser'
|
|
2
|
-
import sizeCheck from 'rollup-plugin-filesize-check'
|
|
3
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
4
|
-
|
|
5
|
-
const opts = { keep_classnames: true, module: true }
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
input: 'src/plugin.js',
|
|
10
|
-
output: [{ file: 'builds/compromise-speech.cjs', format: 'umd', name: 'compromiseSpeech' }],
|
|
11
|
-
plugins: [nodeResolve(), sizeCheck({ expect: 11, warn: 15 })],
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
input: 'src/plugin.js',
|
|
15
|
-
output: [{ file: 'builds/compromise-speech.min.js', format: 'umd', name: 'compromiseSpeech' }],
|
|
16
|
-
plugins: [nodeResolve(), terser(opts), sizeCheck({ expect: 4, warn: 15 })],
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
input: 'src/plugin.js',
|
|
20
|
-
output: [{ file: 'builds/compromise-speech.mjs', format: 'esm' }],
|
|
21
|
-
plugins: [nodeResolve(), terser(opts), sizeCheck({ expect: 4, warn: 15 })],
|
|
22
|
-
}
|
|
23
|
-
]
|
package/scratch.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console, no-unused-vars */
|
|
2
|
-
import nlp from '../../src/three.js'
|
|
3
|
-
|
|
4
|
-
import speechPlugin from './src/plugin.js'
|
|
5
|
-
nlp.plugin(speechPlugin)
|
|
6
|
-
// nlp.verbose(true)
|
|
7
|
-
// nlp.verbose('date')
|
|
8
|
-
|
|
9
|
-
let txt = ''
|
|
10
|
-
txt = 'seventh millenium. white collar'
|
|
11
|
-
|
|
12
|
-
// let doc = nlp(txt).compute(['soundsLike', 'syllables'])
|
|
13
|
-
// console.dir(doc.json()[0], { depth: 5 })
|
|
14
|
-
|
|
15
|
-
let doc = nlp('calgary')
|
|
16
|
-
doc.compute('soundsLike')
|
|
17
|
-
console.log(JSON.stringify(doc.json()[0], null, 2))
|
package/src/compute/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import getSyllables from './syllables.js'
|
|
2
|
-
|
|
3
|
-
// const defaultObj = { normal: true, text: true, terms: false }
|
|
4
|
-
|
|
5
|
-
const syllables = function (view) {
|
|
6
|
-
view.docs.forEach(terms => {
|
|
7
|
-
terms.forEach(term => {
|
|
8
|
-
term.syllables = getSyllables(term.normal || term.text)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default syllables
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
const starts_with_single_vowel_combos = /^(eu)/i
|
|
2
|
-
const joining_consonant_vowel = /^[^aeiou]e([^d]|$)/
|
|
3
|
-
const cvcv_same_consonant = /^([^aeiouy])[aeiouy]\1[aeiouy]/
|
|
4
|
-
const cvcv_same_vowel = /^[^aeiouy]([aeiouy])[^aeiouy]\1/
|
|
5
|
-
const cvcv_known_consonants = /^([tg][aeiouy]){2}/
|
|
6
|
-
const only_one_or_more_c = /^[^aeiouy]+$/
|
|
7
|
-
|
|
8
|
-
const ends_with_vowel = /[aeiouy]$/
|
|
9
|
-
const starts_with_consonant_vowel = /^[^aeiouy]h?[aeiouy]/
|
|
10
|
-
|
|
11
|
-
const ones = [
|
|
12
|
-
/^[^aeiou]?ion/,
|
|
13
|
-
/^[^aeiou]?ised/,
|
|
14
|
-
/^[^aeiou]?iled/,
|
|
15
|
-
|
|
16
|
-
// -ing, -ent
|
|
17
|
-
/[aeiou]n[gt]$/,
|
|
18
|
-
|
|
19
|
-
// -ate, -age
|
|
20
|
-
/\wa[gt]e$/,
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
//suffix fixes
|
|
24
|
-
const postprocess = function (arr) {
|
|
25
|
-
//trim whitespace
|
|
26
|
-
arr = arr.map(function (w) {
|
|
27
|
-
return w.trim()
|
|
28
|
-
})
|
|
29
|
-
arr = arr.filter(function (w) {
|
|
30
|
-
return w !== ''
|
|
31
|
-
})
|
|
32
|
-
// if (arr.length > 2) {
|
|
33
|
-
// return arr;
|
|
34
|
-
// }
|
|
35
|
-
let l = arr.length
|
|
36
|
-
if (l > 1) {
|
|
37
|
-
let suffix = arr[l - 2] + arr[l - 1]
|
|
38
|
-
for (let i = 0; i < ones.length; i++) {
|
|
39
|
-
if (suffix.match(ones[i])) {
|
|
40
|
-
arr[l - 2] = arr[l - 2] + arr[l - 1]
|
|
41
|
-
arr.pop()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// since the open syllable detection is overzealous,
|
|
47
|
-
// sometimes need to rejoin incorrect splits
|
|
48
|
-
if (arr.length > 1) {
|
|
49
|
-
let first_is_open =
|
|
50
|
-
(arr[0].length === 1 || arr[0].match(starts_with_consonant_vowel)) &&
|
|
51
|
-
arr[0].match(ends_with_vowel)
|
|
52
|
-
let second_is_joining = arr[1].match(joining_consonant_vowel)
|
|
53
|
-
|
|
54
|
-
if (first_is_open && second_is_joining) {
|
|
55
|
-
let possible_combination = arr[0] + arr[1]
|
|
56
|
-
let probably_separate_syllables =
|
|
57
|
-
possible_combination.match(cvcv_same_consonant) ||
|
|
58
|
-
possible_combination.match(cvcv_same_vowel) ||
|
|
59
|
-
possible_combination.match(cvcv_known_consonants)
|
|
60
|
-
|
|
61
|
-
if (!probably_separate_syllables) {
|
|
62
|
-
arr[0] = arr[0] + arr[1]
|
|
63
|
-
arr.splice(1, 1)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (arr.length > 1) {
|
|
69
|
-
let second_to_last_is_open =
|
|
70
|
-
arr[arr.length - 2].match(starts_with_consonant_vowel) &&
|
|
71
|
-
arr[arr.length - 2].match(ends_with_vowel)
|
|
72
|
-
let last_is_joining =
|
|
73
|
-
arr[arr.length - 1].match(joining_consonant_vowel) &&
|
|
74
|
-
ones.every(re => !arr[arr.length - 1].match(re))
|
|
75
|
-
|
|
76
|
-
if (second_to_last_is_open && last_is_joining) {
|
|
77
|
-
let possible_combination = arr[arr.length - 2] + arr[arr.length - 1]
|
|
78
|
-
let probably_separate_syllables =
|
|
79
|
-
possible_combination.match(cvcv_same_consonant) ||
|
|
80
|
-
possible_combination.match(cvcv_same_vowel) ||
|
|
81
|
-
possible_combination.match(cvcv_known_consonants)
|
|
82
|
-
|
|
83
|
-
if (!probably_separate_syllables) {
|
|
84
|
-
arr[arr.length - 2] = arr[arr.length - 2] + arr[arr.length - 1]
|
|
85
|
-
arr.splice(arr.length - 1, 1)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (arr.length > 1) {
|
|
91
|
-
let single = arr[0] + arr[1]
|
|
92
|
-
if (single.match(starts_with_single_vowel_combos)) {
|
|
93
|
-
arr[0] = single
|
|
94
|
-
arr.splice(1, 1)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (arr.length > 1) {
|
|
99
|
-
if (arr[arr.length - 1].match(only_one_or_more_c)) {
|
|
100
|
-
arr[arr.length - 2] = arr[arr.length - 2] + arr[arr.length - 1]
|
|
101
|
-
arr.splice(arr.length - 1, 1)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return arr
|
|
106
|
-
}
|
|
107
|
-
export default postprocess
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
//chop a string into pronounced syllables
|
|
2
|
-
import postProcess from './postProcess.js'
|
|
3
|
-
|
|
4
|
-
const all_spaces = / +/g
|
|
5
|
-
const ends_with_vowel = /[aeiouy]$/
|
|
6
|
-
const starts_with_consonant_vowel = /^[^aeiouy]h?[aeiouy]/
|
|
7
|
-
const starts_with_e_then_specials = /^e[sm]/
|
|
8
|
-
const starts_with_e = /^e/
|
|
9
|
-
const ends_with_noisy_vowel_combos = /(eo|eu|ia|oa|ua|ui)$/i
|
|
10
|
-
const aiouy = /[aiouy]/
|
|
11
|
-
const ends_with_ee = /ee$/
|
|
12
|
-
// const whitespace_dash = /\s\-/
|
|
13
|
-
|
|
14
|
-
//method is nested because it's called recursively
|
|
15
|
-
const doWord = function (w) {
|
|
16
|
-
let all = []
|
|
17
|
-
let chars = w.split('')
|
|
18
|
-
let before = ''
|
|
19
|
-
let after = ''
|
|
20
|
-
let current = ''
|
|
21
|
-
for (let i = 0; i < chars.length; i++) {
|
|
22
|
-
before = chars.slice(0, i).join('')
|
|
23
|
-
current = chars[i]
|
|
24
|
-
after = chars.slice(i + 1, chars.length).join('')
|
|
25
|
-
let candidate = before + chars[i]
|
|
26
|
-
|
|
27
|
-
//it's a consonant that comes after a vowel
|
|
28
|
-
if (before.match(ends_with_vowel) && !current.match(ends_with_vowel)) {
|
|
29
|
-
if (after.match(starts_with_e_then_specials)) {
|
|
30
|
-
candidate += 'e'
|
|
31
|
-
after = after.replace(starts_with_e, '')
|
|
32
|
-
}
|
|
33
|
-
all.push(candidate)
|
|
34
|
-
return all.concat(doWord(after))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//unblended vowels ('noisy' vowel combinations)
|
|
38
|
-
if (candidate.match(ends_with_noisy_vowel_combos)) {
|
|
39
|
-
//'io' is noisy, not in 'ion'
|
|
40
|
-
all.push(before)
|
|
41
|
-
all.push(current)
|
|
42
|
-
return all.concat(doWord(after)) //recursion
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// if candidate is followed by a CV, assume consecutive open syllables
|
|
46
|
-
if (candidate.match(ends_with_vowel) && after.match(starts_with_consonant_vowel)) {
|
|
47
|
-
all.push(candidate)
|
|
48
|
-
return all.concat(doWord(after))
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//if still running, end last syllable
|
|
52
|
-
if (w.match(aiouy) || w.match(ends_with_ee)) {
|
|
53
|
-
//allow silent trailing e
|
|
54
|
-
all.push(w)
|
|
55
|
-
} else if (w) {
|
|
56
|
-
let last = all.length - 1
|
|
57
|
-
if (last < 0) {
|
|
58
|
-
last = 0
|
|
59
|
-
}
|
|
60
|
-
all[last] = (all[last] || '') + w //append it to the last one
|
|
61
|
-
}
|
|
62
|
-
return all
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let syllables = function (str) {
|
|
66
|
-
let all = []
|
|
67
|
-
if (!str) {
|
|
68
|
-
return all
|
|
69
|
-
}
|
|
70
|
-
str = str.replace(/[.,?]/g, '')
|
|
71
|
-
str.split(all_spaces).map(s => {
|
|
72
|
-
all = all.concat(doWord(s))
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// str.split(whitespace_dash).forEach(doWord)
|
|
76
|
-
all = postProcess(all)
|
|
77
|
-
|
|
78
|
-
//for words like 'tree' and 'free'
|
|
79
|
-
if (all.length === 0) {
|
|
80
|
-
all = [str]
|
|
81
|
-
}
|
|
82
|
-
//filter blanks
|
|
83
|
-
all = all.filter(s => s)
|
|
84
|
-
|
|
85
|
-
return all
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// console.log(syllables('civilised'))
|
|
89
|
-
|
|
90
|
-
export default syllables
|
package/tests/_lib.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import build from '../../../builds/one/compromise-one.mjs'
|
|
2
|
-
import src from '../../../src/one.js'
|
|
3
|
-
import plgBuild from '../builds/compromise-speech.mjs'
|
|
4
|
-
import plg from '../src/plugin.js'
|
|
5
|
-
let nlp;
|
|
6
|
-
|
|
7
|
-
if (process.env.TESTENV === 'prod') {
|
|
8
|
-
console.warn('== production build test 🚀 ==') // eslint-disable-line
|
|
9
|
-
nlp = build
|
|
10
|
-
nlp.plugin(plgBuild)
|
|
11
|
-
} else {
|
|
12
|
-
nlp = src
|
|
13
|
-
nlp.plugin(plg)
|
|
14
|
-
}
|
|
15
|
-
export default nlp
|
package/tests/soundsLike.test.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import test from 'tape'
|
|
2
|
-
import nlp from './_lib.js'
|
|
3
|
-
|
|
4
|
-
test('soundsLike-tests', function (t) {
|
|
5
|
-
let arr = [
|
|
6
|
-
['phil collins', 'fil kolins'],
|
|
7
|
-
['Philadelphia freedom', 'filatelfia fretom'],
|
|
8
|
-
['Shine on me', 'shine on me'],
|
|
9
|
-
['peace of mind', 'pease of mint'],
|
|
10
|
-
['Yes I do', 'yes i to'],
|
|
11
|
-
['Zapped me', 'sapet me'],
|
|
12
|
-
['Right between the eyes', 'rit betwen the eyes'],
|
|
13
|
-
// ['But the times have changed', 'but the times hafe kshanjet'],
|
|
14
|
-
]
|
|
15
|
-
arr.forEach((a) => {
|
|
16
|
-
let doc = nlp(a[0])
|
|
17
|
-
let str = doc.soundsLike({})[0].join(' ')
|
|
18
|
-
t.equal(str, a[1], a[0])
|
|
19
|
-
})
|
|
20
|
-
t.end()
|
|
21
|
-
})
|
package/tests/syllables.test.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import test from 'tape'
|
|
2
|
-
import nlp from './_lib.js'
|
|
3
|
-
|
|
4
|
-
const words = [
|
|
5
|
-
'sud den ly',
|
|
6
|
-
'con sti pa tion',
|
|
7
|
-
'di a bo lic',
|
|
8
|
-
'fa ted',
|
|
9
|
-
'ge ne tic',
|
|
10
|
-
'hy giene',
|
|
11
|
-
'o ma ha',
|
|
12
|
-
'i mi ta ted',
|
|
13
|
-
'tree',
|
|
14
|
-
'ci vi lised',
|
|
15
|
-
'went',
|
|
16
|
-
'to ge ther',
|
|
17
|
-
'tog gle',
|
|
18
|
-
'move ment',
|
|
19
|
-
'mo ment',
|
|
20
|
-
'do nate',
|
|
21
|
-
'vi king',
|
|
22
|
-
'wat tage',
|
|
23
|
-
'con gre gate',
|
|
24
|
-
'some thing',
|
|
25
|
-
'sales man',
|
|
26
|
-
're sour ces',
|
|
27
|
-
'eve ry thing',
|
|
28
|
-
'eve ry bo dy',
|
|
29
|
-
'hole',
|
|
30
|
-
'ho ly',
|
|
31
|
-
'sec ret',
|
|
32
|
-
'cause',
|
|
33
|
-
'fate',
|
|
34
|
-
'fates',
|
|
35
|
-
'eu lo gy',
|
|
36
|
-
'e on',
|
|
37
|
-
'rea sons',
|
|
38
|
-
'and',
|
|
39
|
-
'hoc key',
|
|
40
|
-
'wild',
|
|
41
|
-
'fun',
|
|
42
|
-
'fun ny',
|
|
43
|
-
'hor ses',
|
|
44
|
-
'cal ga ry',
|
|
45
|
-
'tor na do',
|
|
46
|
-
'pen',
|
|
47
|
-
'stu dy',
|
|
48
|
-
'ja mai ca',
|
|
49
|
-
'tri ni dad',
|
|
50
|
-
'ca na da',
|
|
51
|
-
'i ran',
|
|
52
|
-
'i raq',
|
|
53
|
-
'sau di a ra bi a',
|
|
54
|
-
'clin ton',
|
|
55
|
-
'hub ris',
|
|
56
|
-
'tur key',
|
|
57
|
-
'cor si ca',
|
|
58
|
-
'dev iled',
|
|
59
|
-
// 'horse',
|
|
60
|
-
// 'chance',
|
|
61
|
-
// 'peo ple'
|
|
62
|
-
]
|
|
63
|
-
|
|
64
|
-
test('test length', function (t) {
|
|
65
|
-
words.forEach(sep => {
|
|
66
|
-
let str = sep.replace(/ /g, '')
|
|
67
|
-
let doc = nlp(str)
|
|
68
|
-
let have = doc.syllables()[0]
|
|
69
|
-
let want = sep.split(/ /g)
|
|
70
|
-
t.equal(have.length, want.length, str)
|
|
71
|
-
})
|
|
72
|
-
t.end()
|
|
73
|
-
})
|
|
File without changes
|
|
File without changes
|