YouTube Comment Analysis
Project description
YouTubeCommentAnalysis
Installation
pip install YouTubeCommentAnalysis
Example usage
raw_comment_csv = "sample_1k_1.csv"
# Read file
file_processor = FileExIm()
df = file_processor.read_file(raw_comment_csv)
# Clean Text
tp = TextProcessing()
df['cleanText'] = df.textDisplay.apply(tp.process_text)
df['cleanText'] = df.cleanText.apply(tp.lemmatize_stemming)
# Tokenization
cc = CommentCorpus(list(df.cleanText))
df['tokens'] = cc.tokenize()
df['bigrams'] = cc.bigram(min_count=100)
df['bow'] = cc.bag_of_word()
dictionary = cc.dictionary(save=True, directory=dictionary_file)
# Check if english
df['en'] = df.cleanText.apply(tp.isEnglish)
# Emotion Analysis
ea = EmotionAnalysis()
df = ea.emo_score(df, 'tokens', 'emo_tokens')
agg_dict = {
'channelId': 'first',
'commentId': list,
'cleanText': list,
'tokens': list,
'bigrams': list,
'bow': list,
'emo_tokens': list,
'Positive': 'sum',
'Negative': 'sum',
'Anger': 'sum',
'Anticipation': 'sum',
'Disgust': 'sum',
'Fear': 'sum',
'Joy': 'sum',
'Sadness': 'sum',
'Surprise': 'sum',
'Trust': 'sum'
}
groupby_video = ea.process_file_byvideo(channel_vid, 'videoId', agg_dict)
groupby_video.to_pickle(f'result_dir/emotion_analysis{raw_comment_csv}')
# Word Association
token = 'hello'
wa = WordAssociation(dictionary, df.bow)
pmi_dict = wa.token_pmi(token, threshold=10)
top_kw = wa.get_top_kw(token, 0.1) # Get top keywords
# Save top keywords
file_processor.save_to_txt([str(dictionary[k[0]]) for k in top_kw], f'result/{token}_top_words.txt')
# Save current df with muitple pickles,
# Each pickle represent unique channelId
file_processor.save_byColumn(df, 'channelId', 'result_dir')
df.to_csv(cleanText_file)
Changelog
Version 0.0.1
First version includes Comment Text Processing, Emotion Analysis, and Word Association. This version is tested and okay to use.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for YouTubeCommentAnalysis-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e4b5b2a2570c6c6fe72fd35c923d88bf0f6d0eec66b949e797436fc4f9efdd4 |
|
MD5 | 4f7fe5caa714d546a39f63617e48b09a |
|
BLAKE2b-256 | 839bfd7b30d50ac19494f7bdeeb01195f9089d1896669efa35c0937612c9ad9e |
Close
Hashes for YouTubeCommentAnalysis-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04aa9ee99388a3cced44395f36042f979319890d2ca5c99128ae4e681719b968 |
|
MD5 | d65b84b9222280f021c28a7127672813 |
|
BLAKE2b-256 | f570a1128b94279d71c592e4c9c744e711460a0eb74841577fe6d49ffcdcfc96 |