鎬庝箞浣跨敤TextBlob杩囨护鏂囨湰
TextBlob鏄竴涓敤浜庤嚜鐒惰瑷€澶勭悊鐨凱ython搴擄紝鍙互杩涜鏂囨湰鍒嗘瀽銆佹儏鎰熷垎鏋愮瓑銆傝浣跨敤TextBlob杩囨护鏂囨湰锛屽彲浠ユ寜鐓т互涓嬫楠よ繘琛岋細
- 瀵煎叆TextBlob搴?/li>
from textblob import TextBlob
- 鍒涘缓涓€涓猅extBlob瀵硅薄锛屼紶鍏ュ緟澶勭悊鐨勬枃鏈?/li>
text = "杩欐槸涓€娈靛緟澶勭悊鐨勬枃鏈?quot;
blob = TextBlob(text)
- 浣跨敤TextBlob鎻愪緵鐨勬柟娉曡繘琛屾枃鏈繃婊わ紝姣斿鍒嗚瘝銆佽瘝鎬ф爣娉ㄣ€佹儏鎰熷垎鏋愮瓑
# 鍒嗚瘝
words = blob.words
# 璇嶆€ф爣娉?tags = blob.tags
# 鎯呮劅鍒嗘瀽
sentiment = blob.sentiment
- 鏍规嵁闇€姹傞€夋嫨鍚堥€傜殑鏂规硶瀵规枃鏈繘琛岃繃婊ゅ拰澶勭悊锛屾瘮濡傚幓闄ゅ仠鐢ㄨ瘝銆佽瘝骞叉彁鍙栥€佽瘝棰戠粺璁$瓑
# 鍘婚櫎鍋滅敤璇?from textblob import Word
from textblob import WordList
stopwords = ['a', 'an', 'the', 'is', 'are', 'and']
filtered_words = [w for w in words if w not in stopwords]
# 璇嶅共鎻愬彇
stemmed_words = [Word(w).stem() for w in filtered_words]
# 璇嶉缁熻
word_freq = blob.word_counts
閫氳繃浠ヤ笂姝ラ锛屽彲浠ヤ娇鐢═extBlob瀵规枃鏈繘琛岃繃婊ゅ拰澶勭悊锛屼粠鑰屽緱鍒扮鍚堥渶姹傜殑鏂囨湰缁撴灉銆?/p>
相关问答