Jump to content

Ajuda com o google-api-spelling-java


nellaf
 Share

Recommended Posts

Boas

Tenho o seguinte código:

import org.xeustechnologies.googleapi.spelling.*;

public class Corrector {

 public static void main(String[] args) {

   Configuration config = new Configuration();
   //config.setProxy("my_proxy_host", 8080, "http"); -> já descomentei e faz o mesmo

   SpellChecker checker = new SpellChecker(config);
   checker.setOverHttps(true); // Use https (default true from v1.1)
   checker.setLanguage(Language.ENGLISH); // Use English (default)

   SpellRequest request = new SpellRequest();
   request.setText("helloo helloo worlrd");
   request.setIgnoreDuplicates(true); // Ignore duplicates

   SpellResponse spellResponse = checker.check(request);

   for (SpellCorrection sc : spellResponse.getCorrections()) {
      System.out.println(sc.getValue());
   }
 }
}

e dá o erro:

[ERROR][org.xeustechnologies.googleapi.spelling.SpellChecker] - java.net.ConnectException: Connection timed out: connect
Exception in thread "main" org.xeustechnologies.googleapi.spelling.SpellCheckException: java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at org.xeustechnologies.googleapi.spelling.SpellChecker.check(SpellChecker.java:118)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at ribt.v11.Corrector.main(Corrector.java:28)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.Socket.connect(Socket.java:579)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:612)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at java.net.Socket.connect(Socket.java:579)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:612)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:270)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:327)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:270)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:327)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1090)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
at org.xeustechnologies.googleapi.spelling.SpellChecker.check(SpellChecker.java:91)
at ribt.v11.Corrector.main(Corrector.java:28)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1090)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at org.xeustechnologies.googleapi.spelling.SpellChecker.check(SpellChecker.java:91)
... 1 more
Java Result: 1

Como posso corrigir esse erro?

Obrigado

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.