Google的拼写检查程序http://code.google.com/p/google-api-spelling-java/
SpellChecker checker = new SpellChecker();
SpellResponse spellResponse = checker.check( "helloo worlrd" );
for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
Run Code Online (Sandbox Code Playgroud)
这非常类似于您使用Gmail或Google服务(例如translate.google.com或搜索)时,如果您有拼写错误,则会为您提供替代建议.
后台会发生什么?
SpellChecker类将请求转换为XML并将其发送到Google的拼写检查服务.响应也是XML格式,然后反序列化为简单的POJO.
对上面第一个示例的请求如下所示:
Run Code Online (Sandbox Code Playgroud)<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <spellrequest textalreadyclipped="0" ignoredigits="1" ignoreallcaps="1" ignoredups="0"> <text>helloo worlrd</text> </spellrequest>响应XML看起来像:
Run Code Online (Sandbox Code Playgroud)<?xml version="1.0" encoding="UTF-8"?> <spellresult error="0" clipped="0" charschecked="13"> <c o="0" l="6" s="1">hello Helli hell hallo hullo</c> <c o="7" l="6" s="1">world whorled wold warlord would</c> </spellresult>
虽然没试过.
更新:
谷歌可能已开始为此收费.我没有时间来检查这个.有人可以证实.就谷歌而言,他们似乎已经弃用了新的和付费的旧API.
早期免费版本的Translate API发生了什么变化?
截至2011年12月1日,Google Translate API v1已不再提供,已被Google Translate API v2取代.Google Translate API v1于2011年5月26日正式弃用.由于广泛滥用造成的巨大经济负担,决定弃用API并将其替换为付费服务.
| 归档时间: |
|
| 查看次数: |
13093 次 |
| 最近记录: |