【问题标题】:Python: Goslate translation request returns "503: Service Unavailable" [closed]Python:Goslate 翻译请求返回“503:服务不可用”[关闭]
【发布时间】:2015-06-22 22:36:19
【问题描述】:

几个月前,我使用 Python 的 goslate 包将一堆法语文本翻译成英语。但是,当我今天早上尝试这样做时,服务返回了一个错误:

import goslate
gs = goslate.Goslate()
print gs.translate('hello world', 'de')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python27\lib\site-packages\goslate.py", line 389, in translate
    return _unwrapper_single_element(self._translate_single_text(text, target_language, source_language))
  File "c:\Python27\lib\site-packages\goslate.py", line 317, in _translate_single_text
    results = list(self._execute(make_task(i) for i in split_text(text)))
  File "c:\Python27\lib\site-packages\goslate.py", line 200, in _execute
    yield each()
  File "c:\Python27\lib\site-packages\goslate.py", line 315, in <lambda>
    return lambda: self._basic_translate(text, target_language, source_lauguage)[0]
  File "c:\Python27\lib\site-packages\goslate.py", line 241, in _basic_translate
    response_content = self._open_url(url)
  File "c:\Python27\lib\site-packages\goslate.py", line 178, in _open_url
    response = self._opener.open(request, timeout=self._TIMEOUT)
  File "c:\Python27\lib\urllib2.py", line 437, in open
    response = meth(req, response)
  File "c:\Python27\lib\urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\Python27\lib\urllib2.py", line 469, in error
    result = self._call_chain(*args)
  File "c:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "c:\Python27\lib\urllib2.py", line 656, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "c:\Python27\lib\urllib2.py", line 437, in open
    response = meth(req, response)
  File "c:\Python27\lib\urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\Python27\lib\urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "c:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "c:\Python27\lib\urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 503: Service Unavailable

有人知道goslate 发生了什么吗?如果它一去不复返,有没有像 goslate 包的不错的替代品来通过 API 调用将法语翻译成英语?

【问题讨论】:

    标签: python nlp translation machine-translation


    【解决方案1】:

    请确保您使用的是最新版本的 Goslate,如果没有,请尝试从其 repository 更新它。本月 API 发生了一些变化,它们已经在 Goslate 中实现。我刚刚在我的应用程序中检查了它,它确实可以完美运行。
    为了更新 Goslate,您可能需要安装 Mercurial 版本控制系统。
    安装 Mercurial 后,使用以下命令克隆 repo:

    hg clone https://bitbucket.org/zhuoqiang/goslate
    

    然后像这样不时更新它(您需要存储库文件夹中才能工作):

    hg pull -u
    

    【讨论】:

    • 非常感谢!我刚刚跑了pip install -U goslate,它把我带到了那里。再次感谢!
    • 好像又掉线了。至少可以称之为不可靠:S
    • @gabn88 该死的男人,该死的。我已经使用这个多年了!我什至不记得当时 Goslate 是什么。
    猜你喜欢
    • 2015-12-11
    • 2015-06-21
    • 2022-01-22
    • 1970-01-01
    • 2012-08-15
    • 2020-05-20
    • 1970-01-01
    • 2012-07-06
    • 1970-01-01
    相关资源
    最近更新 更多