application_vnd.jupyter.stderr_output_9.png application_vnd.jupyter.stderr_output_7.png application_vnd.jupyter.stderr_output_11.png text_plain_output_4.png text_plain_output_10.png text_plain_output_6.png application_vnd.jupyter.stderr_output_3.png application_vnd.jupyter.stderr_output_5.png text_plain_output_8.png text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from gensim.models import Word2Vec

from tqdm import tqdm

import docx

import os

import re

import numpy as np
import pandas as pd
import os

def read_data(file_path):
    text = []
    none = 0
    doc = docx.Document(file_path)
    for para in doc.paragraphs:
        content = para.text
        filter_ = re.compile(u'[^一-龥]')
        filtered_content = filter_.sub('', content)
        if len(filtered_content) > 0:
            text.append(filtered_content)
        else:
            none += 1
    for table in doc.tables:
        for row in table.rows:
            for cell in row.cells:
                content = cell.text
                filter_ = re.compile(u'[^一-龥]')
                filtered_content = filter_.sub('', content)
                if len(filtered_content) > 0:
                    text.append(filtered_content)
                else:
                    none += 1
    return text

path = '../input/research_data/research_data/'
doc = os.listdir('../input/research_data/research_data/')
doc

text = []
for doc_ in tqdm(doc):
    path_ = path + doc_
    text_ = read_data(path_)
    text += text_

text_split = []
for text_ in tqdm(text):
    text_split_ = []
    for i in range(len(text_)):
        text_split_.append(text_[i])
    text_split.append(text_split_)

model = Word2Vec(text_split, size=100, window=5, min_count=1, workers=1, iter=30)

model['公']