hails
after hours of investigation, I found out that google search (AJAX) APIs DO NOT support the ability to spell check a string. Anyyay, there's a way to do it, via the google tool bar. All needs to be done is doing an XML HTTP Post right away to http://www.google.com/tbproxy/spell?lang=en&hl=en (being en = english / sp=spanish).
this is the XML you need to POST:and this is what google returns back:Code:<?xml version="1.0" encoding="utf-8" ?> <spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"> <text>Ths is a tst</text> </spellrequest>o: the offset from the start of the text of the wordCode:<?xml version="1.0" encoding="UTF-8"?> <spellresult error="0" clipped="0" charschecked="12"> <c o="0" l="3" s="1">This Th's Thus Th HS</c> <c o="9" l="3" s="1">test tat ST St st</c> </spellresult>
l: length of misspelled word
s: Confidence of the suggestion
text tab (chr(9)) delimited list of suggestions
Now, the good thing is that I found out how to make it to work via ASP/VBScript. All samples provided on the web have been just for C/Jscript/PHP . This is the VB code. Hope it helpsLatersCode:Dim xmlDoc Dim xmlHTTP Set xmlDoc = CreateObject("Microsoft.XMLDOM") tsearch = "ths is a tst" xmlDoc.async = False taux= "<spellrequest textalreadyclipped=""0"" ignoredups=""1"" ignoredigits=""1"" ignoreallcaps=""0"">" & _ "<text>" & tsearch & "</text>" & _ "</spellrequest>" xmlDoc.loadXML (taux) 'loads the XML from string 'depending on the server you are hosting this code, it could be "Microsoft.XMLHttp" or "MSXML2.ServerXMLHTTP" 'Set xmlHTTP = CreateObject("Microsoft.XMLHttp") Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP") xmlHTTP.Open "POST","http://www.google.com/tbproxy/spell?lang=en&hl=en", False xmlHTTP.send xmlDoc.xml 'do the HTTP post out to google trevisedstring = xmlHTTP.responseXML.xml response.write trevisedstring 'first word will be always be the one you need, ignore the rest 'now all you need to do is parsing the XML response as normally 'you will probably start with something like: Set objXMLDoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument") objXMLDoc.async = false objXMLDoc.validateOnParse = False objxmldoc.loadXML (xmlHTTP.responseXML.xml) 'do the parsing here for each <c> ... </c> node set objxmldoc=nothing set xmlHTTP=nothing set xmlDoc=nothing
Diego


Reply With Quote


Bookmarks