text_plain_output_1.png
from sklearn.feature_extraction.text import CountVectorizer

from sklearn.feature_extraction.text import TfidfVectorizer

from textblob import TextBlob

import matplotlib.dates as mdates

import matplotlib.pylab as plt

import nltk

import nltk

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

dfpub = pd.read_csv('/kaggle/input/academic-publications-and-journals/wiki_query_22_12_2020.csv', encoding='iso-8859-1')

array = {}
for c in dfpub['browsing_date']:
    if '1601' in c:
        continue
    today = c.split()[0]
    array[today] = 1 if today not in array else array[today] + 1

x = list(array.keys())
y = list(array.values())
df_plot = pd.DataFrame()
df_plot['x'] = x
df_plot['y'] = y
df_plot.index = x

ax = plt.gca()
ax.xaxis.set_major_locator(mdates.DayLocator(interval=13))
ax.xaxis.set_major_formatter(mdates.DateFormatter('%d-%m-%Y'))
plt.gcf().autofmt_xdate()

wordListCorpus = []
titleCorpus = []
failedConvert = []
for row in dfpub['tags'].values:
    try:
        tags = row.split(',')
        title = ' '.join(row.split(','))
    except AttributeError:
        failedConvert.append(row)
    for k in tags:
        wordListCorpus.append(k)
    titleCorpus.append(title)
len(wordListCorpus)

from sklearn.feature_extraction.text import TfidfVectorizer
vec = TfidfVectorizer(use_idf=False, norm='l1')
matrix = vec.fit_transform(titleCorpus)
pd.DataFrame(matrix.toarray(), columns=vec.get_feature_names())

from textblob import TextBlob
import nltk
nltk.download('punkt')
def textblob_tokenizer(str_input):
    blob = TextBlob(str_input.lower())
    tokens = blob.words
    words = [token.stem() for token in tokens]
    return words
vec = CountVectorizer(tokenizer=textblob_tokenizer)
matrix = vec.fit_transform(titleCorpus)
pd.DataFrame(matrix.toarray(), columns=vec.get_feature_names())