compromise-speech 0.0.2 → 0.1.1
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/README.md +7 -7
- package/builds/compromise-speech.cjs +1 -1
- package/builds/compromise-speech.min.js +1 -1
- package/builds/compromise-speech.mjs +1 -1
- package/index.d.ts +13 -0
- package/package.json +10 -4
- package/src/compute/soundsLike/transformations.js +1 -1
- package/demo/index.html +0 -28
- package/rollup.config.js +0 -23
- package/scratch.js +0 -17
- package/tests/_lib.js +0 -15
- package/tests/soundsLike.test.js +0 -21
- package/tests/syllables.test.js +0 -73
package/README.md
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
<div>pronounciation metadata plugin for <a href="https://github.com/spencermountain/compromise/">compromise</a></div>
|
|
5
5
|
|
|
6
6
|
<!-- npm version -->
|
|
7
|
-
<a href="https://npmjs.org/package/compromise-
|
|
8
|
-
<img src="https://img.shields.io/npm/v/compromise-
|
|
7
|
+
<a href="https://npmjs.org/package/compromise-speech">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/compromise-speech.svg?style=flat-square" />
|
|
9
9
|
</a>
|
|
10
10
|
|
|
11
11
|
<!-- file size -->
|
|
12
|
-
<a href="https://unpkg.com/compromise-
|
|
13
|
-
<img src="https://badge-size.herokuapp.com/spencermountain/compromise/master/plugins/
|
|
12
|
+
<a href="https://unpkg.com/compromise-speech/builds/compromise-speech.min.js">
|
|
13
|
+
<img src="https://badge-size.herokuapp.com/spencermountain/compromise/master/plugins/speech/builds/compromise-speech.min.js" />
|
|
14
14
|
</a>
|
|
15
15
|
|
|
16
16
|
<div align="center">
|
|
17
|
-
<code>npm install compromise-
|
|
17
|
+
<code>npm install compromise-speech</code>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
### Syllables
|
|
25
25
|
Tokenize a word approximately by it's pronounced syllables. We use a custom rule-based alortithm for this.
|
|
26
26
|
```js
|
|
27
|
-
import plg from 'compromise-
|
|
27
|
+
import plg from 'compromise-speech'
|
|
28
28
|
nlp.extend(plg)
|
|
29
29
|
|
|
30
30
|
let doc = nlp('seventh millenium. white collar')
|
|
@@ -57,7 +57,7 @@ Generate an expected pronounciation for the word, as a normalized string.
|
|
|
57
57
|
We use the [metaphone implementation](https://en.wikipedia.org/wiki/Metaphone), which is a simple rule-based pronounciation system.
|
|
58
58
|
|
|
59
59
|
```js
|
|
60
|
-
import plg from 'compromise-
|
|
60
|
+
import plg from 'compromise-speech'
|
|
61
61
|
nlp.extend(plg)
|
|
62
62
|
|
|
63
63
|
let doc = nlp('seventh millenium. white collar')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(){var e={dedup:e=>e.replace(/([^c])\1/g,"$1"),dropInitialLetters:e=>e.match(/^(kn|gn|pn|ae|wr)/)?e.
|
|
1
|
+
var e,t;e=this,t=function(){var e={dedup:e=>e.replace(/([^c])\1/g,"$1"),dropInitialLetters:e=>e.match(/^(kn|gn|pn|ae|wr)/)?e.substring(1,e.length-1):e,dropBafterMAtEnd:e=>e.replace(/mb$/,"m"),cchange:e=>(e=(e=(e=e.replace(/([^s]|^)(c)(h)/g,"$1x$3").trim()).replace(/cia/g,"xia")).replace(/c([iey])/g,"s$1")).replace(/c/g,"k"),dchange:e=>(e=e.replace(/d(ge|gy|gi)/g,"j$1")).replace(/d/g,"t"),dropG:e=>(e=e.replace(/gh(^$|[^aeiou])/g,"h$1")).replace(/g(n|ned)$/g,"$1"),changeG:e=>(e=(e=(e=e.replace(/gh/g,"f")).replace(/([^g]|^)(g)([iey])/g,"$1j$3")).replace(/gg/g,"g")).replace(/g/g,"k"),dropH:e=>e.replace(/([aeiou])h([^aeiou]|$)/g,"$1$2"),changeCK:e=>e.replace(/ck/g,"k"),changePH:e=>e.replace(/ph/g,"f"),changeQ:e=>e.replace(/q/g,"k"),changeS:e=>e.replace(/s(h|io|ia)/g,"x$1"),changeT:e=>e=e.replace(/t(ia[^n]|io)/g,"x$1"),dropT:e=>e.replace(/tch/g,"ch"),changeV:e=>e.replace(/v/g,"f"),changeWH:e=>e.replace(/^wh/,"w"),dropW:e=>e.replace(/w([^aeiou]|$)/g,"$1"),changeX:e=>(e=e.replace(/^x/,"s")).replace(/x/g,"ks"),dropY:e=>e.replace(/y([^aeiou]|$)/g,"$1"),changeZ:e=>e.replace(/z/,"s"),dropVowels:e=>e},t=function(t){return t=e.dedup(t),t=e.dropInitialLetters(t),t=e.dropBafterMAtEnd(t),t=e.changeCK(t),t=e.cchange(t),t=e.dchange(t),t=e.dropG(t),t=e.changeG(t),t=e.dropH(t),t=e.changePH(t),t=e.changeQ(t),t=e.changeS(t),t=e.changeX(t),t=e.changeT(t),t=e.dropT(t),t=e.changeV(t),t=e.changeWH(t),t=e.dropW(t),t=e.dropY(t),t=e.changeZ(t),(t=e.dropVowels(t)).trim()};const a=/^(eu)/i,c=/^[^aeiou]e([^d]|$)/,n=/^([^aeiouy])[aeiouy]\1[aeiouy]/,l=/^[^aeiouy]([aeiouy])[^aeiouy]\1/,h=/^([tg][aeiouy]){2}/,o=/^[^aeiouy]+$/,i=/[aeiouy]$/,r=/^[^aeiouy]h?[aeiouy]/,g=[/^[^aeiou]?ion/,/^[^aeiou]?ised/,/^[^aeiou]?iled/,/[aeiou]n[gt]$/,/\wa[gt]e$/];var p=function(e){let t=(e=(e=e.map((function(e){return e.trim()}))).filter((function(e){return""!==e}))).length;if(t>1){let a=e[t-2]+e[t-1];for(let c=0;c<g.length;c++)a.match(g[c])&&(e[t-2]=e[t-2]+e[t-1],e.pop())}if(e.length>1){let t=(1===e[0].length||e[0].match(r))&&e[0].match(i),a=e[1].match(c);if(t&&a){let t=e[0]+e[1];t.match(n)||t.match(l)||t.match(h)||(e[0]=e[0]+e[1],e.splice(1,1))}}if(e.length>1){let t=e[e.length-2].match(r)&&e[e.length-2].match(i),a=e[e.length-1].match(c)&&g.every(t=>!e[e.length-1].match(t));if(t&&a){let t=e[e.length-2]+e[e.length-1];t.match(n)||t.match(l)||t.match(h)||(e[e.length-2]=e[e.length-2]+e[e.length-1],e.splice(e.length-1,1))}}if(e.length>1){let t=e[0]+e[1];t.match(a)&&(e[0]=t,e.splice(1,1))}return e.length>1&&e[e.length-1].match(o)&&(e[e.length-2]=e[e.length-2]+e[e.length-1],e.splice(e.length-1,1)),e};const u=/ +/g,s=/[aeiouy]$/,f=/^[^aeiouy]h?[aeiouy]/,d=/^e[sm]/,m=/^e/,y=/(eo|eu|ia|oa|ua|ui)$/i,$=/[aiouy]/,k=/ee$/,b=function(e){let t=[],a=e.split(""),c="",n="",l="";for(let e=0;e<a.length;e++){c=a.slice(0,e).join(""),l=a[e],n=a.slice(e+1,a.length).join("");let h=c+a[e];if(c.match(s)&&!l.match(s))return n.match(d)&&(h+="e",n=n.replace(m,"")),t.push(h),t.concat(b(n));if(h.match(y))return t.push(c),t.push(l),t.concat(b(n));if(h.match(s)&&n.match(f))return t.push(h),t.concat(b(n))}if(e.match($)||e.match(k))t.push(e);else if(e){let a=t.length-1;a<0&&(a=0),t[a]=(t[a]||"")+e}return t};var x=function(e){let t=[];return e?((e=e.replace(/[.,?]/g,"")).split(u).map(e=>{t=t.concat(b(e))}),t=p(t),0===t.length&&(t=[e]),t=t.filter(e=>e),t):t};return{api:function(e){e.prototype.syllables=function(){this.compute("syllables");let e=[];return this.docs.forEach(t=>{let a=[];t.forEach(e=>{a=a.concat(e.syllables)}),a.length>0&&e.push(a)}),e},e.prototype.soundsLike=function(){this.compute("soundsLike");let e=[];return this.docs.forEach(t=>{let a=[];t.forEach(e=>{a=a.concat(e.soundsLike)}),a.length>0&&e.push(a)}),e}},compute:{soundsLike:function(e){e.docs.forEach(e=>{e.forEach(e=>{e.soundsLike=t(e.normal||e.text)})})},syllables:function(e){e.docs.forEach(e=>{e.forEach(e=>{e.syllables=x(e.normal||e.text)})})}}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).compromiseSpeech=t();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={dedup:e=>e.replace(/([^c])\1/g,"$1"),dropInitialLetters:e=>e.match(/^(kn|gn|pn|ae|wr)/)?e.
|
|
1
|
+
var e={dedup:e=>e.replace(/([^c])\1/g,"$1"),dropInitialLetters:e=>e.match(/^(kn|gn|pn|ae|wr)/)?e.substring(1,e.length-1):e,dropBafterMAtEnd:e=>e.replace(/mb$/,"m"),cchange:e=>(e=(e=(e=e.replace(/([^s]|^)(c)(h)/g,"$1x$3").trim()).replace(/cia/g,"xia")).replace(/c([iey])/g,"s$1")).replace(/c/g,"k"),dchange:e=>(e=e.replace(/d(ge|gy|gi)/g,"j$1")).replace(/d/g,"t"),dropG:e=>(e=e.replace(/gh(^$|[^aeiou])/g,"h$1")).replace(/g(n|ned)$/g,"$1"),changeG:e=>(e=(e=(e=e.replace(/gh/g,"f")).replace(/([^g]|^)(g)([iey])/g,"$1j$3")).replace(/gg/g,"g")).replace(/g/g,"k"),dropH:e=>e.replace(/([aeiou])h([^aeiou]|$)/g,"$1$2"),changeCK:e=>e.replace(/ck/g,"k"),changePH:e=>e.replace(/ph/g,"f"),changeQ:e=>e.replace(/q/g,"k"),changeS:e=>e.replace(/s(h|io|ia)/g,"x$1"),changeT:e=>e=e.replace(/t(ia[^n]|io)/g,"x$1"),dropT:e=>e.replace(/tch/g,"ch"),changeV:e=>e.replace(/v/g,"f"),changeWH:e=>e.replace(/^wh/,"w"),dropW:e=>e.replace(/w([^aeiou]|$)/g,"$1"),changeX:e=>(e=e.replace(/^x/,"s")).replace(/x/g,"ks"),dropY:e=>e.replace(/y([^aeiou]|$)/g,"$1"),changeZ:e=>e.replace(/z/,"s"),dropVowels:e=>e};var a=function(a){return a=e.dedup(a),a=e.dropInitialLetters(a),a=e.dropBafterMAtEnd(a),a=e.changeCK(a),a=e.cchange(a),a=e.dchange(a),a=e.dropG(a),a=e.changeG(a),a=e.dropH(a),a=e.changePH(a),a=e.changeQ(a),a=e.changeS(a),a=e.changeX(a),a=e.changeT(a),a=e.dropT(a),a=e.changeV(a),a=e.changeWH(a),a=e.dropW(a),a=e.dropY(a),a=e.changeZ(a),(a=e.dropVowels(a)).trim()};const t=/^(eu)/i,c=/^[^aeiou]e([^d]|$)/,n=/^([^aeiouy])[aeiouy]\1[aeiouy]/,l=/^[^aeiouy]([aeiouy])[^aeiouy]\1/,h=/^([tg][aeiouy]){2}/,r=/^[^aeiouy]+$/,o=/[aeiouy]$/,g=/^[^aeiouy]h?[aeiouy]/,i=[/^[^aeiou]?ion/,/^[^aeiou]?ised/,/^[^aeiou]?iled/,/[aeiou]n[gt]$/,/\wa[gt]e$/];var p=function(e){let a=(e=(e=e.map((function(e){return e.trim()}))).filter((function(e){return""!==e}))).length;if(a>1){let t=e[a-2]+e[a-1];for(let c=0;c<i.length;c++)t.match(i[c])&&(e[a-2]=e[a-2]+e[a-1],e.pop())}if(e.length>1){let a=(1===e[0].length||e[0].match(g))&&e[0].match(o),t=e[1].match(c);if(a&&t){let a=e[0]+e[1];a.match(n)||a.match(l)||a.match(h)||(e[0]=e[0]+e[1],e.splice(1,1))}}if(e.length>1){let a=e[e.length-2].match(g)&&e[e.length-2].match(o),t=e[e.length-1].match(c)&&i.every(a=>!e[e.length-1].match(a));if(a&&t){let a=e[e.length-2]+e[e.length-1];a.match(n)||a.match(l)||a.match(h)||(e[e.length-2]=e[e.length-2]+e[e.length-1],e.splice(e.length-1,1))}}if(e.length>1){let a=e[0]+e[1];a.match(t)&&(e[0]=a,e.splice(1,1))}return e.length>1&&e[e.length-1].match(r)&&(e[e.length-2]=e[e.length-2]+e[e.length-1],e.splice(e.length-1,1)),e};const u=/ +/g,s=/[aeiouy]$/,d=/^[^aeiouy]h?[aeiouy]/,f=/^e[sm]/,m=/^e/,$=/(eo|eu|ia|oa|ua|ui)$/i,y=/[aiouy]/,k=/ee$/,E=function(e){let a=[],t=e.split(""),c="",n="",l="";for(let e=0;e<t.length;e++){c=t.slice(0,e).join(""),l=t[e],n=t.slice(e+1,t.length).join("");let h=c+t[e];if(c.match(s)&&!l.match(s))return n.match(f)&&(h+="e",n=n.replace(m,"")),a.push(h),a.concat(E(n));if(h.match($))return a.push(c),a.push(l),a.concat(E(n));if(h.match(s)&&n.match(d))return a.push(h),a.concat(E(n))}if(e.match(y)||e.match(k))a.push(e);else if(e){let t=a.length-1;t<0&&(t=0),a[t]=(a[t]||"")+e}return a};var x=function(e){let a=[];return e?((e=e.replace(/[.,?]/g,"")).split(u).map(e=>{a=a.concat(E(e))}),a=p(a),0===a.length&&(a=[e]),a=a.filter(e=>e),a):a};var b={api:function(e){e.prototype.syllables=function(){this.compute("syllables");let e=[];return this.docs.forEach(a=>{let t=[];a.forEach(e=>{t=t.concat(e.syllables)}),t.length>0&&e.push(t)}),e},e.prototype.soundsLike=function(){this.compute("soundsLike");let e=[];return this.docs.forEach(a=>{let t=[];a.forEach(e=>{t=t.concat(e.soundsLike)}),t.length>0&&e.push(t)}),e}},compute:{soundsLike:function(e){e.docs.forEach(e=>{e.forEach(e=>{e.soundsLike=a(e.normal||e.text)})})},syllables:function(e){e.docs.forEach(e=>{e.forEach(e=>{e.syllables=x(e.normal||e.text)})})}}};export{b as default};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import nlp from 'compromise'
|
|
2
|
+
|
|
3
|
+
export interface SpeechMethods {
|
|
4
|
+
/** estimate spoken phenomes */
|
|
5
|
+
syllables(): String[][]
|
|
6
|
+
/** estimate pronounciation information */
|
|
7
|
+
soundsLike(): String[][]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** extended compromise lib **/
|
|
11
|
+
declare const nlpSpeech: nlp.TypedPlugin<SpeechMethods>
|
|
12
|
+
|
|
13
|
+
export default nlpSpeech
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compromise-speech",
|
|
3
3
|
"description": "plugin for nlp-compromise",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)",
|
|
6
6
|
"main": "./src/plugin.js",
|
|
7
7
|
"unpkg": "./builds/compromise-speech.min.js",
|
|
8
8
|
"module": "./builds/compromise-speech.mjs",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"types": "types/index.d.ts",
|
|
11
10
|
"sideEffects": false,
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"import": "./src/plugin.js",
|
|
15
|
-
"require": "./builds/compromise-speech.cjs"
|
|
15
|
+
"require": "./builds/compromise-speech.cjs",
|
|
16
|
+
"types": "./index.d.ts"
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
@@ -23,12 +24,17 @@
|
|
|
23
24
|
"scripts": {
|
|
24
25
|
"test": "tape \"./tests/**/*.test.js\" | tap-dancer --color always",
|
|
25
26
|
"testb": "TESTENV=prod tape \"./tests/**/*.test.js\" | tap-dancer --color always",
|
|
26
|
-
"watch": "
|
|
27
|
+
"watch": "node --watch ./scratch.js",
|
|
27
28
|
"build": "rollup -c --silent"
|
|
28
29
|
},
|
|
29
30
|
"eslintIgnore": [
|
|
30
31
|
"builds/*.js"
|
|
31
32
|
],
|
|
33
|
+
"files": [
|
|
34
|
+
"builds/",
|
|
35
|
+
"src/",
|
|
36
|
+
"index.d.ts"
|
|
37
|
+
],
|
|
32
38
|
"peerDependencies": {
|
|
33
39
|
"compromise": ">=14.0.0"
|
|
34
40
|
},
|
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/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
|
-
})
|