songleash

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

common.py (584B)


      1 #!/usr/bin/python3
      2 
      3 import unicodedata
      4 
      5 # starting symbol, must be part of cycle
      6 start = (False, 'm@')
      7 vowels = 'io9@2EeaOy#$u()§°51'
      8 vowels_script = "aeiouy"
      9 semivowels = 'j8w'
     10 
     11 def fem(w):
     12     return ((w.endswith('e') and not w[-2] in "uié")
     13         or (w.endswith('es') and not w[-3] in "uié"))
     14 
     15 
     16 # http://stackoverflow.com/questions/517923/what-is-the-best-way-to-remove-accents-in-a-python-unicode-string
     17 def strip_accents(s):
     18   """Strip accent from a string
     19   
     20   with_except keeps specifically 'é' and 'è'"""
     21   return ''.join([unicodedata.normalize('NFD', x) for x in s])