目前共有7篇帖子。 内容转换:不转换▼
 
点击 回复
376 6
PHP的pspell庫可以對西班牙語單詞的拼寫進行檢查
一派护法 十九级
1楼 发表于:2015-3-29 00:01
首先,需要安裝西班牙語字典:
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服務器
一派护法 十九级
2楼 发表于:2015-3-29 00:02
程序代碼:
<?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>";
    }
}
?>

一派护法 十九级
3楼 发表于:2015-3-29 00:02
運行結果:
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


一派护法 十九级
4楼 发表于:2015-3-29 00:03
值得注意的是,pspell_suggest函數返回的結果,其編碼不是utf-8格式的。所以我加了一個header("content-type:text/html;charset=western");,否則重音字母會顯示一個問號。
一派护法 十九级
5楼 发表于:2015-3-29 00:05
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

一派护法 十九级
6楼 发表于:2015-3-29 00:09
在該程序中,“八月”的英文拼寫方法August被判爲拼寫錯誤,而西班牙語拼寫方法Agosto被判爲正確。
單詞“tendre“因爲少了個重音符號所以被判爲拼寫錯誤。tendré,其中拼寫建議中也有 tendrá,這個是tener第三人稱單數一般將來時態的變位。
一派护法 十九级
7楼 发表于:2015-3-29 00:11

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:376 回复数:6
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2015-3-29 00:11
 
©2010-2024 Arslanbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。