Selenium Webdriver 拼写检查

3

在使用Selenium WebDriver时,是否存在一种可能性可以对网页上显示的内容进行拼写检查。或者您能否建议相应的API。 谢谢, Eliyas


请提供有关情境的更多细节。 - Rupesh Shinde
1个回答

5
尝试使用谷歌 API 进行拼写检查。该解决方案适用于 Java - https://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() );

这将打印出文本“helloo worlrd”中所有可用的更正。

还可以为请求设置更多选项,

// Proxy settings
Configuration config = new Configuration();
config.setProxy( "my_proxy_host", 8080, "http" );

SpellChecker checker = new SpellChecker( config );
checker.setOverHttps( true ); // Use https (default true from v1.1)
checker.setLanguage( Language.ENGLISH ); // Use English (default)

SpellRequest request = new SpellRequest();
request.setText( "helloo helloo worlrd" );
request.setIgnoreDuplicates( true ); // Ignore duplicates

SpellResponse spellResponse = checker.check( request );

for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );

更新: 发现了更多的拼写检查器:

  1. JSpell - https://www.jspell.com/java-spell-checker.html
  2. JOrtho (免费) - http://jortho.sourceforge.net/
  3. Jazzy (免费) - http://sourceforge.net/projects/jazzy/

注意:本文中的HTML标签需保留。

有趣。是否存在C#等效的API? - Saifur
1
我看到了一些关于C#拼写检查器的讨论 - https://dev59.com/OHHYa4cB1Zd3GeqPJDwu,https://dev59.com/5GjWa4cB1Zd3GeqPrHwz。 - LittlePanda

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接