Advertisement
1nikitas

Untitled

Mar 5th, 2022
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import pymorphy2
  2. morph = pymorphy2.MorphAnalyzer()
  3.  
  4. word = 'учиться'
  5. #word = morph.parse(word)[0].normal_form
  6. word = morph.parse(word)[0]
  7. print(word)
  8. pos = word.tag.POS
  9.  
  10. CASES = {
  11. ('past','<Прошедшее время>'):[
  12. {'masc'},{'femn'},{'neut'},{'plur'}
  13. ],
  14. ('pres','<Настоящее время>'):[
  15. {'1per','sing'},
  16. {'1per','plur'},
  17. {'2per','sing'},
  18. {'2per','plur'},
  19. {'3per','sing'},
  20. {'3per','plur'}
  21. ]
  22. }
  23.  
  24. if word.tag.POS in {'INFN','VERB'}:
  25. for key,val in CASES.items():
  26. print(key[1])
  27. for cases in val:
  28. cases.add(key[0])
  29. w = word.inflect(cases).word
  30. print(w)
  31.  
  32. else:
  33. print('Не глагол',pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement