我正在从Twitter上抓取推文,我想从我正在抓取的所有推文中收集所有名词的列表,以便我找出哪些名词出现的频率最高。
def sentiment_script():
for tweet in tweepy.Cursor(api.search, q=hashtag_phrase + ' -filter:retweets', lang="en", tweet_mode='extended').items(7):
text = tweet.full_text
text = ' '.join(re.sub("(@[A-Za-z0-9]+)|([^0-9A-Za-z t])|(w+://S+)", " ", text).split())
blob = TextBlob(text)
nouns = (blob.noun_phrases)
print(nouns)
输出是这样的:
['covid', 'richmitch']
['uk', 'england', 'uk', 'johnson', 's approach']
['peoria']
['pa', 'surely', 'secretly trying', 'infect', 'covid', 'never wonkette']
['don t', 'full lockdown', 'cancer etc don t', 'full recovery', 'death rate', 'aren t', 'full lockdown']
['datascience team', 'weekly report', 'new data', 'covid', 'may', 'report sheds light', 'business impacts', 'covid', 'read', 'capraplus']
['osdbu', 'small businesses', 'linked', 'covid']
我不确定下一步该怎么做,就像我这样做时一样:
print(type(nouns))
结果是
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
<class 'textblob.blob.WordList'>
你试过吗
打印(类型.文本( ?