所以我有这个:
import nltk
forms = {"am" : "are", "are" : "am", 'i' : 'you', 'my' : 'yours', 'me' : 'you', 'mine' : 'yours', 'you' : 'I', 'your' : 'my', 'yours' : 'mine'} # More?
def translate(word):
if word.lower() in forms: return forms[word.lower()]
return word
sent = 'You went to see Avatar, and I came with you.'
result = ' '.join([translate(word) for word in nltk.wordpunct_tokenize(sent)])
print(result.capitalize())
# I went to see avatar , and you came with i .
我为防止在引号“”中转换单词而添加的内容>
示例:示例:输入为:“我去看电影,我说:“ [[you
想看什么?”我想要的转换是:“您去看电影时,说“ 您想看什么?”转换,我不想:'你去看电影,你说“ I想看什么?”所以我有这个:import nltk form = {“ am”:“ are”,“ are”:“ am”,'i':'you','my':'yours','me':'you ','mine':'yours','you':'I','your':'my','yours':'mine'}}#更多? def translation(word)...