Re: [SOLVED] ERXGoogleSpell issue : The entity name must immediately follow the '&' in the entity reference.
Re: [SOLVED] ERXGoogleSpell issue : The entity name must immediately follow the '&' in the entity reference.
- Subject: Re: [SOLVED] ERXGoogleSpell issue : The entity name must immediately follow the '&' in the entity reference.
- From: shravan kumar <email@hidden>
- Date: Sun, 7 Dec 2008 11:22:53 -0800 (PST)
Hello All,
This issue is solved after a long confusion.
Just as a reference for any one getting affected with this problem next time, here is a solution very much related to this problem:
ERXGoogleSpell api was escaping non xml characters in the user given text and then process further, this has been a problem in my case, because, I was giving the escaped text to ERXGoogleSpell api and expected it to start processing from there on.
I have got this solution, after I have closely examined the ERXGoogleSpell source code. Thanks to Wonder Team for sharing the source (Open Source project!!!).
For Eg:
User Entered Text: Hello "World"!
I was passing this text: Hello "World"!
ERXGoogleSpell api was doing this: Hello &quot;World&quot;!
ERXGoogleSpell api was transforming "&" in """ to "&
As a solution, I am unescaping the text and passing that text to ERXGoogleSpell api.
I would be getting the escaped text from user interface, so I was sending the same to ERXGoogleSpell api.
At the end it is a double work to the system to unescape the text and then ERXGoogleSpell api escape the same text. Instead, a more robust api should be introduced. A small thought from my tiny brain is scribbled below for wonder team. Hope to see the best.
----------------------
To WONDER TEAM,
I think ERXGoogleSpell api should modify the below api or write a wrapper api to provide an option to whether escape user given text or not:
ACTUAL:
public static Correction[] suggestions(String text, String lang, String hl) throws CorrectionException {
EXPECTED:
public static Correction[] suggestions(String text, String lang, String hl, boolean shouldEscapeText) throws CorrectionException {
Thank You,
Shravan
---------------
Shravan Wrote:
Hello Group,
I have been receiving below such ERXGoogleSpell$CorrectionException exceptions.
Could you anyone please advise me what could be the reason for these issues and any probable solution thereby.
NOTE:
Eg1: Below string is causing error:
USER Given: funnicity is funny. isn't it. true. well go to "funnicity" today.
Escaped String : funnicity is funny. isn't it. true. well go to "funnicity" today.
Eg2: Below string successfully generated spell suggestions:
USER Given: funnicity is funny. isn ' t it. true. well go to " funnicity " today.
Escaped Given: funnicity is funny. isn ' t it. true. well go to " funnicity " today.
***************
"The difference between above two example strings is, characters to be escaped were separated from other chars with a single whitespace."
***************
In the below notes "TEXT:" is the string sent to ERXGoogleSpell and "ERROR:" is the error received from ERXGoogleSpell:
--------------------------------------------------------
TEXT:
funnicity is funny. isn't it. true. well go to " funnicity " today.
ERROR:
The entity name must immediately follow the '&' in the entity reference.
00:43 DEBUG text is : funnicity is funny. isn t it. true. well go to "funnicity" today.
[Fatal Error] :1:244: The reference to entity "quot" must end with the ';' delimiter.
er.extensions.ERXGoogleSpell$CorrectionException: Failed to correct spelling of 'funnicity is funny. isn t it. true. well go to "funnicity" today.'.
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:172)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:114)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:99)
at com.mtj.DirectAction.checkSpellingAction(DirectAction.java:1872)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.appserver.WODirectAction.performActionNamed(WODirectAction.java:128)
at com.webobjects.appserver._private.WOActionRequestHandler._handleRequest(WOActionRequestHandler.java:240)
at com.webobjects.appserver._private.WOActionRequestHandler.handleRequest(WOActionRequestHandler.java:145)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at com.mtj.Application.dispatchRequest(Application.java:669)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)
Caused by: org.xml.sax.SAXParseException: The reference to entity "quot" must end with the ';' delimiter.
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:267)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:148)
... 14 more
--------------------------------------------------------
TEXT:
funnicity is funny. tell me isn't it true.
ERROR:
07:29 DEBUG text is : funnicity is funny. tell me isn't it true.
[Fatal Error] :1:187: The entity name must immediately follow the '&' in the entity reference.
er.extensions.ERXGoogleSpell$CorrectionException: Failed to correct spelling of 'funnicity is funny. tell me isn't it true.'.
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:172)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:114)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:99)
at com.mtj.DirectAction.checkSpellingAction(DirectAction.java:1872)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.appserver.WODirectAction.performActionNamed(WODirectAction.java:128)
at com.webobjects.appserver._private.WOActionRequestHandler._handleRequest(WOActionRequestHandler.java:240)
at com.webobjects.appserver._private.WOActionRequestHandler.handleRequest(WOActionRequestHandler.java:145)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at com.mtj.Application.dispatchRequest(Application.java:669)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)
Caused by: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:267)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
at er.extensions.ERXGoogleSpell.suggestions(ERXGoogleSpell.java:148)
... 15 more
--------------------------------------------------------
Please let me know, if this email is not clear or need any information.
Thanks in advance.
Thank You,
Shravan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden