python 3.10
щось таке зробив)
upd: трішки змінив
select_word = ""
text = """
"""
search_word_list = list(select_word)
data_text = text.split()
coincidence_words = []
coincidence_words_nums = []
duralisity = 1.2
while(1):
procent_coincidence = len(search_word_list) * duralisity #чутливість
for word in data_text:
procent_coincidence_to_seach_word = 0
word_list = list(word)
for i in range(len(word_list) - 1):
if word_list[i] == "." or word_list[i] == ",":
word_list.remove(word_list[i])
for i in range(len(word_list) - 1):
if word_list[i] in search_word_list:
procent_coincidence_to_seach_word += 0.3
try:
if word_list[i] == search_word_list[i]:
procent_coincidence_to_seach_word += 0.5
except Exception:
pass
if procent_coincidence_to_seach_word > procent_coincidence and procent_coincidence_to_seach_word < procent_coincidence * 1.4:
if not(word in coincidence_words):
coincidence_words.append(word)
if len(word_list) > len(search_word_list):
procent_coincidence_to_seach_word -= 2
procent_coincidence_to_seach_word = round(procent_coincidence_to_seach_word, 0)
coincidence_words_nums.append(procent_coincidence_to_seach_word)
if len(coincidence_words) < 6:
duralisity -= 0.1
else:
break
max_num = 0
max_num_word = ''
for i in range(len(coincidence_words_nums)-1):
if max_num < coincidence_words_nums[i]:
max_num = coincidence_words_nums[i]
max_num_word = coincidence_words[i]
print(coincidence_words)
print(f"\nyou seach: {select_word}\nmax coincidence word: {max_num_word}")
Результат:
['symbolically.', 'symbolism', 'symbols,', 'symbols', 'Symbolic', 'symbol']
you seach: symbolize
max coincidence word: symbolism