Downloading D:\environment\data\data\fra-eng.zip from http://d2l-data.s3-accelerate.amazonaws.com/fra-eng.zip...
Go. Va !
Hi. Salut !
Run! Cours !
Run! Courez !
Who? Qui ?
Wow! Ça alors !
#@savedefpreprocess_nmt(text):"""预处理“英语-法语”数据集"""defno_space(char, prev_char):return char inset(',.!?')and prev_char !=' '# 使用空格替换不间断空格# 使用小写字母替换大写字母
text = text.replace('\u202f',' ').replace('\xa0',' ').lower()# 在单词和标点符号之间插入空格
out =[' '+ char if i >0and no_space(char, text[i