Example #1
0
 def is_correct(frm):
     correct = True
     if norm:
         correct = frm['norm'] == norm
     if method:
         correct = correct and (method in frm['method'])
     if cls:
         correct = correct and (frm['class'] == cls)
     if form:
         gram_filter = GramForm(form)
         gram_form = GramForm(frm['info'])
         correct = correct and gram_form.match(gram_filter)
     return correct
Example #2
0
 def test_lemma_graminfo(self):
     info = morph_ru.get_graminfo(u'СУСЛИКАМИ')
     self.assertEqual(len(info), 1)
     info = info[0]
     gram_form = GramForm(info['info'])
     self.assertEqual(gram_form.form, set([u'мр', u'тв', u'мн']))
     self.assertEqual(info['norm'], u'СУСЛИК')
Example #3
0
 def test_multi_form_change(self):
     form = GramForm(u'мн,рд,мр')
     form.update(u'дт,ед')
     self.assertTrue(u'дт' in form.form)
     self.assertTrue(u'ед' in form.form)
     self.assertFalse(u'рд' in form.form)
     self.assertFalse(u'мн' in form.form)
Example #4
0
 def test_form_str(self):
     form = GramForm(u'мр,мн,рд')
     self.assertTrue(form.get_form_string().count(u'мр') == 1)
     self.assertTrue(form.get_form_string().count(u'мн') == 1)
     self.assertTrue(form.get_form_string().count(u'рд') == 1)
     self.assertTrue(len(form.get_form_string()) == (2 * 3) + 2)
     form.update(u'дт')
     self.assertTrue(form.get_form_string().count(u'мр') == 1)
     self.assertTrue(form.get_form_string().count(u'мн') == 1)
     self.assertTrue(form.get_form_string().count(u'дт') == 1)
     self.assertTrue(len(form.get_form_string()) == (2 * 3) + 2)
Example #5
0
 def test_from_str(self):
     form = GramForm(u'мн,рд')
     self.assertTrue(u'рд' in form.form)
     self.assertTrue(u'мн' in form.form)
Example #6
0
 def test_match_inverted(self):
     form = GramForm(u"мр,ед,имя")
     self.assertFalse(form.match(GramForm(u"мр,!имя")))
     self.assertTrue(form.match(GramForm(u"ед,!тв")))
Example #7
0
 def test_match(self):
     form = GramForm(u"мр,ед,имя")
     self.assertTrue(form.match(GramForm(u"мр")))
     self.assertTrue(form.match(GramForm(u"ед,мр")))