Xử lý văn bản Twitter

Phân tích dữ liệu mạng xã hội bằng Python

Alex Hanna

Computational Social Scientist

Văn bản trong Twitter JSON

tweet_json = open('tweet-example.json', 'r').read()
tweet = json.loads(tweet_json)
tweet['text']
Phân tích dữ liệu mạng xã hội bằng Python

Hơn 140 ký tự

tweet['extended_tweet']['full_text']
Phân tích dữ liệu mạng xã hội bằng Python

Retweet và tweet trích dẫn

tweet['quoted_status']['extended_tweet']['full_text']
Phân tích dữ liệu mạng xã hội bằng Python

Thông tin văn bản của người dùng

tweet['user']['description']
tweet['user']['location']
Phân tích dữ liệu mạng xã hội bằng Python

Làm phẳng Twitter JSON

extended_tweet['extended_tweet-full_text'] = 
    extended_tweet['extended_tweet']['full_text']
Phân tích dữ liệu mạng xã hội bằng Python

Làm phẳng Twitter JSON

tweet_list = []
with open('all_tweets.json', 'r') as fh:
    tweets_json = fh.read().split("\n")

for tweet in tweets_json: tweet_obj = json.loads(tweet)
if 'extended_tweet' in tweet_obj: tweet_obj['extended_tweet-full_text'] = tweet_obj['extended_tweet']['full_text'] ...
tweet_list.append(tweet)
tweets = pd.DataFrame(tweet_list)
Phân tích dữ liệu mạng xã hội bằng Python

Cùng luyện tập nào!

Phân tích dữ liệu mạng xã hội bằng Python

Preparing Video For Download...