oliverschloebe / google-spell-pspell
用于 Google Spell Check XML API 的 PHP Pspell 替代品。
8.0
2024-08-18 15:17 UTC
Requires
- php: ~8.0
README
用于 Google Spell Check XML API 的 PHP Pspell 替代品。要在您的服务器上运行,需要 Pspell。
为什么?
谷歌显然在 2013 年 7 月 9 日关闭了他们的拼写检查 API(www.google.com/tbproxy/spell),详见 这里。此 PHP 类是使用相同 XML 结构的 PHP Pspell 替代品。
用法
require_once 'spell-check-library.php'; $content = ""; $options = array( "lang" => 'en', "maxSuggestions" => 10, "customDict" => 0, "charset" => 'utf-8' ); $factory = new SpellChecker($options); $spell = $factory->create(trim("Ths is a tst")); header('Content-Type: text/xml; charset=UTF-8'); echo $spell->toXML();
以类似以下方式输出 Google 风格的 XML
<spellresult error="0" clipped="0" charschecked="12"> <c o="0" l="3" s="1">This Th's Thus Th HS</c> <c o="9" l="3" s="1">test tat ST St st</c> </spellresult>
... 您可以使用现有的拼写检查脚本(如 GoogieSpell),该脚本期望从谷歌返回结构化 XML 数据。
错误/建议
如果您发现错误或想为此项目做出贡献,请使用我的 GitHub 项目页面上的 问题跟踪器。
致谢
向 Sabin Iacob (m0n5t3r) 致敬。代码基本上来自 这里,但我移除了 Aspell 和 Google API 部分,并使其独立运行。