aquanuke Posted February 24, 2011 Share Posted February 24, 2011 I have a pspell script and I want it to ignore upper case. ie at the moment if I check spelling for say christopher it returns spelling error of Christopher (upper case C) <?php $query = 'helllo'; $pspell_config = pspell_config_create("en"); pspell_config_ignore($pspell_config, 5); pspell_config_mode($pspell_config, PSPELL_FAST); pspell_config_personal($pspell_config, "/home/*/public_html/custom.pws"); pspell_config_repl($pspell_config, "/home/*/public_html/custom.repl"); $pspell_link = pspell_new_config($pspell_config); $words = preg_split ("/\s+/", $query); $ii = count($words); global $spellchecked; $spellchecked = ""; for($i=0;$i<$ii;$i++){ if (pspell_check($pspell_link, $words[$i])) { $spellchecked .= $words[$i]." "; } else { $erroneous = "yes"; $suggestions = pspell_suggest($pspell_link, $words[$i]); $spellchecked .= $suggestions[0]." "; } } if($erroneous == "yes") { $spellchecked2 = str_replace(" ", "+", $spellchecked); echo "Did you mean: <a href=GetSearchResults.php?Query=$spellchecked2&catID=&siteID=3><i>".$spellchecked."</a></i>?"; } else { echo $spellchecked . " is a valid word/phrase"; } ?> Link to comment https://forums.phpfreaks.com/topic/228670-pspell-ignore-case/ Share on other sites More sharing options...
cyberRobot Posted February 24, 2011 Share Posted February 24, 2011 You could make the word lower case before testing with strtolower() http://php.net/manual/en/function.strtolower.php Link to comment https://forums.phpfreaks.com/topic/228670-pspell-ignore-case/#findComment-1179064 Share on other sites More sharing options...
cyberRobot Posted February 24, 2011 Share Posted February 24, 2011 Nevermind, it sounds like switching to lowercase will cause problems with other matches: http://www.phpfreaks.com/forums/php-coding-help/pspell-case-insensitive/ Link to comment https://forums.phpfreaks.com/topic/228670-pspell-ignore-case/#findComment-1179069 Share on other sites More sharing options...
aquanuke Posted February 24, 2011 Author Share Posted February 24, 2011 thanks that will probs work out for me. In the aspell manual it has ignore-case (boolean) ignore case when checking words I guess its not been added to php yet Link to comment https://forums.phpfreaks.com/topic/228670-pspell-ignore-case/#findComment-1179198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.