1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# use nosetest to run these tests
from nose.tools import eq_
import inflect
FNAME = 'tests/words.txt'
# FNAME = 'tests/list-of-nouns.txt'
# FNAME = '/usr/share/dict/british-english'
# FNAME = 'tricky.txt'
def getwords():
words = open(FNAME).readlines()
words = [w.strip() for w in words]
return words
def test_pl_si():
p = inflect.engine()
words = getwords()
for word in words:
if word == '':
continue
if word[-2:] == "'s":
continue
# if word[-1] == 's':
# continue
p.classical(all=False)
yield check_pl_si, p, word
p.classical(all=True)
yield check_pl_si, p, word
def check_pl_si(p, word):
if p.singular_noun(p.plural_noun(word, 2), 1) != word:
f = open('badsi.txt', 'a')
f.write('%s %s %s\n' % (word, p.plural_noun(word, 2),
p.singular_noun(p.plural_noun(word, 2), 1)))
f.close()
eq_(p.singular_noun(p.plural_noun(word, 2), 1), word,
msg='''word==%s
plnoun(%s)==%s
sinoun(%s)==%s''' % (word,
word, p.plural_noun(word, 2),
p.plural_noun(word, 2), p.singular_noun(p.plural_noun(word, 2), 1)))
|