application_vnd.jupyter.stderr_output_1.png
from gensim.models import word2vec

from nltk.corpus import stopwords

import io

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

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 gensim.models import word2vec
from gensim.test.utils import common_texts, get_tmpfile
tokenized_sentences = [[j.lower() for j in st.split() if j not in stopwords.words('english')] for st in titleCorpus]
model = word2vec.Word2Vec(tokenized_sentences, min_count=1)
model.save('word2vec.model')

import io
out_v = io.open('vecs.tsv', 'w', encoding='utf-8')
out_m = io.open('meta.tsv', 'w', encoding='utf-8')
for word in model.wv.vocab:
    out_m.write(word + '\n')
    out_v.write('\t'.join([str(x) for x in model[word]]) + '\n')
out_v.close()
out_m.close()