Advertisement
Woolfer0097

Untitled

Apr 16th, 2021
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import pymorphy2
  2. import sys
  3.  
  4. access = 'йцукенгшщзхъфывапролджэячсмитьбю-–— \n'
  5.  
  6. morph = pymorphy2.MorphAnalyzer()
  7. count = 0
  8.  
  9. result = list()
  10. result_l = list()
  11. result_s = set()
  12.  
  13. newdata = ' '
  14. data = list(map(str.strip, sys.stdin))
  15. for text in data:
  16.     for i in text:
  17.         if i.lower() not in ' абвгдеёжзийклмнопрстуфхцчшщъыьэюя' or i == '\n' or i == '\v' or i == '\t':
  18.             text = text.replace(i, ' ').lower()
  19.     newdata += text + ' '
  20. newdata = newdata.split()
  21.  
  22. for i in newdata:
  23.     item = morph.parse(i)[0]
  24.     rate = 0
  25.     if 'NOUN' == item.tag.POS and item.score > 0.5:
  26.         result_l.append(item.normal_form)
  27.         result_s.add(item.normal_form)
  28.  
  29. for j in result_s:
  30.     result.append([j, result_l.count(j)])
  31.  
  32. result.sort(key=lambda x: (x[1], x[0]), reverse=True)
  33.  
  34. print(*list(map(lambda x: x[0], result[:10])))
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement