code
stringlengths
3
6.57k
stem_text(temp3)
corpus_full.append(final)
pos.iterrows()
strip_non_alphanum(str(temp)
strip_punctuation(temp1)
strip_multiple_whitespaces(temp2)
stem_text(temp3)
corpus_pos.append(final)
neg.iterrows()
strip_non_alphanum(str(temp)
strip_punctuation(temp1)
strip_multiple_whitespaces(temp2)
stem_text(temp3)
corpus_neg.append(final)
stopwords.words('english')
split()
print (len(stoplist)
stoplist.update(stop_words)
print(len(stop_words)
print(len(stoplist)
document.lower()
split()
print(text_full)
document.lower()
split()
document.lower()
split()
defaultdict(int)
defaultdict(int)
defaultdict(int)
corpora.Dictionary(corpus_removeOne_full)
corpora.Dictionary(corpus_removeOne_pos)
corpora.Dictionary(corpus_removeOne_neg)
dictionary_full.save('redditTest_full.dict')
dictionary_pos.save('redditTest_pos.dict')
dictionary_neg.save('redditTest_neg.dict')
gensim.corpora.Dictionary.load('redditTest.dict')
len(text)
corpus_removeOne_full.remove(text)
len(text)
corpus_removeOne_pos.remove(text)
len(text)
corpus_removeOne_neg.remove(text)
dictionary_full.doc2bow(text)
corpora.MmCorpus.serialize('redditTest_full.mm', bow_corpus_full)
gensim.corpora.MmCorpus('redditTest_full.mm')
models.TfidfModel(bow_corpus_full)
dictionary_pos.doc2bow(text)
corpora.MmCorpus.serialize('redditTest_pos.mm', bow_corpus_pos)
gensim.corpora.MmCorpus('redditTest_pos.mm')
models.TfidfModel(bow_corpus_pos)
dictionary_neg.doc2bow(text)
corpora.MmCorpus.serialize('redditTest_neg.mm', bow_corpus_neg)
gensim.corpora.MmCorpus('redditTest_neg.mm')
models.TfidfModel(bow_corpus_neg)
gensim.models.wrappers.LdaMallet(mallet_path, corpus=bow_corpus_full, num_topics=9, id2word=dictionary_full, workers=1, alpha=110, random_seed=109, iterations=50)
lda_full.print_topics(9)
gensim.models.wrappers.LdaMallet(mallet_path, corpus=bow_corpus_pos, num_topics=9, id2word=dictionary_pos, workers=1, alpha=110, random_seed=109, iterations=50)
lda_pos.print_topics(9)
gensim.models.wrappers.LdaMallet(mallet_path, corpus=bow_corpus_neg, num_topics=9, id2word=dictionary_neg, workers=1, alpha=110, random_seed=109, iterations=50)
lda_neg.print_topics(9)
np.array([color for name, color in mcolors.TABLEAU_COLORS.items()
np.zeros(n_topics)
topic_weights_full.append(tmp)
pd.DataFrame(topic_weights_full)
fillna(9)
np.argmax(arr_full, axis=1)
tsne_model_full.fit_transform(arr_full)
str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
plt.xlabel('t-SNE1'.translate(sub)
plt.ylabel('t-SNE2'.translate(sub)
plt.title('t-SNE Plot of Topics within Positive Sentiment Corpus')
plt.scatter(x=tsne_lda_full[:,0], y=tsne_lda_full[:,1])
plt.show(tsne_full)
np.zeros(n_topics)
topic_weights_pos.append(tmp)
pd.DataFrame(topic_weights_pos)
fillna(0)
np.argmax(arr_pos, axis=1)
tsne_model_pos.fit_transform(arr_pos)
str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
plt.xlabel('t-SNE1'.translate(sub)
plt.ylabel('t-SNE2'.translate(sub)
plt.title('t-SNE Plot of Topics within Positive Sentiment Corpus')
plt.scatter(x=tsne_lda_pos[:,0], y=tsne_lda_pos[:,1])
plt.show(tsne_pos)
np.zeros(n_topics)
topic_weights_neg.append(tmp)
pd.DataFrame(topic_weights_neg)
fillna(0)
np.argmax(arr_neg, axis=1)
tsne_model_neg.fit_transform(arr_neg)
str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
plt.xlabel('t-SNE1'.translate(sub)
plt.ylabel('t-SNE2'.translate(sub)
plt.title('t-SNE Plot of Topics within Negative Sentiment Corpus')
plt.scatter(tsne_lda_neg[:,0], tsne_lda_neg[:,1])
plt.show(tsne_neg)
lda_full.show_topics(formatted=False)
Counter(flatten_full)