"Fossies" - the Fresh Open Source Software Archive

Member "php-8.0.28-src/ext/pspell/tests/001.phpt" (14 Feb 2023, 2349 Bytes) of package /windows/www/php-8.0.28-src.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 --TEST--
    2 pspell basic tests (warning: may fail with pspell/aspell < GNU Aspell 0.50.3)
    3 --SKIPIF--
    4 <?php
    5 if (!extension_loaded("pspell")) die("skip");
    6 if (!@pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER))) {
    7     die("skip English dictionary is not available");
    8 }
    9 ?>
   10 --FILE--
   11 <?php
   12 
   13 error_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));
   28 for($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--
   39 I : true
   40 will : true
   41 not : true
   42 buy : true
   43 this : true
   44 record : true
   45 it : true
   46 is : true
   47 scratched : true
   48 Sorry : true
   49 I : true
   50 will : true
   51 not : true
   52 buy : true
   53 this : true
   54 record : true
   55 it : true
   56 is : true
   57 scratched : true
   58 Uh : true
   59 no : true
   60 no : true
   61 no : true
   62 This : true
   63 is : true
   64 a : true
   65 tobacconists : true
   66 Ah : true
   67 I : true
   68 will : true
   69 not : true
   70 buy : true
   71 this : true
   72 tobacconists : true
   73 it : true
   74 is : true
   75 scratched : true
   76 No : true
   77 no : true
   78 no : true
   79 no : true
   80 Tobacco : true
   81 um : true
   82 cigarettes : true
   83 holds : true
   84 up : true
   85 a : true
   86 pack : true
   87 Ya : true
   88 Seegarets : ..false
   89 Possible spellings:%s,Regrets,%s,Cigarettes,%s
   90 Ya : true
   91 Uh : true
   92 My : true
   93 hovercraft : true
   94 is : true
   95 full : true
   96 of : true
   97 eels : true
   98 Sorry : true
   99 My : true
  100 hovercraft : true
  101 pantomimes : true
  102 puffing : true
  103 a : true
  104 cigarette : true
  105 is : true
  106 full : true
  107 of : true
  108 eels : true
  109 pretends : true
  110 to : true
  111 strike : true
  112 a : true
  113 match : true
  114 Ahh : ..false
  115 Possible spellings:%sAh,Aha,%s
  116 matches : true