Skip to content

Instantly share code, notes, and snippets.

View sirovenmitts's full-sized avatar
:shipit:

Kenneth Pullen sirovenmitts

:shipit:
View GitHub Profile
@sirovenmitts
sirovenmitts / syllable-guessing.st
Last active December 18, 2015 08:09
Guess the number of syllables in a word. Not as good as looking up stuff from the CMU pronunciation dictionary...
"This is a naive implementation of syllable guessing. This is for Amber smalltalk. It probably works elsewhere with minor changes."
| word |
word := 'tumult' asLowercase.
word := word replaceRegexp: '(?:[^laeiouy]es|ed|[^laeiouy]e)$' with: ''.
word := word replaceRegexp: '^y' with: ''.
console log: ( word matchesOf: ( RegularExpression fromString: '[aeiouy]{1,2}' flag: 'g' ) ) size.
"Use the CMU Pronunciation Dictionary to determine the number and stress of syllables in a word. Obviously this only works with words that are in the dictionary."