Rusty3 Posted July 25, 2009 Share Posted July 25, 2009 I want to turn this: "helloworld", into this: "hello world" The idea is to use pspell to detect "hel loworld" is incorrect and "hello world" as correct. The algorithm removes one char each loop and detect the smallest world, stores it and loops througth the remaining text again to do the same thing... or at least it was supposed to do that... Of course "expertsexchange", should return "experts exchange" and "expert sex change". Any help greatly appreciated. Thanks. $sentence = "helloworld"; for ($f = 0; $f < 5; $f++) { list($firstword,$remaining) = extractfirstkeyword($sentence); echo "Firstword:$firstword<br>"; echo "Remaining:$remaining<br>"; echo "<hr>"; $sentence = $remaining; } function extractfirstkeyword($sentence) { $pspell_link = pspell_new("en"); $size = strlen($sentence); for ($i = 0; $i < $size-1; $i++) { $currentword = substr_replace($sentence ,"",($size - $i)); if (pspell_check($pspell_link, $currentword)) { $firstword = $currentword; $remaining = substr($sentence, strlen($firstword)); echo "currentword:$currentword<br>"; echo "remaining:$remaining<br>"; } } return array($firstword,$remaining); } Link to comment https://forums.phpfreaks.com/topic/167427-use-pspell-to-detect-words-on-sentence/ Share on other sites More sharing options...
Rusty3 Posted July 26, 2009 Author Share Posted July 26, 2009 No help? :'( Ok, if moderators have no issue with it, I am offering $5 Paypal to the first one who solves this. Link to comment https://forums.phpfreaks.com/topic/167427-use-pspell-to-detect-words-on-sentence/#findComment-883334 Share on other sites More sharing options...
Rusty3 Posted July 28, 2009 Author Share Posted July 28, 2009 No takers? Link to comment https://forums.phpfreaks.com/topic/167427-use-pspell-to-detect-words-on-sentence/#findComment-884379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.