PlatformSpellChecker

Platform-specific spell checker that provides spell checking functionality.

On Android, this uses the system's TextServicesManager and SpellCheckerSession. On Desktop, this uses native spell checking APIs (Windows Spell Checking API, macOS NSSpellChecker, or Hunspell on Linux).

Platform-specific spell checker that provides spell checking functionality.

On Android, this uses the system's TextServicesManager and SpellCheckerSession. On Desktop, this uses native spell checking APIs (Windows Spell Checking API, macOS NSSpellChecker, or Hunspell on Linux).

Desktop JVM implementation of PlatformSpellChecker.

Automatically detects the operating system and uses the appropriate native spell checker:

  • Windows 8+: Windows Spell Checking API via JNA/COM

  • macOS: NSSpellChecker via JNA/Objective-C runtime

  • Linux: Hunspell/Enchant (to be implemented)

iOS implementation of PlatformSpellChecker using UITextChecker.

UITextChecker is part of UIKit and provides spell checking functionality using the system's dictionaries and language settings.

Constructors

Link copied to clipboard
constructor(context: Context, locale: SpLocale? = null, operationTimeout: Duration = DEFAULT_OPERATION_TIMEOUT)
constructor(locale: SpLocale? = null)
constructor(locale: SpLocale? = null)

Functions

Link copied to clipboard
actual suspend fun addToDictionary(word: String, scope: DictionaryScope)

Adds word to the user dictionary. Subsequent spell checks will treat it as correctly spelled.

expect suspend fun addToDictionary(word: String, scope: DictionaryScope = DictionaryScope.AppLocal)

Adds word to the user dictionary. Subsequent spell checks will treat it as correctly spelled.

actual suspend fun addToDictionary(word: String, scope: DictionaryScope)

Adds word to the user dictionary. Subsequent spell checks will treat it as correctly spelled.

actual suspend fun addToDictionary(word: String, scope: DictionaryScope)

Adds word to the user dictionary. Subsequent spell checks will treat it as correctly spelled.

Link copied to clipboard
actual suspend fun checkMultiword(text: String): List<SpellingCorrection>

Performs spell check on a sentence or multi-word text. Returns a list of SpellingCorrection objects containing the misspelled words, their positions in the original text, and suggested corrections. Returns an empty list if no spelling errors are found.

expect suspend fun checkMultiword(text: String): List<SpellingCorrection>

Performs spell check on a sentence or multi-word text. Returns a list of SpellingCorrection objects containing the misspelled words, their positions in the original text, and suggested corrections. Returns an empty list if no spelling errors are found.

actual suspend fun checkMultiword(text: String): List<SpellingCorrection>

Performs spell check on a sentence or multi-word text. Returns a list of SpellingCorrection objects containing the misspelled words, their positions in the original text, and suggested corrections. Returns an empty list if no spelling errors are found.

actual suspend fun checkMultiword(text: String): List<SpellingCorrection>

Performs spell check on a sentence or multi-word text. Returns a list of SpellingCorrection objects containing the misspelled words, their positions in the original text, and suggested corrections. Returns an empty list if no spelling errors are found.

Link copied to clipboard
actual suspend fun checkWord(word: String, maxSuggestions: Int): WordCheckResult

Checks a single word and returns a structured result indicating if it is spelled correctly. When misspelled, includes up to maxSuggestions suggestions (may be empty).

expect suspend fun checkWord(word: String, maxSuggestions: Int = 5): WordCheckResult

Checks a single word and returns a structured result indicating if it is spelled correctly. When misspelled, includes up to maxSuggestions suggestions (may be empty).

actual suspend fun checkWord(word: String, maxSuggestions: Int): WordCheckResult

Checks a single word and returns a structured result indicating if it is spelled correctly. When misspelled, includes up to maxSuggestions suggestions (may be empty).

actual suspend fun checkWord(word: String, maxSuggestions: Int): WordCheckResult

Checks a single word and returns a structured result indicating if it is spelled correctly. When misspelled, includes up to maxSuggestions suggestions (may be empty).

Link copied to clipboard
actual open override fun close()

Releases any platform resources held by the spell checker (if applicable). Safe to call multiple times. No-op on platforms that do not require cleanup.

expect fun close()

Releases any platform resources held by the spell checker (if applicable). Safe to call multiple times. No-op on platforms that do not require cleanup.

actual open override fun close()

Releases any platform resources held by the spell checker (if applicable). Safe to call multiple times. No-op on platforms that do not require cleanup.

actual open override fun close()

Releases any platform resources held by the spell checker (if applicable). Safe to call multiple times. No-op on platforms that do not require cleanup.

Link copied to clipboard
actual suspend fun ignoreWord(word: String)

Marks word as ignored for the lifetime of this checker. Unlike addToDictionary, ignores are not persisted and are not returned by userDictionary. Where the platform provides a native ignore facility (iOS, macOS, Windows, Linux/Hunspell) it is used; otherwise the word is filtered out of results in this library.

expect suspend fun ignoreWord(word: String)

Marks word as ignored for the lifetime of this checker. Unlike addToDictionary, ignores are not persisted and are not returned by userDictionary. Where the platform provides a native ignore facility (iOS, macOS, Windows, Linux/Hunspell) it is used; otherwise the word is filtered out of results in this library.

actual suspend fun ignoreWord(word: String)

Marks word as ignored for the lifetime of this checker. Unlike addToDictionary, ignores are not persisted and are not returned by userDictionary. Where the platform provides a native ignore facility (iOS, macOS, Windows, Linux/Hunspell) it is used; otherwise the word is filtered out of results in this library.

actual suspend fun ignoreWord(word: String)

Marks word as ignored for the lifetime of this checker. Unlike addToDictionary, ignores are not persisted and are not returned by userDictionary. Where the platform provides a native ignore facility (iOS, macOS, Windows, Linux/Hunspell) it is used; otherwise the word is filtered out of results in this library.

Link copied to clipboard
actual suspend fun isWordCorrect(word: String): Boolean

Checks if a single word exists in the active dictionary and is considered correctly spelled. Returns true when the word is recognized by the platform spell checker or appears in the user dictionary (see addToDictionary) or session ignores (see ignoreWord); false otherwise.

expect suspend fun isWordCorrect(word: String): Boolean

Checks if a single word exists in the active dictionary and is considered correctly spelled. Returns true when the word is recognized by the platform spell checker or appears in the user dictionary (see addToDictionary) or session ignores (see ignoreWord); false otherwise.

actual suspend fun isWordCorrect(word: String): Boolean

Checks if a single word exists in the active dictionary and is considered correctly spelled. Returns true when the word is recognized by the platform spell checker or appears in the user dictionary (see addToDictionary) or session ignores (see ignoreWord); false otherwise.

actual suspend fun isWordCorrect(word: String): Boolean

Checks if a single word exists in the active dictionary and is considered correctly spelled. Returns true when the word is recognized by the platform spell checker or appears in the user dictionary (see addToDictionary) or session ignores (see ignoreWord); false otherwise.

Link copied to clipboard
actual suspend fun removeFromDictionary(word: String, scope: DictionaryScope)

Removes word from the user dictionary previously added via addToDictionary.

expect suspend fun removeFromDictionary(word: String, scope: DictionaryScope = DictionaryScope.AppLocal)

Removes word from the user dictionary previously added via addToDictionary.

actual suspend fun removeFromDictionary(word: String, scope: DictionaryScope)

Removes word from the user dictionary previously added via addToDictionary.

actual suspend fun removeFromDictionary(word: String, scope: DictionaryScope)

Removes word from the user dictionary previously added via addToDictionary.

Link copied to clipboard
actual suspend fun setUserDictionary(words: Collection<String>)

Atomically replaces the DictionaryScope.AppLocal user dictionary with words (normalized the same way as addToDictionary: trimmed, case-insensitive) and resets this checker's session ignore set. Use to switch between independent dictionary contexts without tearing down the checker.

expect suspend fun setUserDictionary(words: Collection<String>)

Atomically replaces the DictionaryScope.AppLocal user dictionary with words (normalized the same way as addToDictionary: trimmed, case-insensitive) and resets this checker's session ignore set. Use to switch between independent dictionary contexts without tearing down the checker.

actual suspend fun setUserDictionary(words: Collection<String>)

Atomically replaces the DictionaryScope.AppLocal user dictionary with words (normalized the same way as addToDictionary: trimmed, case-insensitive) and resets this checker's session ignore set. Use to switch between independent dictionary contexts without tearing down the checker.

actual suspend fun setUserDictionary(words: Collection<String>)

Atomically replaces the DictionaryScope.AppLocal user dictionary with words (normalized the same way as addToDictionary: trimmed, case-insensitive) and resets this checker's session ignore set. Use to switch between independent dictionary contexts without tearing down the checker.

Link copied to clipboard
actual fun userDictionary(): Set<String>
expect fun userDictionary(): Set<String>
actual fun userDictionary(): Set<String>
actual fun userDictionary(): Set<String>