Getting the list of misspelled words
Contents
[
Hide
]
Aspose.OCR can automatically generate a list of misspelled words found in an image and their suggested replacements in descending order of suitability. This list is fetched using getSpellCheckErrorList
method of RecognitionResult
class.
This functionality supports the following languages:
Value | Language |
---|---|
SpellCheckLanguage.Cze |
Czech |
SpellCheckLanguage.Dan |
Danish |
SpellCheckLanguage.Deu |
German |
SpellCheckLanguage.Dum |
Dutch |
SpellCheckLanguage.Eng |
English |
SpellCheckLanguage.Est |
Estonian |
SpellCheckLanguage.Fin |
Finnish |
SpellCheckLanguage.Fra |
French |
SpellCheckLanguage.Ita |
Italian |
SpellCheckLanguage.Lav |
Latvian |
SpellCheckLanguage.Lit |
Lithuanian |
SpellCheckLanguage.Pol |
Polish |
SpellCheckLanguage.Por |
Portuguese |
SpellCheckLanguage.Rum |
Romanian |
SpellCheckLanguage.Slk |
Slovak |
SpellCheckLanguage.Slv |
Slovene |
SpellCheckLanguage.Spa |
Spanish |
SpellCheckLanguage.Swe |
Swedish |
Found errors and suggested substitutions are provided as a list of SpellCheckError
objects. The substitutions are ordered by Levenshtein distance from the misspelled word, so the most likely replacements come first.
AsposeOCR api = new AsposeOCR();
// Extract text from image
RecognitionResult result = api.RecognizePage("source.png", new RecognitionSettings());
// Spelling suggestions
result.getSpellCheckErrorList(com.aspose.ocr.SpellCheck.SpellCheckLanguage.Eng).forEach((correction) -> {
System.out.println("Found misspelled word \"" + correction.word + "\" at position " + correction.startPosition);
if(correction.suggestedWords.size() > 0) System.out.println("Most likely replacement: " + correction.get(0).word);
});