001.phpt 2.3 KB

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