Comments (2)
Update on 12th, Nov, 2018
It seems that each translator instance can only be used for one translation. This Exception can be avoided if you detach the translator immediately after you use it and renew a different translator for the next translation. A simple demo may like the following:
BaiduTranslator baiduTranslator = new BaiduTranslator();
querierTrans.attach(baiduTranslator);
querierTrans.setParams(LANG.ZH, LANG.EN, source);
List<String> targets = querierTrans.execute();
querierTrans.detach(baiduTranslator);
for(String target: targets){
baiduTranslator = new BaiduTranslator();
querierTrans.attach(baiduTranslator);
querierTrans.setParams(LANG.EN, LANG.ZH, target);
List<String> source_ = querierTrans.execute();
querierTrans.detach(baiduTranslator);
}
But this solution is rather complicated and time-consuming..
This project is fairly helpful!
But when I tried to translate from A to B and immediately from B to A like this:
querierTrans.setParams(LANG.ZH, LANG.EN, source);
List<String> targets = querierTrans.execute();
for(String target: targets){
querierTrans.setParams(LANG.EN, LANG.ZH, target);
List<String> source_ = querierTrans.execute();
}
I met the very same issue as shown above.
This problem has nothing to do with which translator I chose. Since I knew few about the HttpClient sort of thing, it's hard for me to understand why this happened.
Thank you.
from mtrans.
遇到这种情况怎么办,被谷歌限制了
rg.apache.http.conn.HttpHostConnectException: Connect to www.google.com:443 [www.google.com/127.0.0.1, www.google.com/2404:6800:4012:0:0:0:0:2004] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at com.swjtu.trans.impl.GoogleTranslator.query(GoogleTranslator.java:74)
at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42)
at com.swjtu.querier.Querier.execute(Querier.java:25)
from mtrans.
Related Issues (17)
- 关于sign和Cookie的计算 HOT 11
- 被请求的服务器限制怎么办 HOT 1
- 部分文本计算tk计算错误
- 搜狗的Translator失效 HOT 1
- 源代码内可能泄露个人信息 HOT 1
- 大佬您好! 我个人觉得,音频文件的储存名称以及, 储存路径, 应该做成接口, 让用户自定义传值, 不然每次都改源文件
- 百度翻译报401 HOT 1
- 可以翻译文档吗
- 是需要把源代码下载下来导入到项目吗? HOT 1
- 有道翻译的md5 变量ebSeFb%=XZ%T[KZ)c(sy!
- 能获取到语音接口? HOT 2
- 支持单词查询 HOT 2
- 语言简写问题 HOT 2
- Map selection problem under the GoogleTranslator class setFormData() under jdk 1.8 HOT 1
- Result is null when using BaiduTranslator
- NoRouteToHostException: No route to host (Host unreachable) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtrans.