Skip to main content

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

YouTubeCommentAnalysis-0.0.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

YouTubeCommentAnalysis-0.0.4-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file YouTubeCommentAnalysis-0.0.4.tar.gz.

File metadata

  • Download URL: YouTubeCommentAnalysis-0.0.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for YouTubeCommentAnalysis-0.0.4.tar.gz
Algorithm Hash digest
SHA256 51873e8852b8fb078bec6f1ec82a5a27ee20e89b07e8a418ae0579b4e1efbd4b
MD5 6a0e6062b8354a2f5f69d0bd7a5dc63b
BLAKE2b-256 b09fffa96cc46d4049e9ad481982c5c5dff214cc42e3d60ba3e84dee7876c94b

See more details on using hashes here.

File details

Details for the file YouTubeCommentAnalysis-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: YouTubeCommentAnalysis-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for YouTubeCommentAnalysis-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac43fceda305b54492929b16ed3d1f2bc8cd5f199ce1ddda83df8492afa0102
MD5 7a369372b7dcd87dbfb25ca6a43bb72f
BLAKE2b-256 438f1431ccad2e4e2ff80833869f3f894c6e6f6ef4a107232218c0fa368b6f30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page