|
首先,需要安装西班牙语字典: sudo yum install aspell-es
在fedora上安装: [octopus@pc3 ~]$ sudo yum install aspell-es [sudo] password for octopus: Loaded plugins: langpacks Resolving Dependencies --> Running transaction check ---> Package aspell-es.x86_64 50:1.11-8.fc21 will be installed --> Finished Dependency Resolution
Dependencies Resolved
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: aspell-es x86_64 50:1.11-8.fc21 fedora 503 k
Transaction Summary ================================================================================ Install 1 Package
Total download size: 503 k Installed size: 1.4 M Is this ok [y/d/N]: y Downloading packages: aspell-es-1.11-8.fc21.x86_64.rpm | 503 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction (shutdown inhibited) Warning: RPMDB altered outside of yum. ** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows: maxthon-browser-stable-1.0.5.3-1.x86_64 has missing requires of libgcrypt.so.11()(64bit) mysql-workbench-5.2.47-2.fc19.x86_64 has missing requires of libctemplate.so.2()(64bit) wps-office-8.1.0.3724-0.1.b1p2.i686 has missing requires of libmng.so.1 Installing : 50:aspell-es-1.11-8.fc21.x86_64 1/1 Verifying : 50:aspell-es-1.11-8.fc21.x86_64 1/1
Installed: aspell-es.x86_64 50:1.11-8.fc21
Complete! [octopus@pc3 ~]$ sudo service httpd restart Redirecting to /bin/systemctl restart httpd.service [octopus@pc3 ~]$
然后记得重庆apache服务器
|
|
程序代码: <?php header("content-type:text/html;charset=western"); $pspell_link = pspell_new("es");
$words = array("sabado", "papa", "miecoles", "nules", "poca", "ustedes", "hablamos", "contemos", "aprender", "Septiembre", "November"); foreach ($words as $word) { if (!pspell_check($pspell_link, $word)) { $suggestions = pspell_suggest($pspell_link, $word); echo "Word <b>{$word}</b> isn't spelled correctly.<br>"; echo "<b>Suggestions: </b>"; echo join("<br>", $suggestions); echo "<br><br>"; } else { echo "Word <b>{$word}</b> is spelled correctly.<br>"; } } ?>
|
|
运行结果: Word sabado isn't spelled correctly. Suggestions: sábado sabido sobado sanado abado sabed sobad habado sacado sajado salado sabida sobada subido
Word papa is spelled correctly. Word miecoles isn't spelled correctly. Suggestions: miércoles méceles mociles macolles mieles recoles micelios mécelos macules mécelas macelos mizcales mezcles mueles mirles nicles coles meces mecos micos miles moles mecedles mecerles mezcales muelles macollas macúlese melles mielas méeles cicles
Word nules isn't spelled correctly. Suggestions: nulas nulos nieles nubles anules hules nubes pules rules tules blues nielas nicles nula únales úneles anuales les nobles nublas nublos nulo anales anulas ánulas ánulos lunes
Word poca is spelled correctly. Word ustedes is spelled correctly. Word hablamos is spelled correctly. Word contemos is spelled correctly. Word aprender is spelled correctly. Word Septiembre is spelled correctly. Word November isn't spelled correctly. Suggestions: Noviembre Nombre Nombré Nombra Nombro Nombró Nimbar Novelera Novelero Nimbare Novelare Nombren Nombres Nombrar Novelar Novemos Nimbe Hombre
|
|
值得注意的是,pspell_suggest函数返回的结果,其编码不是utf-8格式的。所以我加了一个header("content-type:text/html;charset=western");,否则重音字母会显示一个问号。
|
|
Word Agosto is spelled correctly. Word August isn't spelled correctly. Suggestions: Augusta Augusto Agosta Agoste Agosto Agosté Agostó Augustas Augustos Augita Gusta Gusto Agustín Aguosa Aguoso
Word esta is spelled correctly. Word estemos is spelled correctly. Word tendre isn't spelled correctly. Suggestions: tendré tender tenderé tendrá tendera tendero tenderá tendiere tendría cendre tundra
Word mayo is spelled correctly. Word hulio isn't spelled correctly. Suggestions: helio hilo hiló huelo julio huello halo hule tulio hallo heleo holeo hulla hielo hila hile hilé huido huiro huela huele quilo helios huelgo hulero hálito chulo
|
|
在该程序中,“八月”的英文拼写方法August被判为拼写错误,而西班牙语拼写方法Agosto被判为正确。 单词“tendre“因为少了个重音符号所以被判为拼写错误。tendré,其中拼写建议中也有 tendrá,这个是tener第三人称单数一般将来时态的变位。
|
|
|