This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "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." |