Jump to content

pspell ignore case


aquanuke

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.