Google真是宝库,想调用拼写检查的API
这是一个Java调用的lib库和例子,很简单就可以调用了
http://code.google.com/p/google-api-spelling-java/
可以使用SVN检出源码 http://google-api-spelling-java.googlecode.com/svn/trunk/
貌似是用maven管理的,由于目前还没接触maven,checkout后断开svn连接,手动改了目录,把依赖的jar包加到路径下,才可以运行...鄙视自己一下...
下面的源码里的测试代码,我加了一个判空
Java代码
复制package org.xeustechnologies.googleapi.spelling;
publicclass Test {
@org.junit.Test
publicvoid check() {
SpellChecker checker = new SpellChecker();
checker.setOverHttps( true ); // Now default is true
checker.setLanguage( Language.ENGLISH ); // Default is English
SpellRequest request = new SpellRequest();
request.setText( "google baidu twitter facebook yahoo microsoft ibm" );
request.setIgnoreDuplicates( true );
SpellResponse spellResponse = checker.check( request );
if(spellResponse.getCorrections() != null){
for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
}else{
System.out.println("Its OK!");
}
}
}
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.
后台实现原理在项目页面也讲了
应该是向 www.google.com/tbproxy/spell 接口发送一个xml文件
Xml代码
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~