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