我正在研究在 python 中嵌入文本。我發(fā)現(xiàn)兩個文檔與 Doc2vec 模型的相似之處。代碼如下:for doc_id in range(len(train_corpus)): inferred_vector = model.infer_vector(train_corpus[doc_id].words) # it takes each document words as a input and produce vector of each document sims = model.docvecs.most_similar([inferred_vector], topn=len(model.docvecs)) # it takes list of all document's vector as a input and compare those with the trained vectors and gives the most similarity of 1st document to other and then second to other and so on . print('Document ({}): ?{}?\n'.format(doc_id, ' '.join(train_corpus[doc_id].words))) print(u'SIMILAR/DISSIMILAR DOCS PER MODEL %s:\n' % model) for label, index in [('MOST', 0), ('SECOND-MOST', 1), ('MEDIAN', len(sims)//2), ('LEAST', len(sims) - 1)]: print(u'%s %s: ?%s?\n' % (label, sims[index], ' '.join(train_corpus[sims[index][0]].words)))現(xiàn)在,從這兩個嵌入的文檔中,我如何才能從這些特定文檔中提取一組語義相似的單詞。請幫幫我。
我想從python中的兩個嵌入文檔中獲取語義相似的單詞列表
阿波羅的戰(zhàn)車
2022-10-05 17:00:46