问题描述
import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
plt.style.use ('ggplot')
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from gensim.test.utils import datapath,get_tmpfile
from gensim.models import KeyedVectors
from gensim.scripts.glove2word2vec import glove2word2vec
glove_file = datapath('c:\Users\Lenovo\AppData\glove.6B.100d.word2vec.txt')
word2vec_glove_file = get_tmpfile("glove.6B.100d.word2vec.txt")
glove2word2vec(glove_file,word2vec_glove_file)
我正在尝试使用手套矢量。但它产生如下语法错误:
File "<ipython-input-27-b7974d8ef44b>",line 1
glove_file = datapath('\Users\Lenovo\AppData\glove.6B.100d.word2vec.txt')
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \UXXXXXXXX escape
有谁知道如何解决这个问题?谢谢。
解决方法
尝试使用这个:
glove_file = datapath(r'c:\Users\Lenovo\AppData\glove.6B.100d.word2vec.txt')
你必须阅读路径... 它会解决你的问题...