Coder Social home page Coder Social logo

syllable's Issues

Contractions are not counted correctly

Hi! We noticed that contractions aren't handled properly. A few examples:

that's -> 2 (should be 1)
they're -> 2 (should be 1)
aren't -> 3 (should be 1)

Let me know if you have any thoughts on how to account for contractions!

Thanks,
Aviv (Engineering Lead at Flocabulary)

Does not account for re- prefix in some cases.

reuse -> 1
reimpose -> 2

Works for some cases:
realign -> 3

This was being propped up by the test cases including the failing words ending in -shed or -sed, which #20 solves, so I only noticed this now.

Unfortunately, just triggering on re- doesn't work, since there are plenty of valid words that start with re- that aren't using it as a prefix.

real/deal/really have too many syllables

"Real" counts as 2—should be 1
"Deal" counts as 2—should be 1
"Really" counts as 3—should be 2

There may be similar words affected that I didn't catch.

-rbed should be one syllable

Waterbed, riverbed, featherbed, etc are compound words, and thus exceptions.

See: disturbed, barbed, herbed, absorbed.

Option to get the actual syllables

apologies if this is a silly question as I haven't looked at how the code works, but would it be possible to return the actual syllables, rather than just the count?

node.js: "syllable unicorn" produces 5 instead of 6 inside shell

The following in node.js on 10.36 and 12.2:
console.log("syllable unicorn", syllable("syllable unicorn"));
produces 5 instead of the correct 6 like in the shell directly.

My current solution is to just split the string by spaces and add up the values to find the total syllables in the line.

My experience with NLP is limited, so at the moment I'm not quite sure what went wrong where, but I'll dig through and see what I can find.

Thanks for the npm module! It's been the best I've found so far.

False positives for 1 syllable

Using this with sentencer.js to create a random phrase generator with the option to restrict the number of syllables per word.

import Sentencer from 'sentencer';
import Syllable from 'syllable';

function getWordsWithSyllables(num, words) {
    return words.filter(function(word) {
        return Syllable(word) === num;
    });
};
   
console.log(getWordsWithSyllables(1, Sentencer._adjectives));

Results in the following output:

[
  "aged",
  "ain",
  "air",
  "bar",
  "beauish", // 2 syllables
  "biped", // 2 syllables
  "bluest", // 2 syllables
  "bluish", // 2 syllables
  "bomb",
  "broch",
  "brute",
  "chill",
  "chin",
  "crooked", // 2 syllables
  "cruel",
  "crying", // 2 syllables
  "cursed",
  "cussed",
  "dam",
  "deuced",
  "dun",
  "dying", // 2 syllables
  "freest", // 2 syllables
  "gluey", // 2 syllables
  "grave",
  "here",
  "hyoid", // 2 syllables
  "jasp",
  "jet",
  "laic",
  "learned",
  "liege",
  "louvred",
  "lying", // 2 syllables
  "male",
  "man",
  "measled", // 2 syllables
  "mere",
  "meshed",
  "mis",
  "naif",
  "naive", // 2 syllables
  "pan",
  "par",
  "pass",
  "peaked",
  "prying", // 2 syllables
  "pyoid", // 2 syllables
  "said",
  "saut",
  "shredless", // 2 syllables
  "store",
  "theist", // 2 syllables
  "toey", // 2 syllables
  "treen", // 2 syllables
  "vying", // 2 syllables
  "weest" // 2 syllables
]

English is weird! Admittedly, I had to look up the pronunciation for a number of these.

Feature request: syllablize()

Hi, Words team,

I appreciate your work. The syllable module is super good.

However, I wish to syllable have this function for creating readability texts.

syllablize('beautiful') // output: ['beau', 'ti', 'ful']

I think it's not too hard to create this function with your algorithm.

Thank you so much!

Best regards,
Vien Dinh.

Use div class instead of textarea

I'm using a wysiwyg editor and it doesn't use textarea. Your index.js code works great if I target a textarea, but as soon as I change the querySelector to a class, like .myeditor, then E is no longer a function according to my console error.

The index.js file I'm trying to use is from the demo: https://words.github.io/syllable/index.js

I know this isn't an "issue" and github isn't necessarily meant for support like this but I thought I'd give this a shot.

[aeiouy]nse$

'expanse', 'tense', 'expense', 'rinse', 'response'

PR forthcoming

ERR_REQUIRE_ESM: Must use import (I am using import)

Getting this:

Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/syllable/index.js from extendToMinimumLength.ts not supported.
Instead change the require of index.js in extendToMinimumLength.ts to a dynamic import() which is available in all CommonJS modules.

But I am using import?

Oneway is three syllables instead of 2

I think it's because of

// Count multiple consonants.
parts = value.split(/[^aeiouy]+/)

and ay is counted as a vowel split, so we ended up with
parts [ 'o', 'e', 'ay' ]

There's no consonant before the o.

Make syllable work in browser?

I wasn't able to make this work in the browser (because normalize-strings uses require).

I was able to browserify it but it was a bit tricky, the command I used is as follows:

browserify index.js -p esmify -s syllable -o syllable-browser.js

That creates a global variable called syllable that you can use like syllable.syllable(word). Not the most elegant but just wanted something quick and dirty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.