godzilla3000
godzilla3000

Reputation: 246

Is there anyway in python to count syllables without the use of a dictionary?

CMUdict works for the english language, but what if I want to count the syllables of content in another language?

Upvotes: 3

Views: 2042

Answers (3)

Ben
Ben

Reputation: 71535

You certainly can't do it in a general way for all languages, because different languages render sounds to text differently.

For example, the Hungarian word "vagy" looks like 2 syllables to an English speaker, but it's only one. And the English word "bike" would naturally be read as 2 syllables by speakers of many other languages.

Furthermore, for English you probably can't do this very accurately without a dictionary anyway, because English has so much bizarre variation in its spelling. For example, we pronounce the "oe" in "poet" as two distinct syllables, but only one in "does". This is probably true of some other languages as well.

Upvotes: 0

jdotjdot
jdotjdot

Reputation: 17072

This depends on the language. This may sound like an obvious answer, but it all comes down to how the orthography is designed. In English, syllables are pretty much independent of how the words are written, so you'd need a dictionary. Many other languages are like this.

Certain other languages though (like (South) Korean, Japanese Hiragana and Katakana (but not Kanji)) are written in such a way that the characters themselves are obviously matched up with a syllable or a specific number of syllables. In that case, if you know how those languages work, you could theoretically use Python to break the writing up into syllables.

Otherwise, you'd need a dictionary, or some other compling platform that takes care of this. Poke around nltk and see what you can find.

Upvotes: 4

BrenBarn
BrenBarn

Reputation: 251428

In general, no. For some languages there might be, but if you don't have a dictionary you'd need knowledge of those languages' linguistic structure. How words are divided into syllables varies from language to language.

Upvotes: 2

Related Questions