Guest User

Untitled

a guest
Feb 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. for c in chars:
  2. if c in event.text:
  3. event.text = event.text.replace(c, "")
  4. for symbol in symbols:
  5. if symbol in event.text.lower():
  6. event.text = event.text.lower().replace(symbol, syllables[symbols.index(symbol)])
  7. a = event.text.lower()
  8. b = "Привет"
  9. n, m = len(a), len(b)
  10. if n > m:
  11. a, b = b, a
  12. n, m = m, n
  13. current_row = range(n+1)
  14. for i in range(1, m+1):
  15. previous_row, current_row = current_row, [i]+[0]*n
  16. for j in range(1,n+1):
  17. add, delete, change = previous_row[j]+1, current_row[j-1]+1, previous_row[j-1]
  18. if a[j-1] != b[i-1]:
  19. change += 1
  20. current_row[j] = min(add, delete, change)
  21. message = "Прости, не понимаю тебя."
  22. distance = len(a)
  23. a1 = 0
  24. d1 = 0
  25. c1 = 0
  26. if current_row[add] != distance + 1:
  27. if current_row[add] <= distance + 1:
  28. a1 = 1
  29. elif current_row[add] > distance + 1:
  30. a1 = 2
  31. if current_row[delete] != distance:
  32. if current_row[delete] <= distance:
  33. d1 = 1
  34. elif current_row[delete] > distance:
  35. d1 = 2
  36. if current_row[change] != distance + 1:
  37. if current_row[change] <= distance:
  38. c1 = 1
  39. elif current_row[change] > distance:
  40. c1 = 2
  41. if a1 == 1 and d1 == 1 and c1 == 0 or a1 == 1 and d1 == 1 and c1 == 1 or a1 == 0 and d1 == 1 and c1 == 0: # И так далее, после решения проблемы с переменными допишу остальные варианты "правильного слова"
  42. message = 'Я понял ваш запрос как "%s"nn' % 'Привет' + message
  43. print(message, end='')
  44. print(str(a1),str(d1),str(c1))
  45. break
  46. else:
  47. print(message, end='')
  48. print(str(a1),str(d1),str(c1))
  49. break
Add Comment
Please, Sign In to add comment