plint

French poetry validator (local mirror of https://gitlab.com/a3nm/plint)
git clone https://a3nm.net/git/plint/
Log | Files | Refs | README

commit 7c3001505146c5b9356c2c26df3a7b9743f81b54
parent 48c62571db0d1fc8b1d5794523d6b583dd793ba4
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sun, 10 Jun 2012 20:05:21 +0200

better tolerance mechanism, add ai/é

Diffstat:
rhyme.py | 21+++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/rhyme.py b/rhyme.py @@ -28,7 +28,11 @@ liaison = { } tolerance = { - 'ï': 'i' + 'ï': 'i', + "ai": "é", + 'm': 'n', + 'à': 'a', + 'û': 'u', } @@ -129,10 +133,6 @@ def suffix(x, y): for i in range(bound): a = x[-(1+i)] b = y[-(1+i)] - if a in tolerance.keys(): - a = tolerance[a] - if b in tolerance.keys(): - b = tolerance[b] if a != b: return i return bound @@ -166,16 +166,13 @@ def concat_couples(a, b): return s def consonant_suffix(s): + for k in tolerance.keys(): + if s.endswith(k): + s = s[:-(len(k))] + tolerance[k] for i in range(len(s)): if not s[-(i+1)] in consonants: break - result = s[-(i+1):] - if result.endswith('m'): - result = result[:-1] + 'n' - if result.endswith('à'): - result = result[:-1] + 'a' - if result.endswith('û'): - result = result[:-1] + 'u' + result = s[-(i):] return result def raw_lookup(s):