-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)
我試過在「你是」中添加「/」,無濟於事。
的輸出是通過通過原來的鳴叫。我哪裏錯了?
謝謝
很愚蠢的錯誤,是吧? :) 謝謝! –