software for syllable separation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

software for syllable separation

Eduardo Vieira
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
 
 

_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: software for syllable separation

Daniel Johnson-2
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
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: software for syllable separation

Bertalan Fodor
In reply to this post by Eduardo Vieira
LilyPondTool for jEdit provides this, using OpenOffice dictionaries.
However, the macro for it included is buggy, so you should use the
attached BeanShell macro (it is very simple to use, just copy into the
jEdit/macros directory, select the text to hyphenate and start from
Macros>Hyphenate).
Due to another bug you must restart jEdit after changing the OpenOffice
dictionary setting (I have the dictionaries at C:\Program
Files\OpenOffice.org 2.0\share\dict\ooo).

So, if you succed with install (it is easy!) it would hyphenate like this:

Are you walk -- ing alone through the shad -- ows dim?

So you must do manual hyphenation as well, because hyphenation is not
for singing but for typesetting flow text. (That's why it doesn't make
one-character syllables.)
But it is still much better than nothing. In a future version, I think
we could handle this one-letter-syllable issue.

You can get bad result with e.g. German, if you use the German
hyphenation dict., but will get better, if you use the English
dictionary for the German text:
German:
Es ist nun nichts Ver -- damm -- li -- ches an denen, die in Christo
Jesu sind, die nicht
nach dem Fleische wandeln, son -- dern nach dem Geist
English:
Es ist nun nichts Ver -- damm -- lich -- es an de -- nen, die in Chris
-- to Je -- su sind, die nicht
nach dem Fleis -- che wan -- deln, son -- dern nach dem Geist

*Still not perfect. But only one fault (or two, I dunno).
*
Bert

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 is a temporary macro. First, check over the
// commands to make sure this is what you intended.
// Then, to run this macro, switch to the buffer
// where you would like to execute it and press C+m C+p.

import mt.org.linux.textcheck.HyphEngine;

import lilytool.lyrics.HyphenUtils;

import lilytool.macrohelp.InputDialog;
import lilytool.LilyToolPlugin;
import lilytool.console.LilyPondShell;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

dlg=new InputDialog("Hyphenation", view);
language=jEdit.getProperty(LilyToolPlugin.OPTION_PREFIX + "lyrics.language");
locales=HyphenUtils.getAvailableLocales();
s=new ArrayList();
for (locale : locales) s.add(locale.getDisplayName());
Collections.sort(s);
dlg.addInput("Language:", "language", language, s.toArray(), false);
dlg.show();

vars=dlg.getContext();
if (!vars.get("cancelled")) {
        language=vars.get("language");
       
        jEdit.setProperty(LilyToolPlugin.OPTION_PREFIX + "lyrics.language", language);
        for (l : locales) {
                if (l.getDisplayName().equals(language)) {
                        locale=l; break;
                }
        }
       
        text=textArea.getSelectedText();
        if (text!=null) {
                hText=HyphenUtils.hyphenate(text, locale);
                // {{{ Hungarian double consonants
                if (language.equals("magyar")) {
                        hText = hText.replaceAll("ccs", "cs-cs");
                        hText = hText.replaceAll("ddz", "dz-dz");
                        hText = hText.replaceAll("ddzs", "dzs-dzs");
                        hText = hText.replaceAll("ggy", "gy-gy");
                        hText = hText.replaceAll("lly", "ly-ly");
                        hText = hText.replaceAll("nny", "ny-ny");
                        hText = hText.replaceAll("tty", "ty-ty");
                        hText = hText.replaceAll("ssz", "sz-sz");
                        hText = hText.replaceAll("zzs", "zs-zs");
                }
                // }}}
                hText = hText.replace(HyphEngine.SOFT_HYPHEN, '-');
                hText = hText.replaceAll("-", " -- ");
                textArea.setSelectedText(hText);
        }
}

_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: software for syllable separation

Eduardo Vieira
Thank you, Bertalan.
I think what you presented is just what I was looking for. I said, "think"
because I couldn't test it. I put the file
hyphenate.bsh in the folder macros, as you instructed. But when I run the
macro, there appear a dialog box to select the language but there is no
language listed in. So nothing happens. How do I tell jEdit to find the
dictionary or language information?
I'm using Windows Me and my Open Office dictionary is located in C:\Arquivos
de Programas\OpenOffice.org 1.9.122\share\dict\ooo\
jEdit is installed in C:\Arquivos de Programas\

Quote:
> So, if you succed with install (it is easy!) it would hyphenate like this:
>
> Are you walk -- ing alone through the shad -- ows dim?
It looks good to me, because I want to use it for Lilypond, anyway. When I
need it for typesetting abc files, I
can run a "search and replace":


Eduardo Vieira

----- Original Message -----
From: "Bertalan Fodor" <[hidden email]>
To: "Eduardo Vieira" <[hidden email]>
Cc: "lilypond-user" <[hidden email]>
Sent: Wednesday, December 21, 2005 8:38 PM
Subject: Re: software for syllable separation


> LilyPondTool for jEdit provides this, using OpenOffice dictionaries.
> However, the macro for it included is buggy, so you should use the
> attached BeanShell macro (it is very simple to use, just copy into the
> jEdit/macros directory, select the text to hyphenate and start from
> Macros>Hyphenate).
> Due to another bug you must restart jEdit after changing the OpenOffice
> dictionary setting (I have the dictionaries at C:\Program
> Files\OpenOffice.org 2.0\share\dict\ooo).
>
> So, if you succed with install (it is easy!) it would hyphenate like this:
>
> Are you walk -- ing alone through the shad -- ows dim?
>
> So you must do manual hyphenation as well, because hyphenation is not
> for singing but for typesetting flow text. (That's why it doesn't make
> one-character syllables.)
> But it is still much better than nothing. In a future version, I think
> we could handle this one-letter-syllable issue.
>
> You can get bad result with e.g. German, if you use the German
> hyphenation dict., but will get better, if you use the English
> dictionary for the German text:
> German:
> Es ist nun nichts Ver -- damm -- li -- ches an denen, die in Christo
> Jesu sind, die nicht
> nach dem Fleische wandeln, son -- dern nach dem Geist
> English:
> Es ist nun nichts Ver -- damm -- lich -- es an de -- nen, die in Chris
> -- to Je -- su sind, die nicht
> nach dem Fleis -- che wan -- deln, son -- dern nach dem Geist
>
> *Still not perfect. But only one fault (or two, I dunno).
> *
> Bert
>



_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: software for syllable separation

Bertalan Fodor
Eduardo Vieira wrote:

>Thank you, Bertalan.
>I think what you presented is just what I was looking for. I said, "think"
>because I couldn't test it. I put the file
>hyphenate.bsh in the folder macros, as you instructed. But when I run the
>macro, there appear a dialog box to select the language but there is no
>language listed in. So nothing happens. How do I tell jEdit to find the
>dictionary or language information?
>I'm using Windows Me and my Open Office dictionary is located in C:\Arquivos
>de Programas\OpenOffice.org 1.9.122\share\dict\ooo\
>jEdit is installed in C:\Arquivos de Programas\
>
>  
>
Go to Plugins>Plugin Options>LilyPondTool and set the OpenOffice dict.
place, and restart jEdit.



_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user