Eduardo Vieira wrote:

> Hello users!
>  
> Does anybody know of a program that would make a syllable separation
> (hyphenation) of text to do something
> like this:
>  
> "Are you walking alone through the shadows dim?"
>  
> would be automatically converted to:
>  
> "Are you walk-ing a-lone through the shad-ows dim?"
>  
> This would be nice in working with lyrics.
>  
>  
> Best regards,
>  
> Eduardo Vieira
>  

This python script was posted to another list to which I subscribe.  It
should hyphenate a single word (passed on the command line) according to
the usage given on dictionary.com.  You might use this as the basis for
a larger script which could return the hyphenation rules for an entire
paragraph.

import sys, urllib, re

word = sys.argv[1]

url = "http://dictionary.reference.com/search?q="; + word

f = urllib.urlopen(url)
page = f.read()
f.close()

all = re.findall(r"<[bB]>(.+?&#183;.+?)</[bB]>", page)
for t in all:
    print re.sub(r"<IMG.+?>|&#183;", "-", t).rstrip(",")


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to