1 from syllabify
import *
4 def __init__(self
, language
='fr'):
5 self
.language
= language
7 def read_and_write(self
, file):
8 #file = open(filename, 'r')
9 sign_tokenizer
= SignTokenizer(language
=self
.language
)
10 syllable_tokenizer
= SyllableTokenizerWithWordSeparation()
12 verse_match
= re
.match(r
"^%#(\S*) (.*)$", line
)
15 verse
= Verse(verse_match
.group(2).strip())
16 verse
.syllabify(sign_tokenizer
, syllable_tokenizer
)
17 print(verse
.hyphenate(hyphen
= " -- ", add_space
= True))
22 if __name__
== '__main__':
23 parser
= argparse
.ArgumentParser(
24 description
='LilPond lyrics generation.',
25 formatter_class
=argparse
.ArgumentDefaultsHelpFormatter
)
29 help='verse language (fr, it)')
31 'files', metavar
='FILE',
32 type=argparse
.FileType('r'),
35 args
= vars(parser
.parse_args())
36 for file in args
['files']:
37 transformer
= Lyricsifier(args
['language'])
38 transformer
.read_and_write(file)