【问题标题】:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \UXXXXXXXX escapeSyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \UXXXXXXXX escape
【发布时间】:2021-05-08 11:46:43
【问题描述】:
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)

我正在尝试使用 Glove 矢量。但它会产生如下语法错误:

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

有谁知道如何解决这个问题?谢谢。

【问题讨论】:

    标签: nlp stanford-nlp word2vec


    【解决方案1】:

    试试这个:

    glove_file = datapath(r'c:\Users\Lenovo\AppData\glove.6B.100d.word2vec.txt')
    

    你必须阅读路径... 它会解决你的问题...

    【讨论】:

    • 我确实按照您的建议尝试过,但没有帮助。
    猜你喜欢
    • 1970-01-01
    • 2020-11-25
    • 2021-12-15
    • 2022-11-10
    • 1970-01-01
    • 2022-11-03
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多