commit e3450cac6e652683a4917913e298d7d8178147e9
parent 39ba6402b2d72e508a4c33f43e8889c933b6858d
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Thu, 17 Aug 2017 01:10:45 +0200
elide inside words also for unaspirated h
Diffstat:
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/TODO b/TODO
@@ -1,6 +1,3 @@
-should be accepted (elision should also occur within compound words):
-"Le navire, doublant le cap de Sainte-Hélène"
-
"pays" and "paysage": "payse", "abbaye"
should be rejected (hemistiche is broken):
diff --git a/verse.py b/verse.py
@@ -177,6 +177,21 @@ class Verse:
for i, w in enumerate(word[:-1]):
if w['text'] == "e-":
w['weights'] = [0] # force elision
+ if (w['text'] == "e" and i < len(word) - 1 and
+ word[i+1]['text'].startswith("-h")):
+ # collect what follows until the next hyphen or end
+ flw = word[i+1]['original'].split('-')[1]
+ ii = i+2
+ while ii < len(word):
+ flw += word[ii]['original'].split('-')[0]
+ if '-' in word[ii]['original']:
+ break
+ ii += 1
+ # TODO: not sure if this reconstruction of the original word is bulletproof...
+ if haspirater.lookup(normalize(flw)):
+ w['weights'] = [0]
+ else:
+ w['weights'] = [1]
# remove leading and trailing crap
for w in self.chunks:
diff --git a/versetest.py b/versetest.py
@@ -151,6 +151,13 @@ class ExceptionCounts(Counts):
f = self.runCount("porte-avions porte-avions", limit=6)
self.assertEqual(1, len(f))
self.assertEqual(self.getWeight(f[0]), 6)
+
+ def testSainteHelene(self):
+ # from "Les Trophées", José-Maria de Heredia
+ text = "Le navire, doublant le cap de Sainte-Hélène,"
+ f = self.runCount(text, limit=12)
+ self.assertEqual(1, len(f))
+ self.assertEqual(self.getWeight(f[0]), 12)
class AspiratedCounts(Counts):
def testBaudelaire1half(self):