基本上,我想做的是创建一个程序,将一个句子/段落作为用户输入,查找每个单词的同义词,并用同义词替换该词。到目前为止,我创建的这个程序运行得很好,但是有一些问题/人为错误/逻辑错误。我现在得到的是:response=input("Enter what you want to thesaurize")
orig=response #puts user input into a string
num=orig.count(" ")+1 #finds number of words in the sentence
orig=orig.split(" ") #turns the sentence into a list of its words
new=[] #creates a new list to put the new words in, in case I'd want to go back to the original sentence for any reason
for i in range (num):
if orig[i] not in badWords: #makes sure that the word is not a no-synonym word like "the" or "be"
new.insert(i, myFuncs.replace(orig[i])) #the replace function (which I put in a separate module for neatness purposes) looks up the word on thesaurus.com and replaces it with a synonym
else:
new.insert(i,