Skip to content

Commit

Permalink
Fix many things
Browse files Browse the repository at this point in the history
Closes GH-36.
Closes GH-37.
Closes GH-39.
Closes GH-40.

Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
MichaelChambers authored Apr 21, 2020
1 parent 8d3e386 commit b2479c9
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var EXPRESSION_MONOSYLLABIC_TWO = new RegExp(
'g[hn]',
'l[lv]',
'mm',
'n[cgn]',
'n[cgns]',
'r[cnsv]',
'squ',
's[cklst]',
Expand Down Expand Up @@ -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('|') +
Expand All @@ -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'
)
Expand Down Expand Up @@ -180,7 +182,7 @@ var EXPRESSION_SINGLE = new RegExp(
'sides?',
'ports?',
'shires?',
'tion(?:ed|s)?'
'[gnst]ion(?:ed|s)?'
].join('|') +
')$'
].join('|'),
Expand Down Expand Up @@ -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'
)
Expand Down
2 changes: 2 additions & 0 deletions problematic.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"adieu": 2,
"adobe": 3,
"anemone": 4,
"anyone": 3,
"apache": 3,
"aphrodite": 4,
"apostrophe": 4,
Expand Down Expand Up @@ -37,6 +38,7 @@
"karate": 3,
"machete": 3,
"maybe": 2,
"naive": 2,
"newlywed": 3,
"penelope": 4,
"people": 2,
Expand Down
196 changes: 196 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down

0 comments on commit b2479c9

Please sign in to comment.