Google Spell Checker Api Asp.Net C#
来源:互联网 发布:kakakaoo的淘宝网店 编辑:程序博客网 时间:2024/06/08 09:49
In this article you will learn how to use the Google Spell Checker API in Asp.Net C# apps
The API is very simple, spell checking is done through a XML http post to the following url
https://www.google.com/tbproxy/spell?lang=en:
Request XML structure
<?xmlversion=”1.0”encoding=”utf-8”?>
<spellrequesttextalreadyclipped=”0”ignoredups=”0”ignoredigits=”1”ignoreallcaps=”1“>
<text>Hotal</text>
</spellrequest>
<spellrequesttextalreadyclipped=”0”ignoredups=”0”ignoredigits=”1”ignoreallcaps=”1“>
<text>Hotal</text>
</spellrequest>
The folloing are the Response XML from Google API
<?xmlversion=”1.0”encoding=”UTF-8“?>
<spellresulterror=”0”clipped=”0”charschecked=”12“>
<c o=”0”l=”5”s=”0″>Hotel Hotly Total Ital Hots</c>
</spellresult>
<spellresulterror=”0”clipped=”0”charschecked=”12“>
<c o=”0”l=”5”s=”0″>Hotel Hotly Total Ital Hots</c>
</spellresult>
See the complete code here
public static string DidYouMean(string aWord){ string retValue = string.Empty; try { string uri = "http://www.google.com/tbproxy/spell?"; using (WebClient webClient = new WebClient()) { WebProxy myProxy = new WebProxy(@"127.0.0.1:48100", true); webClient.Proxy = myProxy; string postData = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><spellrequest textalreadyclipped=\"0\" ignoredups=\"0\" ignoredigits=\"1\" " + "ignoreallcaps=\"1\"><text>{0}</text></spellrequest>", aWord); webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); byte[] bytes = Encoding.ASCII.GetBytes(postData); byte[] response = webClient.UploadData(uri, "POST", bytes); string data = Encoding.ASCII.GetString(response); if (data != string.Empty) { retValue = Regex.Replace(data, @"<(.|\n)*?>", string.Empty).Split('\t')[0]; } } } catch (Exception ex) { } return retValue;}private void btnSearch_Click(object sender, EventArgs e){ string word = DidYouMean(this.textBox1.Text); if (word != string.Empty) { this.label1.Text = word; }}
http://www.sxlist.com/techref/spell.asp
http://didyoumean.info/
http://didyoumean.info/
- Google Spell Checker Api Asp.Net C#
- Spell checker
- Spell Checker
- Spell Checker
- Spell checker
- Spell Checker
- Spell checker
- Spell checker
- Spell checker
- 1035 Spell checker
- poj-1035-Spell checker
- 1035 Spell checker
- poj 1035 Spell checker
- Poj 1035 --Spell checker
- ural 1038 Spell Checker
- 1035 Spell checker
- Spell checker--POJ 1035
- poj 1035 Spell checker
- tttitletttttttttt
- PL/SQL Developer导入导出数据库
- 什么是kbuild?
- 111tttitletttttttttt
- 222tttitletttttttttt
- Google Spell Checker Api Asp.Net C#
- 主流报表制作工具之王者争夺战:功能大PK系列之单元格字体删除线
- Java开源 J2EE框架
- code::blocks自动补全诸如socket或者其它一些库中的函数
- vfp9.0通过WebBrowser控件获取QQ新闻标题及链接
- Microsoft .NET Framework 3.5 sp1 安装速度慢,快速离线安装的方法【标红方法较好用】
- SDRAM中数据掩码的作用(DQM)
- java知识 原生数据类型
- 邀请vc高手参与开发纯文本人工智能