通过C#访问Google拼写/建议API [英] Accessing Google spelling/suggestion API via C#

查看:143
本文介绍了通过C#访问Google拼写/建议API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我正在使用的应用程序中使用Google的拼写更正/建议.我已经在Google上进行了搜索,但是我发现的只是Google取消的SOAP API和新近弃用的XML Web Search API的示例.

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.

我现在可以使用哪个API?你能举一个使用它的例子吗?周围有C#包装器吗?

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

谢谢!

Bing和Yahoo拼写API的问题在于它们似乎要对照字典进行检查,因此某些品牌/产品名称无法识别,Google似乎是基于常见的拼写错误和最终访问的页面,因此可以建议对最常见的事物进行拼写检查,例如:

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:

如果您输入

你好词"

"hello word"

它会说

你是说世界你好吗?"

"do you mean hello world?"

即使拼写正确

推荐答案

如果有的话,您可以使用一个小的C#程序自己构建它,该程序会下载google搜索特定单词的搜索页面,即

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

片段,如果措词不正确,将包含在<p class="sp_cnt">中,您可以从其中提取建议的正确拼写

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

更新:实际上,取决于几件事,它也可能位于<p class="ssp">中,我认为这取决于短语的长度,无论如何,您都可以搜索<span id="topstuff">并找到带有任一类,然后从那里提取正确的拼写,请注意,在"ssp"情况下,措辞是不同的:

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:

您的意思是:显示phi的结果

Did you mean: showing result for phi

如果代码符合XHTML,则可以将页面解析为XML,然后是hurrah,否则您必须对其进行一些调整,使其格式正确"以将XML作为XMLDocument加载.之后,应该很容易找到告诉您适当拼写的页面片段(应该存在)

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

这篇关于通过C#访问Google拼写/建议API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆