Skip to content

Commit

Permalink
Fixed formatting and the new tests, updated change log
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Grönholm committed Jun 17, 2013
1 parent ff8065c commit 39ee1da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
ver 0.2.5

* Fixed TypeError while parsing compounds (by yavarhusain)


ver 0.2.4

Expand Down
10 changes: 5 additions & 5 deletions inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class BadGenderError(Exception):

__ver_major__ = 0
__ver_minor__ = 2
__ver_patch__ = 4
__ver_sub__ = ""
__ver_patch__ = 5
__ver_sub__ = "pre1"
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
__ver_patch__, __ver_sub__)

Expand Down Expand Up @@ -2324,16 +2324,16 @@ def _sinoun(self, word, count=None, gender=None):
for numword in range(1, len(lowersplit) - 1):
if lowersplit[numword] in pl_prep_list_da:
return ' '.join(lowersplit[:numword - 1] +
[self._sinoun(lowersplit[numword - 1], 1, gender=gender) or lowersplit[numword-1]] +
lowersplit[numword:])
[self._sinoun(lowersplit[numword - 1], 1, gender=gender) or
lowersplit[numword - 1]] + lowersplit[numword:])

lowersplit = lowerword.split('-')
if len(lowersplit) >= 3:
for numword in range(1, len(lowersplit) - 1):
if lowersplit[numword] in pl_prep_list_da:
return ' '.join(
lowersplit[:numword - 1] +
[(self._sinoun(lowersplit[numword - 1], 1, gender=gender) or lowersplit[numword-1]) +
[(self._sinoun(lowersplit[numword - 1], 1, gender=gender) or lowersplit[numword - 1]) +
'-' + lowersplit[numword] + '-']) + ' '.join(lowersplit[(numword + 1):])

# HANDLE PRONOUNS
Expand Down
31 changes: 17 additions & 14 deletions tests/test_compounds.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import unittest
from nose.tools import eq_

import inflect

class test(unittest.TestCase):
def test_compound_1(self):
self.assertEqual(p.singular_noun('hello-out-there'),'hello-out-there')
def test_compound_2(self):
self.assertEqual(p.singular_noun('hello out there'),'hello out there')
def test_compound_3(self):
self.assertEqual(p.singular_noun('continue-to-operate'),'continue-to-operate')
def test_compound_4(self):
self.assertEqual(p.singular_noun('case of diapers'),'case of diapers')

if __name__ == '__main__':
p=inflect.engine()
unittest.main()

class TestCompounds(object):
def setup(self):
self.p = inflect.engine()

def test_compound_1(self):
eq_(self.p.singular_noun('hello-out-there'), 'hello-out-there')

def test_compound_2(self):
eq_(self.p.singular_noun('hello out there'), 'hello out there')

def test_compound_3(self):
eq_(self.p.singular_noun('continue-to-operate'), 'continue-to-operate')

def test_compound_4(self):
eq_(self.p.singular_noun('case of diapers'), 'case of diapers')

0 comments on commit 39ee1da

Please sign in to comment.