i have created php code extracts valid words form text file :
$pspell_link = pspell_new("en"); $handle = fopen("list.txt", "r"); if ($handle) { while (($line = fgets($handle)) !== false) { $line = str_replace(' ', '', $line); $line = preg_replace('/\s+/', '', $line); if (pspell_check($pspell_link, $line)) { echo $line."<br>"; } } }
let's assume list.txt contains
ghgh fghy hello hellothere
the code above print : hello
what i'm trying print hellothere contains 2 valid words hello , there
(edited)
you can try pass constant pspell_run_together
option:
$pspell_link = pspell_new( "en", null, null, null, pspell_run_together );
from php documentation:
the mode parameter mode in spellchecker work. there several modes available:
pspell_fast - fast mode (least number of suggestions)
pspell_normal - normal mode (more suggestions)
pspell_bad_spellers - slow mode (a lot of suggestions)
pspell_run_together - consider run-together words legal compounds. is, "thecat" legal compound, although there should space between 2 words. changing setting affects results returned pspell_check(); pspell_suggest() still return suggestions.
furthermore, replacing spaces in line
, pass string "ghghfghyhellohellothere" pspell_check()
try instead exploding:
(...) $words = explode( ' ', $line ); foreach($words $word) { if (pspell_check($pspell_link, $word)) { echo "---> ".$word.php_eol; } } (...)
Comments
Post a Comment