From b2479c9d2edae8d4dbd041806c72d8e16666c857 Mon Sep 17 00:00:00 2001 From: MichaelChambers Date: Tue, 21 Apr 2020 02:44:16 -0400 Subject: [PATCH] Fix many things Closes GH-36. Closes GH-37. Closes GH-39. Closes GH-40. Reviewed-by: Titus Wormer --- index.js | 10 ++- problematic.json | 2 + test/index.js | 196 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 39a1e0b..d7a364e 100644 --- a/index.js +++ b/index.js @@ -75,7 +75,7 @@ var EXPRESSION_MONOSYLLABIC_TWO = new RegExp( 'g[hn]', 'l[lv]', 'mm', - 'n[cgn]', + 'n[cgns]', 'r[cnsv]', 'squ', 's[cklst]', @@ -106,6 +106,7 @@ var EXPRESSION_DOUBLE_SYLLABIC_ONE = new RegExp( 'ua', 'react?', 'orbed', // Cancel `'.[^aeiuoycgltdb]{2,}ed$',` + 'shred', // Cancel `'.[^aeiuoycgltdb]{2,}ed$',` 'eings?', '[aeiouy]sh?e[rs]' ].join('|') + @@ -119,7 +120,8 @@ var EXPRESSION_DOUBLE_SYLLABIC_TWO = new RegExp( '[^gq]ua[^auieo]', '[aeiou]{3}', '^(?:ia|mc|coa[dglx].)', - '^re(app|es|im|us)' + '^re(app|es|im|us)', + '(th|d)eist' ].join('|'), 'g' ) @@ -180,7 +182,7 @@ var EXPRESSION_SINGLE = new RegExp( 'sides?', 'ports?', 'shires?', - 'tion(?:ed|s)?' + '[gnst]ion(?:ed|s)?' ].join('|') + ')$' ].join('|'), @@ -218,7 +220,7 @@ var EXPRESSION_DOUBLE = new RegExp( 'somer' ].join('|') + ')', - '(?:fully|berry|woman|women|edly)$' + '(?:fully|berry|woman|women|edly|union|((?:[bcdfghjklmnpqrstvwxz])|[aeiou])ye?ing)$' ].join('|'), 'g' ) diff --git a/problematic.json b/problematic.json index ede4ff9..a4b40b0 100644 --- a/problematic.json +++ b/problematic.json @@ -10,6 +10,7 @@ "adieu": 2, "adobe": 3, "anemone": 4, + "anyone": 3, "apache": 3, "aphrodite": 4, "apostrophe": 4, @@ -37,6 +38,7 @@ "karate": 3, "machete": 3, "maybe": 2, + "naive": 2, "newlywed": 3, "penelope": 4, "people": 2, diff --git a/test/index.js b/test/index.js index c5df7ec..0b7544f 100644 --- a/test/index.js +++ b/test/index.js @@ -66,6 +66,202 @@ test('api', function(t) { 'GH-32 (awe)' ) + t.deepEqual( + [ + 'communion', + 'contagion', + 'decision', + 'division', + 'erosion', + 'occasion', + 'opinion', + 'religion', + 'reunion', + 'bunion', + 'fission', + 'fusion', + 'mission', + 'nation', + 'onion', + 'passion', + 'region', + 'session', + 'union', + 'version', + 'vision' + ].map(syllable), + [3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], + 'GH-36 ([gnst]ion$)' + ) + + t.deepEqual( + [ + 'anybody', + 'anymore', + 'anyone', + 'anyones', + 'anyplace', + 'anything', + 'anythings', + 'anytime', + 'anyway', + 'anyways', + 'anywhere' + ].map(syllable), + [4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], + 'GH-36 ^any' + ) + + t.deepEqual( + [ + 'anyone', + 'everyone', + 'alone', + 'lonely', + 'ozone', + 'one', + 'bone', + 'phone' + ].map(syllable), + [3, 3, 2, 2, 2, 1, 1, 1], + 'GH-36 one$' + ) + + t.deepEqual( + [ + 'embodying', + 'annoying', + 'buoying', + 'busying', + 'envying', + 'jurying', + 'nosying', + 'obeying', + 'pitying', + 'untying', + 'braying', + 'buying', + 'cloying', + 'crying', + 'drying', + 'dying', + 'eying', + 'eyeing', + 'flying', + 'lying', + 'paying', + 'plying', + 'saying', + 'spraying', + 'toying', + 'trying', + 'tying', + 'vying', + 'ying' + ].map(syllable), + [ + 4, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 1 + ], + 'GH-37 (ying$)' + ) + + t.deepEqual( + [ + 'shreds', + 'shredded', + 'shredder', + 'shredders', + 'shredding', + 'shredless' + ].map(syllable), + [1, 2, 2, 2, 2, 2], + 'GH-37 shredless' + ) + + t.deepEqual( + [ + 'monotheist', + 'monotheists', + 'monotheistic', + 'polytheist', + 'polytheists', + 'polytheistic', + 'atheist', + 'atheists', + 'atheistic', + 'pantheist', + 'pantheists', + 'pantheistic', + 'deist', + 'deists', + 'deistic', + 'theist', + 'theists', + 'theistic', + 'heist' + ].map(syllable), + [4, 4, 5, 4, 4, 5, 3, 3, 4, 3, 3, 4, 2, 2, 3, 2, 2, 3, 1], + 'GH-37 (th|d)iest(s|ic)?)' + ) + + t.deepEqual( + [ + 'reminiscense', + 'commonsense', + 'innocense', + 'recompense', + 'condense', + 'defense', + 'dispense', + 'expanse', + 'expense', + 'immense', + 'intense', + 'license', + 'mouthrinse', + 'nonsense', + 'offense', + 'pretense', + 'response', + 'suspense', + 'cleanse', + 'dense', + 'rinse', + 'sense', + 'tense' + ].map(syllable), + [4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], + 'GH-39 ([aeiouy]nse$)' + ) + t.end() })