সমস্যা বিবরণ
একটি শব্দ দেওয়া আছে। এর সাথে সবচেয়ে মিল থাকা শব্দগুলো (একজাক্ট না হলেও) একটি লিস্ট থেকে বের করতে হবে। difflib.get_close_matches ফাংশন ব্যবহার করুন।
সিনট্যাক্স
difflib.get_close_matches(word, possibilities, n, cutoff)
# word: মিল খুঁজতে হবে এমন শব্দ
# possibilities: প্যাটার্ন লিস্ট
# n: সর্বোচ্চ কতগুলো রিটার্ন করবে (>0)
# cutoff: ০ থেকে ১ এর মধ্যে স্কোর থ্রেশহোল্ড
উদাহরণ
from difflib import get_close_matches
word = 'banana'
patterns = ['ana', 'nana', 'ban', 'ran', 'tan']
print('matched words:', get_close_matches(word, patterns))
# আউটপুট: ['nana', 'ban', 'ana']