def setUp(self): self.dictionary = Dictionary() self.dictionary.add_word(Noun.create_from_baseword(morph, u'обезьянка')) self.dictionary.add_word(Noun.create_from_baseword(morph, u'тень')) self.dictionary.add_word(Adjective.create_from_baseword(morph, u'глупый')) self.dictionary.add_word(Verb.create_from_baseword(morph, u'ударил')) self.dictionary.add_word(Verb.create_from_baseword(morph, u'подставил')) self.dictionary.add_word(Adjective.create_from_baseword(morph, u'целый'))
def test_serialization(self): noun_1 = Noun.create_from_baseword(morph, u'обезьянка') data = noun_1.serialize() noun_2 = Noun.deserialize(data) self.assertEqual(noun_1.normalized, noun_2.normalized) self.assertEqual(noun_1.forms, noun_2.forms) self.assertEqual(noun_1.properties, noun_2.properties)
def test_serialization(self): noun_1 = Noun.create_from_baseword(morph, u'обезьянка') data = noun_1.serialize() noun_2 = Noun.deserialize(data) self.assertEqual(noun_1.normalized , noun_2.normalized) self.assertEqual(noun_1.forms, noun_2.forms) self.assertEqual(noun_1.properties, noun_2.properties)
def setUp(self): self.dictionary = Dictionary() self.dictionary.add_word(Noun.create_from_baseword( morph, u'обезьянка')) self.dictionary.add_word(Noun.create_from_baseword(morph, u'тень')) self.dictionary.add_word( Adjective.create_from_baseword(morph, u'глупый')) self.dictionary.add_word(Verb.create_from_baseword(morph, u'ударил')) self.dictionary.add_word(Verb.create_from_baseword( morph, u'подставил')) self.dictionary.add_word( Adjective.create_from_baseword(morph, u'целый'))
def test_create_from_baseword(self): noun = Noun.create_from_baseword(morph, u'обезьянка') self.assertEqual(noun.normalized, u'обезьянка') self.assertEqual(noun.properties, (u'жр', )) self.assertEqual( noun.forms, (u'обезьянка', u'обезьянки', u'обезьянке', u'обезьянку', u'обезьянкой', u'обезьянке', u'обезьянки', u'обезьянок', u'обезьянкам', u'обезьянок', u'обезьянками', u'обезьянках'))
def test_create_from_baseword(self): noun = Noun.create_from_baseword(morph, u'обезьянка') self.assertEqual(noun.normalized, u'обезьянка') self.assertEqual(noun.properties, (u'жр',)) self.assertEqual(noun.forms, (u'обезьянка', u'обезьянки', u'обезьянке', u'обезьянку', u'обезьянкой', u'обезьянке', u'обезьянки', u'обезьянок', u'обезьянкам', u'обезьянок', u'обезьянками', u'обезьянках'))
def setUp(self): self.monkey = Noun.create_from_baseword(morph, u'обезьянка') self.silly = Adjective.create_from_baseword(morph, u'глупый') self.hit = Verb.create_from_baseword(morph, u'ударил')
def test_pluralize(self): noun = Noun.create_from_baseword(morph, u'монета') self.assertEqual(noun.normalized, u'монета') self.assertEqual(noun.pluralize(1, Args()), u'монета') self.assertEqual(noun.pluralize(2, Args()), u'монеты') self.assertEqual(noun.pluralize(3, Args()), u'монеты') self.assertEqual(noun.pluralize(5, Args()), u'монет') self.assertEqual(noun.pluralize(10, Args()), u'монет') self.assertEqual(noun.pluralize(11, Args()), u'монет') self.assertEqual(noun.pluralize(12, Args()), u'монет') self.assertEqual(noun.pluralize(21, Args()), u'монета') self.assertEqual(noun.pluralize(33, Args()), u'монеты') self.assertEqual(noun.pluralize(36, Args()), u'монет') self.assertEqual(noun.pluralize(113, Args()), u'монет') self.assertEqual(noun.pluralize(9003, Args()), u'монеты') self.assertEqual(noun.pluralize(1, Args(u'рд')), u'монеты') self.assertEqual(noun.pluralize(2, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(3, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(5, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(10, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(11, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(12, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(21, Args(u'рд')), u'монеты') self.assertEqual(noun.pluralize(33, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(36, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(113, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(9003, Args(u'рд')), u'монет') self.assertEqual(noun.pluralize(1, Args(u'вн')), u'монету') self.assertEqual(noun.pluralize(2, Args(u'вн')), u'монеты') self.assertEqual(noun.pluralize(3, Args(u'вн')), u'монеты') self.assertEqual(noun.pluralize(5, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(10, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(11, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(12, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(21, Args(u'вн')), u'монету') self.assertEqual(noun.pluralize(33, Args(u'вн')), u'монеты') self.assertEqual(noun.pluralize(36, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(113, Args(u'вн')), u'монет') self.assertEqual(noun.pluralize(9003, Args(u'вн')), u'монеты') self.assertEqual(noun.pluralize(1, Args(u'дт')), u'монете') self.assertEqual(noun.pluralize(2, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(3, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(5, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(10, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(11, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(12, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(21, Args(u'дт')), u'монете') self.assertEqual(noun.pluralize(33, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(36, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(113, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(9003, Args(u'дт')), u'монетам') self.assertEqual(noun.pluralize(1, Args(u'тв')), u'монетой') self.assertEqual(noun.pluralize(2, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(3, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(5, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(10, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(11, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(12, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(21, Args(u'тв')), u'монетой') self.assertEqual(noun.pluralize(33, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(36, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(113, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(9003, Args(u'тв')), u'монетами') self.assertEqual(noun.pluralize(1, Args(u'пр')), u'монете') self.assertEqual(noun.pluralize(2, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(3, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(5, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(10, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(11, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(12, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(21, Args(u'пр')), u'монете') self.assertEqual(noun.pluralize(33, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(36, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(113, Args(u'пр')), u'монетах') self.assertEqual(noun.pluralize(9003, Args(u'пр')), u'монетах')
def test_normal_form(self): self.assertRaises(NormalFormNeeded, Noun.create_from_baseword, morph, u'обезьянки') Noun.create_from_baseword(morph, u'ножницы')
def test_get_form(self): noun = Noun.create_from_baseword(morph, u'обезьянка') self.assertEqual(noun.get_form(Args(u'рд', u'мн')), u'обезьянок') self.assertEqual(noun.get_form(Args(u'дт', u'ед')), u'обезьянке')