plint

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

commit 6d538774d19a7aa764c95d2c9cfa389204c24632
parent 8b48d874b21135edb349c43e56e46956de5bc48c
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat,  7 Jul 2012 01:35:16 +0200

add check_occurrences

Diffstat:
template.py | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/template.py b/template.py @@ -48,6 +48,7 @@ class Template: self.forbidden_ok = False self.normande_ok = True self.check_end_hemistiche = True + self.check_occurrences = True self.diaeresis = "classical" self.mergers = [] self.load(string) @@ -73,6 +74,8 @@ class Template: raise ValueError elif key == "check_end_hemistiche": self.check_end_hemistiche = str2bool(value) + elif key == "check_occurrences": + self.check_occurrences = str2bool(value) else: raise ValueError @@ -182,15 +185,16 @@ class Template: print((str(x[0]) + ' ' + ' '.join(x[1])), file=ofile) # occurrences - if pattern.myid not in self.occenv.keys(): - self.occenv[pattern.myid] = {} - last_word = line_with_case.split(' ')[-1] - if last_word not in self.occenv[pattern.myid].keys(): - self.occenv[pattern.myid][last_word] = 0 - self.occenv[pattern.myid][last_word] += 1 - if self.occenv[pattern.myid][last_word] > nature_count(last_word): - errors.append(error.ErrorMultipleWordOccurrence(last_word, - self.occenv[pattern.myid][last_word])) + if self.check_occurrences: + if pattern.myid not in self.occenv.keys(): + self.occenv[pattern.myid] = {} + last_word = line_with_case.split(' ')[-1] + if last_word not in self.occenv[pattern.myid].keys(): + self.occenv[pattern.myid][last_word] = 0 + self.occenv[pattern.myid][last_word] += 1 + if self.occenv[pattern.myid][last_word] > nature_count(last_word): + errors.append(error.ErrorMultipleWordOccurrence(last_word, + self.occenv[pattern.myid][last_word])) # rhyme genres # inequality constraint