Find words missing their accents

I’m trying to find misspelled words in an uppercase string taking diacritics into account.
Is it possible with NSSpellChecker?

The following snippet considers the string as correct where it should be: “UN CRI PERÇANT À L’ORÉE DE LA FORÊT D’ÉBÈNE.”

use framework "Foundation"
use framework "AppKit"
use scripting additions

set theString to "UN CRI PERCANT A L'OREE DE LA FORET D'EBENE."
set theString to (current application's NSMutableString's stringWithString:theString)
set theChecker to current application's NSSpellChecker's sharedSpellChecker()
theChecker's setLanguage:"fr"
set theFound to (theChecker's checkString:theString range:{0, theString's |length|()} |types|:(2) options:(missing value) inSpellDocumentWithTag:0 orthography:(missing value) wordCount:(missing value))
return theFound as list

I found that I need to convert the string in lowercase, otherwise the words are not checked.

Now, I have another question:
Is it possible to automatically replace the misspelled words?

How about to use Microsoft Word for spell checking?
I don’t use Microsoft Word on French language environment. It has spell cheking & correction function.

Thank you Takaaki.
In French, diacritics are optional for capital letters*.
This is why most spell checkers will consider capitalized words without accents to be correct.
Word is no exception.


*This comes from the printing press: the accents were very difficult to reproduce with lead characters.

2 Likes