-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)
私は「あなたのもの」に「/」を追加しようとしましたが、無駄です。
出力は、通過した元のツイートです。どこが間違っていますか?
はあなた
かなり愚かな間違いでしょうか? :) ありがとうございました! –