Wednesday, May 29, 2013

splitting words into syllables with python

There is one very easy way to achieve it:

pip install pyhyphen

from hyphen import Hyphenator
from hyphen.dictools import *

for lang in ['es_MX', 'es_SP']:
        if not is_installed(lang): install(lang)
h_mx = Hyphenator('es_MX')
print h_mx.syllables(u"modernismo")

For more info:

https://pypi.python.org/pypi/PyHyphen/0.9.3

Just in case you wondered, I need this as I'm working on mastering a mnemonic system based on the phonetic sound of words.




No comments:

Post a Comment