import os
import json
import pandas as pd
import numpy as np
import csv
import datetime
import re  # regular expression
import string
# from textblob import TextBlob
# import preprocessor as p
import nltk
# from nltk.stem import WordNetLemmatizer
# from nltk.tokenize import word_tokenize
# from nltk.corpus import stopwords
# nltk.download('stopwords')
# nltk.download('punkt')
# nltk.download('wordnet')
# pip install vaderSentiment
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer


clean_df = pd.read_csv("tweets_sentiments.csv", index_col=0)

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation as LDA

count_vectorizer = CountVectorizer(stop_words='english')
# Fit and transform the processed titles
count_data = count_vectorizer.fit_transform(clean_df['text'])


def print_topics(model, count_vectorizer, n_top_words):
    words = count_vectorizer.get_feature_names()
    for topic_idx, topic in enumerate(model.components_):
        print("\nTopic #%d:" % topic_idx)
        print(" ".join([words[i]
                        for i in topic.argsort()[:-n_top_words - 1:-1]]))


# Tweak the two parameters below
number_topics = 5
number_words = 10
# Create and fit the LDA model
lda = LDA(n_components=number_topics, n_jobs=-1, verbose=1)
lda.fit(count_data)
# Print the topics found by the LDA model
print("Topics found via LDA:")
print_topics(lda, count_vectorizer, number_words)


48dd743adb903a2d766501db4a6c3bcbc64ce32f
<mask token>

<mask token>


def print_topics(model, count_vectorizer, n_top_words):
    words = count_vectorizer.get_feature_names()
    for topic_idx, topic in enumerate(model.components_):
        print('\nTopic #%d:' % topic_idx)
        print(' '.join([words[i] for i in topic.argsort()[:-n_top_words - 1
            :-1]]))


<mask token>
lda.fit(count_data)
print('Topics found via LDA:')
print_topics(lda, count_vectorizer, number_words)

<mask token>
clean_df = pd.read_csv('tweets_sentiments.csv', index_col=0)
<mask token>
count_vectorizer = CountVectorizer(stop_words='english')
count_data = count_vectorizer.fit_transform(clean_df['text'])


def print_topics(model, count_vectorizer, n_top_words):
    words = count_vectorizer.get_feature_names()
    for topic_idx, topic in enumerate(model.components_):
        print('\nTopic #%d:' % topic_idx)
        print(' '.join([words[i] for i in topic.argsort()[:-n_top_words - 1
            :-1]]))


number_topics = 5
number_words = 10
lda = LDA(n_components=number_topics, n_jobs=-1, verbose=1)
lda.fit(count_data)
print('Topics found via LDA:')
print_topics(lda, count_vectorizer, number_words)

import os
import json
import pandas as pd
import numpy as np
import csv
import datetime
import re
import string
import nltk
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
clean_df = pd.read_csv('tweets_sentiments.csv', index_col=0)
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation as LDA
count_vectorizer = CountVectorizer(stop_words='english')
count_data = count_vectorizer.fit_transform(clean_df['text'])


def print_topics(model, count_vectorizer, n_top_words):
    words = count_vectorizer.get_feature_names()
    for topic_idx, topic in enumerate(model.components_):
        print('\nTopic #%d:' % topic_idx)
        print(' '.join([words[i] for i in topic.argsort()[:-n_top_words - 1
            :-1]]))


number_topics = 5
number_words = 10
lda = LDA(n_components=number_topics, n_jobs=-1, verbose=1)
lda.fit(count_data)
print('Topics found via LDA:')
print_topics(lda, count_vectorizer, number_words)

import os
import json
import pandas as pd
import numpy as np
import csv
import datetime
import re  # regular expression
import string
# from textblob import TextBlob
# import preprocessor as p
import nltk
# from nltk.stem import WordNetLemmatizer
# from nltk.tokenize import word_tokenize
# from nltk.corpus import stopwords
# nltk.download('stopwords')
# nltk.download('punkt')
# nltk.download('wordnet')
# pip install vaderSentiment
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer


clean_df = pd.read_csv("tweets_sentiments.csv", index_col=0)

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation as LDA

count_vectorizer = CountVectorizer(stop_words='english')
# Fit and transform the processed titles
count_data = count_vectorizer.fit_transform(clean_df['text'])


def print_topics(model, count_vectorizer, n_top_words):
    words = count_vectorizer.get_feature_names()
    for topic_idx, topic in enumerate(model.components_):
        print("\nTopic #%d:" % topic_idx)
        print(" ".join([words[i]
                        for i in topic.argsort()[:-n_top_words - 1:-1]]))


# Tweak the two parameters below
number_topics = 5
number_words = 10
# Create and fit the LDA model
lda = LDA(n_components=number_topics, n_jobs=-1, verbose=1)
lda.fit(count_data)
# Print the topics found by the LDA model
print("Topics found via LDA:")
print_topics(lda, count_vectorizer, number_words)

