commit 26698e8622e9335e0ceaab922b4206574b0a40fa
parent 59109988a626737a9613fc5ed66b52987bb0bd73
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Sat, 1 Feb 2014 13:22:46 +0100
configurable threshold
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/verse.py b/verse.py
@@ -75,9 +75,10 @@ class Verse:
if 'text_pron' not in x.keys() else x['text']
for x in self.chunks).lstrip().rstrip()
- def __init__(self, line, template, pattern):
+ def __init__(self, line, template, pattern, threshold=None):
self.template = template
self.pattern = pattern
+ self.threshold = threshold
# will be updated later, used in parse and feminine
self.phon = None
self.possible = None
@@ -280,7 +281,8 @@ class Verse:
def possible_weights(self, pos):
if self.template.options['diaeresis'] == "classical":
- return vowels.possible_weights_ctx(self.chunks, pos)
+ return vowels.possible_weights_ctx(self.chunks, pos,
+ threshold=self.threshold)
elif self.template.options['diaeresis'] == "permissive":
return vowels.possible_weights_approx(self.chunks[pos]['text'])
diff --git a/vowels.py b/vowels.py
@@ -24,7 +24,7 @@ def contains_trema(chunk):
return True
return False
-threshold = 10
+default_threshold = 12
def make_query(chunks, pos):
cleared = [clear(x) for x in chunks]
@@ -39,7 +39,10 @@ def make_query(chunks, pos):
''.join(cleared[pos+1:]),
''.join([x[::-1] for x in cleared[:pos][::-1]]))
-def possible_weights_ctx(chunks, pos):
+def possible_weights_ctx(chunks, pos, threshold=None):
+ global default_threshold
+ if not threshold:
+ threshold = default_threshold
from diaeresis import lookup
chunk = chunks[pos]
q = make_query(chunks, pos)