
6.6
単語の種類を考慮する
133
r"\bhadn't\b": "had not",
r"\bwon't\b": "will not",
r"\bwouldn't\b": "would not",
r"\bcan't\b": "can not",
r"\bcannot\b": "can not",
}
def create_ngram_model(params=None):
def preprocessor(tweet):
global emoticons_replaced
tweet = tweet.lower() #
ツイート文章を小文字に変換
for k in emo_repl_order:
tweet = tweet.replace(k, emo_repl[k])
f
or r, repl in re_repl.iteritems():
tweet = re.sub(r, repl, tweet)
return tweet
tfidf_ngrams = TfidfVectorizer(preprocessor=preprocessor,
analyzer="word")
# ...
ここで定義された以外の略語が他にもあることは間違いありません。しかし、ここで定義した顔文
字と略語は限定されたものですが、それだけでも精度を向上させることができます。次の結果に示す
通り、たとえば、感情が含まれるツイートとそうでないツイートを分類する場合はAUCの値は70.7%
になり、前より0