An open API service indexing awesome lists of open source software.

https://github.com/benoitprmt/levenshtein-distance

Levenshtein distance algorithm implementation in Rust
https://github.com/benoitprmt/levenshtein-distance

levenshtein-distance rust rust-learning

Last synced: 7 months ago
JSON representation

Levenshtein distance algorithm implementation in Rust

Awesome Lists containing this project

README

          

# ๐Ÿงฎ Levenshtein Distance in Rust

A simple Rust implementation of the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance), used to calculate the minimum number of single-character edits required to change one string into another.

This project is a learning exercise to explore Rust basics, algorithms, and project organization.

## ๐Ÿ“ Project Structure

```
src/
โ”œโ”€โ”€ main.rs
โ”œโ”€โ”€ levenshtein.rs
โ””โ”€โ”€ spellchecker.rs
```

## ๐Ÿš€ Getting Started

Make sure you have [Rust installed](https://rustup.rs/).

```bash
# Clone the project
git clone https://github.com/BenoitPrmt/levenshtein-distance.git
cd levenshtein-distance

# Run the main program
cargo run

# Run tests
cargo test
```

## ๐Ÿ“ฆ Features

- Calculates Levenshtein distance between two strings
- Spell checker using Levenshtein distance
-> Suggests the closest word from a dictionary for a given input
- Includes unit and integration tests
- Modular project structure

## ๐Ÿ”ง Example Output

```
Distance de Levenshtein entre "chat" et "chats" : 1

Mot recherchรฉ: chzt
Suggestions:
- chat
```

## ๐Ÿง  Notes

- For simplicity, this implementation assumes ASCII strings. Unicode support would require working with `.chars()` instead of `.as_bytes()`.

## โœ… TODO
- [ ] Import dictionary from a file (spellchecker)
- [ ] Build CLI to check spelling
- [ ] Build little API to use tools easily through other projects

## ๐Ÿ“š License

MIT License. Free to use and modify.