Accessing Google spelling/suggestion API via C# [closed]

岁酱吖の 提交于 2019-12-21 07:26:55

问题


I want to use Google's spelling correction/suggestions in an app I'm doing. I've googled it but all I found was examples for Google's canceled SOAP API and the newly deprecated XML Web Search API.

I just want to be able to send a search query and get back the suggested correction.

Which API can I use now? Could you give an example of its usage? Is there a C# Wrapper around it?

Thanks!

EDIT:

The problem with Bing and Yahoo's spelling API is that they seem to check against a dictionary, so some brand/product names are not recognized, Googles seem to be based on usual spelling mistakes and pages they ended up visiting, so it can suggest spell checking for the most common things, ie:

if you type

"hello word"

it will say

"do you mean hello world?"

even though it is spelled correctly


回答1:


If anything, you could build it yourself with a small C# program that downloaded google's search page for a particular word i.e http://www.google.com/search?q=filipines and search for the

Showing results for philippines. Search instead for filipines

fragment, which would be contained in a <p class="sp_cnt"> in case the wording was incorrect, from there you could just extract the suggested correct spelling

Update: Actually, depending on a couple of things, it could also be in a <p class="ssp">, I think it depends on how long the phrase is, anyways you could search for the <span id="topstuff"> and find a child paragraph with either class, and extract the correct spelling from there, note that in the "ssp" case the wording is different:

Did you mean: showing result for phi

You could parse the page as an XML, if the code is XHTML compliant, then hurrah, otherwise you would have to tweak it a bit, making it "well-formed" to be loaded with XML as a XMLDocument. After that it should be easy finding the fragment of the page (should it exist) that tells you the appropriate spelling




回答2:


If you don't have to use Google, the Bing API actually includes Spelling, you can use http://bingsharp.codeplex.com/




回答3:


Somewhat late, but Google's spelling checker is part of the Search API. See

http://code.google.com/apis/soapsearch/reference.html#1_3




回答4:


Google Search Api Sample Code http://deepumi.wordpress.com/2010/05/20/google-spell-checker-api-asp-net-c/ As u will use Proxy Authentication Error will come then add following line of code to remove error System.Net.IWebProxy theProxy = webclient.Proxy; if (theProxy != null) theProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;




回答5:


Here is a list of all google APIs: http://code.google.com/apis/ajax/playground/

Unfortunately it seems that there is no spelling API.




回答6:


There is a Google-API Spelling implementation in Java, implemented by Kamran. It is not that complicated as I looked into the source. You might consider translating it into C# ?!

The project page states that

This is a simple Java API that makes it very easy to call Google's spell checker service from Java applications.

but which google spell checker service it uses I don't know, but it works pretty good.



来源:https://stackoverflow.com/questions/4238924/accessing-google-spelling-suggestion-api-via-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!