Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for c in chars:
- if c in event.text:
- event.text = event.text.replace(c, "")
- for symbol in symbols:
- if symbol in event.text.lower():
- event.text = event.text.lower().replace(symbol, syllables[symbols.index(symbol)])
- a = event.text.lower()
- b = "Привет"
- n, m = len(a), len(b)
- if n > m:
- a, b = b, a
- n, m = m, n
- current_row = range(n+1)
- for i in range(1, m+1):
- previous_row, current_row = current_row, [i]+[0]*n
- for j in range(1,n+1):
- add, delete, change = previous_row[j]+1, current_row[j-1]+1, previous_row[j-1]
- if a[j-1] != b[i-1]:
- change += 1
- current_row[j] = min(add, delete, change)
- message = "Прости, не понимаю тебя."
- distance = len(a)
- a1 = 0
- d1 = 0
- c1 = 0
- if current_row[add] != distance + 1:
- if current_row[add] <= distance + 1:
- a1 = 1
- elif current_row[add] > distance + 1:
- a1 = 2
- if current_row[delete] != distance:
- if current_row[delete] <= distance:
- d1 = 1
- elif current_row[delete] > distance:
- d1 = 2
- if current_row[change] != distance + 1:
- if current_row[change] <= distance:
- c1 = 1
- elif current_row[change] > distance:
- c1 = 2
- 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: # И так далее, после решения проблемы с переменными допишу остальные варианты "правильного слова"
- message = 'Я понял ваш запрос как "%s"nn' % 'Привет' + message
- print(message, end='')
- print(str(a1),str(d1),str(c1))
- break
- else:
- print(message, end='')
- print(str(a1),str(d1),str(c1))
- break
Add Comment
Please, Sign In to add comment