Commits

ivirabyan committed fec0ceb

fixed numeral agreement of words in accusative case

Comments (0)

Files changed (2)

pymorphy2/tagset.py

 
     _NUMERAL_AGREEMENT_GRAMMEMES = (
         set(['sing', 'nomn']),
+        set(['sing', 'accs']),
         set(['sing', 'gent']),
         set(['plur', 'nomn']),
         set(['plur', 'gent']),
         if self.POS not in ('NOUN', 'ADJF', 'PRTF'):
             return set([])
 
-        if self.POS == 'NOUN' and self.case != 'nomn':
+        if self.POS == 'NOUN' and self.case not in ('nomn', 'accs'):
             if index == 0:
                 grammemes = set(['sing', self.case])
-            elif self.case == 'accs' and index == 2:
-                grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[3]
             else:
                 grammemes = set(['plur', self.case])
         elif index == 0:
-            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[0]
+            if self.case == 'nomn':
+                grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[0]
+            else:
+                grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[1]
         elif self.POS == 'NOUN' and index == 1:
-            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[1]
+            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[2]
         elif self.POS in ('ADJF', 'PRTF') and self.gender == 'femn' and index == 1:
-            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[2]
+            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[3]
         else:
-            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[3]
+            grammemes = self._NUMERAL_AGREEMENT_GRAMMEMES[4]
         return grammemes
 
 

tests/test_numeral_agreement.py

     ("книгу", 'accs', ["книгу", "книги", "книг"]),
     ("книгой", 'ablt', ["книгой", "книгами", "книгами"]),
     ("книге", 'loct', ["книге", "книгах", "книгах"]),
+
+    # ("час", "accs", ["час", "часа", "часов"]), https://github.com/kmike/pymorphy2/issues/32
+    ("день", "accs", ["день", "дня", "дней"]),
+    ("минуту", "accs", ["минуту", "минуты", "минут"]),
 ])
 def test_plural_inflected(word, case, result):
     parsed = [p for p in morph.parse(word) if p.tag.case == case]