"生物沙文主义,在这样一个小范围中,如果它影响到对知识的处理,是可笑的。将任何你担忧的专家交给我,我就会将他的价值发挥到最基本机魂的十倍以上。"
——摘录自《组织思想的问题》,第七章
doc2vec继承自word2vec。比起word2vec,doc能更好的使用文章或短句来进行训练与建模。
和word2vec不同,doc2vec需要每次把训练短句的tag作为值传入
TaggededDocument = gensim.models.doc2vec.TaggedDocument
model = gensim.models.Doc2Vec(size=contact_word_num,dm=1, window=1, min_count=1, workers=10) #dm=0-distributed bag of words; dm=1-distributed memory
if os.path.exists(save_path):
model = gensim.models.Doc2Vec.load(save_path)
#储存分词,用来训练
sentence_cut_list = []
#根据excel的短句学习
def learn_excel_word():
global sentence_cut_list
sheet_name = sheet_names[0]
sheet_ = workbook.sheet_by_name(sheet_name)
for docIndex_ in MaxWordCount:
#获取到词库里面的词
text_ = sheet_.row_values(index_)[0].encode("utf-8")
word_