from gensim.models import FastText from gensim.models import KeyedVectors import pandas as pd data=pd.read_excel("level_2_table(1).xlsx") data_neirong=data['内容'].values data_1_aspect=data['1_aspect'].values print(data_1_aspect) FASTTEXT
from gensim.models import KeyedVectors
import pandas as pd
data=pd.read_excel("level_2_table(1).xlsx")
data_neirong=data['内容'].values
data_1_aspect=data['1_aspect'].values
print(data_1_aspect)
FASTTEXTFILE = "wiki-news-300d-1M.vec"
ft_model = KeyedVectors.load_word2vec_format(FASTTEXTFILE)
with open ("1_aspect_vec.txt","a+",encoding="utf-8") as f:
for word in data_1_aspect:
temp_vec=ft_model.get_vector(str(word))
print(temp_vec)
f.write(str(word) + " ")
for i in temp_vec:
f.write(str(i)+" ")
f.write("\n")
f.close()