Back to LanguageTool Homepage - Privacy - Imprint

How spell checker comparing lower case word with cameCase dictionary word?


(surekha) #1

I have been waiting for solution for case insensitive spell check but I did not get 100% solution.
@Yakov gave me a temporary solution. Thanks for that but still I have issues with case insensitive check.
As Yakov replied in GitHub https://github.com/languagetool-org/languagetool/pull/1425 I have overriden the isMissplelled api as below

	if (!speller.isMisspelled(word.toLowerCase(conversionLocale))) {
		return false;
	}else if(!speller.isMisspelled(word.toUpperCase(conversionLocale)))
	{
		return false;
	}
    //for initcap words
	else if(!speller.isMisspelled(word.substring(0, 1).toUpperCase(conversionLocale) + word.substring(1).toLowerCase(conversionLocale)))
	{
		return false;
	}

but it is still not covering all cases.
Ex: I am passing word “mastercard” for spell check.
Actual word in dictionary is “MasterCard” so, it is failing. I have added logic to convert each letter in my word to capital and checking as a temporary solution. This will deffinetly cause a performance issue.
I am looking for better solution. Please provide me the solution.

I feel some issue with this condition

Please check below part for all cases.
Ex: BLue, friday (one is mixed case and another is not)

  !(!isMixedCase(wordToCheck) && 
        (isInDictionary(wordToCheck.toLowerCase(dictionaryMetadata.getLocale())) 
            || isAllUppercase(wordToCheck) && isInDictionary(initialUppercase(wordToCheck)))) 

Taken from Speller.java(isMisspelled api)

  wordToCheck.length() > 0
   && (!dictionaryMetadata.isIgnoringPunctuation() || isAlphabetic)
   && (!dictionaryMetadata.isIgnoringNumbers() || containsNoDigit(wordToCheck))
   && !(dictionaryMetadata.isIgnoringCamelCase() && isCamelCase(wordToCheck))
   && !(dictionaryMetadata.isIgnoringAllUppercase() && isAlphabetic && 
                isAllUppercase(wordToCheck))
   && !isInDictionary(wordToCheck)
   && (!dictionaryMetadata.isConvertingCase() || 
       !(!isMixedCase(wordToCheck) && 
            (isInDictionary(wordToCheck.toLowerCase(dictionaryMetadata.getLocale())) 
             || isAllUppercase(wordToCheck) && isInDictionary(initialUppercase(wordToCheck)))));` 

Please check and provide me the solution. I have been looking for this but I did not get it.


(Yakov) #2

II will make a special version of the en_US dictionary today.

Upd.
Done. But speller with this dict fails some tests for suggestion.
en_US.zip


(surekha) #3

Thanks a lot for your help.
I am not using suggestions. I think It is fine for me.