Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inflector/rules/spanish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"' % (
Expand Down