-1
我想使用Python签约的话,但现在面临的错误来代替。在扩大英语收缩的基础上,最常见的收缩的字典
import re
tweet = "I luv my <3 iphone & you're awsm apple. DisplayIsAwesome, sooo happppppy http://www.apple.com"
contractions_dict = {"ain't": "am not",
"aren't": "are not",
"can't": "cannot",
"you're": "you are"}
contractions_re = re.compile('(%s)' '|'.join(contractions_dict.keys()))
def expand_contractions(s, contractions_dict=contractions_dict):
def replace(match):
return contractions_dict[match.group(0)]
return contractions_re.sub(replace, s)
expand_contractions(tweet)
我试过在“你是”中添加“/”,无济于事。
的输出是通过通过原来的鸣叫。我哪里错了?
谢谢
很愚蠢的错误,是吧? :) 谢谢! –