commit aa6360e7fefee67b45c98b201e37831d4a53032b
parent 5029312ce955ce1e80c65e6d1f52c7c3eea8b54b
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Wed, 14 Mar 2012 02:39:04 +0100
bugfix
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/template.py b/template.py
@@ -56,7 +56,7 @@ class Template:
ok = False
if ok and c == pattern.length:
return 0
- return (len(hemis.keys())*abs(pattern.length - c)
+ return ((1+len(hemis.keys()))*abs(pattern.length - c)
+ sum([1 for x in hemis.values() if x != "ok"]))
def match(self, line):
@@ -87,11 +87,14 @@ class Template:
pattern.constraint)
else:
# update the rhyme
- old = self.env[pattern.myid]
+ old_p = self.env[pattern.myid].phon
+ old_e = self.env[pattern.myid].eye
self.env[pattern.myid].feed(normalize(line), pattern.constraint)
# no more possible rhymes, something went wrong
if not self.env[pattern.myid].satisfied():
- errors.append(error.ErrorBadRhymeSound(old, None))
+ self.env[pattern.myid].phon = old_p
+ self.env[pattern.myid].eye = old_e
+ errors.append(error.ErrorBadRhymeSound(self.env[pattern.myid], None))
# rhyme genres
# inequality constraint