summaryrefslogtreecommitdiff
path: root/ext/pspell/tests/001.phpt
blob: 4853ab597e526963d20195a9aada0224a0c5c7ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--TEST--
pspell basic tests (warning: may fail with pspell/aspell < GNU Aspell 0.50.3)
--SKIPIF--
<?php
if (!extension_loaded("pspell")) die("skip");
if (!@pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER))) {
	die("skip English dictionary is not available");
}
?>
--FILE--
<?php // $Id$

error_reporting(E_ALL);
$string = "";
$string .= "I will not buy this record, it is scratched. ";
$string .= "Sorry ";
$string .= "I will not buy this record, it is scratched. ";
$string .= "Uh, no, no, no. This is a tobacconist's ";
$string .= "Ah! I will not buy this tobacconist's, it is scratched. ";
$string .= "No, no, no, no. Tobacco... um... cigarettes (holds up a pack). ";
$string .= "Ya! See-gar-ets! Ya! Uh... My hovercraft is full of eels. ";
$string .= "Sorry? ";
$string .= "My hovercraft (pantomimes puffing a cigarette)... is full of eels (pretends to strike a match). ";
$string .= "Ahh, matches!";

$pspell = pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER));
$array = explode(' ',preg_replace('/[^a-zA-Z0-9 ]/','',$string));
for($i=0,$u=count($array);$i<$u;++$i) {
    echo $array[$i].' : ';
    if (!pspell_check($pspell, $array[$i])) {
        echo "..false\n";
        echo "Possible spellings: " . join(',',pspell_suggest ($pspell, $array[$i])) . "\n";
    } else {
        echo "true\n";
    }
}
?>
--EXPECTF--
I : true
will : true
not : true
buy : true
this : true
record : true
it : true
is : true
scratched : true
Sorry : true
I : true
will : true
not : true
buy : true
this : true
record : true
it : true
is : true
scratched : true
Uh : true
no : true
no : true
no : true
This : true
is : true
a : true
tobacconists : true
Ah : true
I : true
will : true
not : true
buy : true
this : true
tobacconists : true
it : true
is : true
scratched : true
No : true
no : true
no : true
no : true
Tobacco : true
um : true
cigarettes : true
holds : true
up : true
a : true
pack : true
Ya : true
Seegarets : ..false
Possible spellings:%s,Regrets,%s,Cigarettes,%s
Ya : true
Uh : true
My : true
hovercraft : true
is : true
full : true
of : true
eels : true
Sorry : true
My : true
hovercraft : true
pantomimes : true
puffing : true
a : true
cigarette : true
is : true
full : true
of : true
eels : true
pretends : true
to : true
strike : true
a : true
match : true
Ahh : ..false
Possible spellings:%sAh,Aha,%s
matches : true