songleash

generate chansons en laisse
git clone https://a3nm.net/git/songleash/
Log | Files | Refs

only3.py (979B)


      1 #!/usr/bin/python3
      2 
      3 from common import vowels, fem
      4 import re
      5 import sys
      6 
      7 for l in sys.stdin.readlines():
      8     f = l.split('\t')
      9     vowels_regexp = re.compile('([' + vowels + '])')
     10     f[-1] = f[-1].strip()
     11     if len(f) < 3:
     12         # f.append("")
     13         # only take words with complete syllabification in lexique
     14         continue
     15     if len(f[2].split('-')) != (4 if fem(f[0]) else 3):
     16         # garbled syllabification from lexique
     17         continue
     18     chunks = f[1].split('-')
     19     # words cannot start with a vowel
     20     # as last consonant before last vowel will be kept
     21     if chunks[0][0] in vowels:
     22         continue
     23     # sound preceding the last vowel sound must be a consonant
     24     if chunks[-1][-1] in vowels and (len(chunks[-1]) == 1 or chunks[-1][-2] in
     25             vowels):
     26         continue
     27     if (chunks[-1][-1] not in vowels and chunks[-1][-2] in vowels
     28             and (len(chunks[-1]) == 2 or chunks[-1][-3] in vowels)):
     29         continue
     30     print('\t'.join(f))
     31