sherifkozman / google-api-spelling-java Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/google-api-spelling-java
Automatically exported from code.google.com/p/google-api-spelling-java
What steps will reproduce the problem?
1. Take the google-api-spelling-java.1.1.jar
2. Integrate it into your project( as sample shows )
3. do something to activate the code and you get the error:
org.xeustechnologies.googleapi.spelling.SpellCheckException:
java.io.FileNotFoundException:
https://www.google.com/tbproxy/spell?lang=en&hl=en
Original issue reported on code.google.com by [email protected]
on 22 Aug 2013 at 1:12
Reading bytes one-by-one and casting them to char won't work for non-ASCII
characters.
Here is a patch which fixes this:
Index: src/main/java/org/xeustechnologies/googleapi/spelling/SpellChecker.java
===================================================================
---
src/main/java/org/xeustechnologies/googleapi/spelling/SpellChecker.java (revisio
n 17)
+++
src/main/java/org/xeustechnologies/googleapi/spelling/SpellChecker.java (working
copy)
@@ -22,10 +22,12 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.charset.Charset;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -98,20 +100,16 @@
if( logger.isDebugEnabled() )
logger.debug( new String( requestData ) );
- int c = 0;
- StringBuffer buff = new StringBuffer();
- BufferedInputStream responseStream = new BufferedInputStream(
conn.getInputStream() );
+ InputStream responseStream = conn.getInputStream();
- while(( c = responseStream.read() ) != -1) {
- buff.append( (char) c );
- }
+ byte[] buff = toByteArray(responseStream);
responseStream.close();
if( logger.isDebugEnabled() )
- logger.debug( buff );
+ logger.debug( new String(buff, Charset.forName("UTF-8")) );
- return unmarshall( buff.toString().getBytes() );
+ return unmarshall( buff );
} catch (Exception e) {
logger.error( e, e );
@@ -167,6 +165,19 @@
return uri.toString();
}
+ // could add dependency to Apache Commons,
+ // but may not be worth it for one method
+ private static byte[] toByteArray(InputStream in) throws IOException {
+ int BUFFER_SIZE = 4096;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int read = 0;
+ while ((read = in.read(buffer)) != -1) {
+ out.write(buffer, 0, read);
+ }
+ return out.toByteArray();
+ }
+
public SpellChecker(Language language) {
this.language = language;
}
Index: src/main/java/org/xeustechnologies/googleapi/spelling/Language.java
===================================================================
---
src/main/java/org/xeustechnologies/googleapi/spelling/Language.java (revision
17)
+++
src/main/java/org/xeustechnologies/googleapi/spelling/Language.java (working
copy)
@@ -23,7 +23,7 @@
*/
public enum Language {
DANISH("da"), GERMAN("de"), ENGLISH("en"), SPANISH("es"), FINNISH("fi"), FRENCH("fr"), ITALIAN("it"), DUTCH("nl"), POLISH(
- "pl"), PORTUGUESE("pt"), SWEDISH("sv");
+ "pl"), PORTUGUESE("pt"), SWEDISH("sv"), RUSSIAN("ru");
private final String code;
Original issue reported on code.google.com by [email protected]
on 8 Mar 2013 at 11:09
What steps will reproduce the problem?
copied the get started code
What is the expected output? What do you see instead?
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/apache/log4j/Logger
at org.xeustechnologies.googleapi.spelling.SpellChecker.<clinit>(SpellChecker.java:50)
What version of the product are you using? On what operating system?
1.1 on windows 7
Please provide any additional information below.
Original issue reported on code.google.com by fokion.s
on 22 Feb 2013 at 4:56
What steps will reproduce the problem?
1. checking the spelling of Arabic word
What is the expected output? What do you see instead?
[DEBUG][org.xeustechnologies.googleapi.spelling.SpellChecker] - <?xml
version="1.0" encoding="UTF-8"?><spellresult error="0" clipped="0"
charschecked="2"></spellresult>
What version of the product are you using? On what operating system?
version 1
Original issue reported on code.google.com by [email protected]
on 8 May 2012 at 8:44
What steps will reproduce the problem?
1. SpellChecker.check is throwing exception
2.
3.
What is the expected output? What do you see instead?
expecting some suggested words and getting java.io.FileNotFoundException:
What version of the product are you using? On what operating system?
version 1.1, OS=windows
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 15 Jul 2013 at 8:00
What steps will reproduce the problem?
1. Spell check the word "CCR'S" without the double quotes.
What is the expected output? What do you see instead?
One of the results should be CCR&Rs, but an exception is thrown.
What version of the product are you using? On what operating system?
Version 1.1 on Windows 7.
Please provide any additional information below.
It looks like the XML returns ampersands without being XML-formatted, so the
XML can't be parsed.
Original issue reported on code.google.com by [email protected]
on 11 Jul 2011 at 8:37
What steps will reproduce the problem?
1. Caused By: javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A
corrupt or unuseable certificate was received.
2. not sure what needs to be done
3.
What is the expected output? What do you see instead?
should not see the BAD_CERTIFICATE issue in logs. i see the error log attaches
to this issue.
What version of the product are you using? On what operating system?
we are trying to implement Google spell check in Linux
Please provide any additional information below.
i imported "thawte" Aliases in to the keystore .nmkst file.
Original issue reported on code.google.com by [email protected]
on 13 Apr 2012 at 8:20
Attachments:
[deleted issue]
[deleted issue]
What steps will reproduce the problem?
--------------------------------------
1.
SpellResponse spellResponse = checker.check("dontknow")
2.
for ( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getWords()[0] );
3.
What is the expected output? What do you see instead?
-----------------------------------------------------
I guess SpellCorrection.getWords() should split the alternatives returned by
the google's api.
The expected output then should be "don't know" for getWords()[0] but is
"don't".
Please provide any additional information below.
------------------------------------------------
Looking at the output xml it seems that the alternatives are separated by a
tab,
so you have to replace
"value.split(\\s)"
by
"value.split(\\t)"
in SpellCorrection.getWords().
Original issue reported on code.google.com by [email protected]
on 5 Sep 2012 at 1:16
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.