xref: /PHP-8.2/ext/pspell/tests/001.phpt (revision 74859783)
1--TEST--
2pspell basic tests (warning: may fail with pspell/aspell < GNU Aspell 0.50.3)
3--EXTENSIONS--
4pspell
5--SKIPIF--
6<?php
7if (!@pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER))) {
8    die("skip English dictionary is not available");
9}
10?>
11--FILE--
12<?php
13
14error_reporting(E_ALL);
15$string = "";
16$string .= "I will not buy this record, it is scratched. ";
17$string .= "Sorry ";
18$string .= "I will not buy this record, it is scratched. ";
19$string .= "Uh, no, no, no. This is a tobacconist's ";
20$string .= "Ah! I will not buy this tobacconist's, it is scratched. ";
21$string .= "No, no, no, no. Tobacco... um... cigarettes (holds up a pack). ";
22$string .= "Ya! See-gar-ets! Ya! Uh... My hovercraft is full of eels. ";
23$string .= "Sorry? ";
24$string .= "My hovercraft (pantomimes puffing a cigarette)... is full of eels (pretends to strike a match). ";
25$string .= "Ahh, matches!";
26
27$pspell = pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER));
28$array = explode(' ',preg_replace('/[^a-zA-Z0-9 ]/','',$string));
29for($i=0,$u=count($array);$i<$u;++$i) {
30    echo $array[$i].' : ';
31    if (!pspell_check($pspell, $array[$i])) {
32        echo "..false\n";
33        echo "Possible spellings: " . join(',',pspell_suggest ($pspell, $array[$i])) . "\n";
34    } else {
35        echo "true\n";
36    }
37}
38?>
39--EXPECTF--
40I : true
41will : true
42not : true
43buy : true
44this : true
45record : true
46it : true
47is : true
48scratched : true
49Sorry : true
50I : true
51will : true
52not : true
53buy : true
54this : true
55record : true
56it : true
57is : true
58scratched : true
59Uh : true
60no : true
61no : true
62no : true
63This : true
64is : true
65a : true
66tobacconists : true
67Ah : true
68I : true
69will : true
70not : true
71buy : true
72this : true
73tobacconists : true
74it : true
75is : true
76scratched : true
77No : true
78no : true
79no : true
80no : true
81Tobacco : true
82um : true
83cigarettes : true
84holds : true
85up : true
86a : true
87pack : true
88Ya : true
89Seegarets : ..false
90Possible spellings:%s,Regrets,%s,Cigarettes,%s
91Ya : true
92Uh : true
93My : true
94hovercraft : true
95is : true
96full : true
97of : true
98eels : true
99Sorry : true
100My : true
101hovercraft : true
102pantomimes : true
103puffing : true
104a : true
105cigarette : true
106is : true
107full : true
108of : true
109eels : true
110pretends : true
111to : true
112strike : true
113a : true
114match : true
115Ahh : ..false
116Possible spellings:%sAh,Aha,%s
117matches : true
118