All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.darkrockstudios.symspellkt.api.SpellChecker.kt Maven / Gradle / Ivy

Go to download

A Kotlin Multiplatform implementation of the SymSpell Spell Checking algorithm.

There is a newer version: 3.1.0
Show newest version
package com.darkrockstudios.symspellkt.api

import com.darkrockstudios.symspellkt.common.Composition
import com.darkrockstudios.symspellkt.common.SpellCheckSettings
import com.darkrockstudios.symspellkt.common.SuggestionItem
import com.darkrockstudios.symspellkt.common.Verbosity
import com.darkrockstudios.symspellkt.exception.SpellCheckException

/**
 * Abstract class for the Spell Correction
 */
abstract class SpellChecker(
	val dictionary: DictionaryHolder,
	protected val stringDistance: StringDistance,
	protected val spellCheckSettings: SpellCheckSettings,
) {
	@Throws(SpellCheckException::class)
	abstract fun lookup(
		word: String,
		verbosity: Verbosity = spellCheckSettings.verbosity,
		editDistance: Double = spellCheckSettings.maxEditDistance,
	): List

	@Throws(SpellCheckException::class)
	abstract fun lookupCompound(
		word: String,
		editDistance: Double = spellCheckSettings.maxEditDistance,
		tokenizeOnWhiteSpace: Boolean = true,
	): List

	@Throws(SpellCheckException::class)
	abstract fun wordBreakSegmentation(
		phrase: String,
		maxSegmentationWordLength: Int = spellCheckSettings.prefixLength,
		maxEditDistance: Double = spellCheckSettings.maxEditDistance,
	): Composition

	abstract fun createDictionaryEntry(word: String, frequency: Int): Boolean
	abstract fun createDictionaryEntry(word: String, frequency: Double): Boolean
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy