From 320fc9a58fa02fba5a181a81d154227aa623bb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Ignacio=20Ria=C3=B1o?= Date: Sun, 1 Sep 2019 00:02:56 +0200 Subject: [PATCH] =?UTF-8?q?fix(spa):=20fix=20for=20Spanish=20words=20whose?= =?UTF-8?q?=20last=20vowel=20has=20an=20accent=20(e.g:=20=C3=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inflector/rules/spanish.py | 4 ++-- tests_es.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/inflector/rules/spanish.py b/inflector/rules/spanish.py index 2d95fb1..575961b 100644 --- a/inflector/rules/spanish.py +++ b/inflector/rules/spanish.py @@ -89,7 +89,7 @@ def pluralize(self, word): replacement = rule[1] if re.match('\|', replacement): for k in range(1, len(groups)): - replacement = replacement.replace('|' + k, self.string_replace(groups[k - 1], 'ÁÉÍÓÚáéíóú', 'AEIOUaeio')) + replacement = replacement.replace('|' + str(k), self.string_replace(groups[k - 1], 'ÁÉÍÓÚáéíóú', 'AEIOUaeiou')) result = re.sub(rule[0], replacement, word) # Esto acentúa los sustantivos que al pluralizarse se @@ -149,7 +149,7 @@ def singularize(self, word): replacement = rule[1] if re.match('~', replacement): for k in range(1, len(groups)): - replacement = replacement.replace('~' + k, self.string_replace(groups[k - 1], 'AEIOUaeio', 'ÁÉÍÓÚáéíóú')) + replacement = replacement.replace('~' + str(k), self.string_replace(groups[k - 1], 'AEIOUaeiou', 'ÁÉÍÓÚáéíóú')) result = re.sub(rule[0], replacement, word) # Esta es una posible solución para el problema de dobles diff --git a/tests_es.py b/tests_es.py index 55cf732..39923e3 100755 --- a/tests_es.py +++ b/tests_es.py @@ -62,20 +62,20 @@ class SpanishInflectorTestCase(unittest.TestCase): } def setUp(self): - self.inflector = Inflector(Spanish) + self.inflector = Inflector(Spanish()) def tearDown(self): self.inflector = None def test_pluralize(self): - for singular, plural in self.singular_to_plural.iteritems(): + for singular, plural in self.singular_to_plural.items(): inflector_pluralize = self.inflector.pluralize(singular) assert inflector_pluralize == plural, \ 'Spanish Inflector pluralize(%s) should produce "%s" and NOT "%s"' % ( singular, plural, inflector_pluralize) def test_singularize(self): - for singular, plural in self.singular_to_plural.iteritems(): + for singular, plural in self.singular_to_plural.items(): inflector_singularize = self.inflector.singularize(plural) assert inflector_singularize == singular, \ 'Spanish Inflector singularize(%s) should produce "%s" and NOT "%s"' % (