所以我在difflib.get_close_matches库上的代码有问题,我想获取句子中所有可能的单词匹配。
def nearest_words(sentence,n):
global tagalog_dictionary
global index
index = 0
sentences = sentence.split()
sentence_s = sentence
temp_sentence = ' '
counter = 0
new_sentence = list()
elif int(n) > 1:
word_l = 0
for i in range(n):
for words in sentences:
x = difflib.get_close_matches(words, get_all_matches_list, int(n))[i]
print(x)
new_sentence.append(x)
counter += 1
print(new_sentence)
Sample sentence = "dis iz a gud music"
if n = 4
output based on N:
Output 1 = " this is a good music" <br>
Output 2 = " ths isz aw gd music" <br>
Output 3 = ........<br>
Output 4 = ........