【问题标题】:Python3 Textblob detection - ValueErrorPython3 Textblob 检测 - ValueError
【发布时间】:2021-03-19 16:32:42
【问题描述】:

我使用的是 textblob detecct_language,它在两周前就可以使用。只是基本用法。

from textblob import TextBlob
text = "C???????????? ???????? ????????????????®: ???????????????????? ???????????? ???????????????? ???????????? - ???????????????????????? ????????????????????????????"
lang = TextBlob(text).detect_language()

现在它引发了 ValueError。

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-27-bad6e63440b4> in <module>
      3 text = "C???????????? ???????? ????????????????®: ???????????????????? ???????????? ???????????????? ???????????? - ???????????????????????? ????????????????????????????"
      4 lang = TextBlob(text)
----> 5 lang.detect_language()

~\anaconda3\lib\site-packages\textblob\blob.py in detect_language(self)
    566         :rtype: str
    567         """
--> 568         return self.translator.detect(self.raw)
    569 
    570     def correct(self):

~\anaconda3\lib\site-packages\textblob\translate.py in detect(self, source, host, type_)
     71         url = u'{url}&sl=auto&tk={tk}'.format(url=self.url, tk=_calculate_tk(source))
     72         response = self._request(url, host=host, type_=type_, data=data)
---> 73         result, language = json.loads(response)
     74         return language
     75 

ValueError: not enough values to unpack (expected 2, got 1)

完全不知道是什么导致了错误。

【问题讨论】:

  • 我也遇到了这个错误。语言检测使用谷歌 API,所以我的猜测是谷歌 API 发生了一些变化。抱歉,除此之外我不知道更多。

标签: python-3.x textblob


【解决方案1】:

面临同样的问题,这是 google translate api 的回复格式发生了变化,对我来说 translate 和 detect_language 函数都不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 1970-01-01
    相关资源
    最近更新 更多