/Wagner-Fischer-Kotlin

This project implements the Wagner-Fischer algorithm in Kotlin.

Primary LanguageKotlin

Wagner-Fischer Spell Checker in Kotlin

Overview

This Kotlin project implements a simple spell checker using the Wagner-Fischer algorithm. The spell checker provides suggestions for the closest words to a misspelled word based on a given dictionary.

Usage

To use the spell checker, follow these steps:

  1. Ensure Kotlin is installed on your machine.
  2. Run the main function in your Kotlin project.
fun main() {
    val wordList = Utils.getStringsFromWordFile()
    val misspelledWord = "forsed"
    val suggestions = spellCheck(misspelledWord, wordList)
    println("Closest suggestions for $misspelledWord:")
    for ((suggestion, distance) in suggestions) {
        println("$suggestion ($distance)")
    }
}

How it Works

The spell checker utilizes the Wagner-Fischer algorithm, a dynamic programming approach to calculate the edit distance between two strings. It compares the input word to the words in the dictionary, providing a list of suggestions sorted by their edit distance.

Example

Assuming a dictionary loaded from a file(In current project words.txt which contains 10k words), the example above would output suggestions for the misspelled word "forsed."

Screenshot


Algo success run