Exemple #1
0
 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'целый'))
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
 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'целый'))
Exemple #5
0
 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'обезьянках'))
Exemple #6
0
 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'обезьянках'))
Exemple #7
0
 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'ударил')
Exemple #8
0
    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'монетах')
Exemple #9
0
 def test_normal_form(self):
     self.assertRaises(NormalFormNeeded, Noun.create_from_baseword, morph, u'обезьянки')
     Noun.create_from_baseword(morph, u'ножницы')
Exemple #10
0
 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'обезьянке')
Exemple #11
0
 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'ударил')
Exemple #12
0
    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'монетах')
Exemple #13
0
 def test_normal_form(self):
     self.assertRaises(NormalFormNeeded, Noun.create_from_baseword, morph,
                       u'обезьянки')
     Noun.create_from_baseword(morph, u'ножницы')
Exemple #14
0
 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'обезьянке')