This repository contains a Java application that implements a spell-checker. The application stores a lexicon of words in a set and includes a method, spellChecker(a)
, to perform a spell check on a given string with respect to the set of words.
The objective of this assignment is to develop a spell-checker that can identify correctly spelled words and suggest possible corrections for misspelled words by considering common types of misspellings.
-
Store Lexicon of Words:
- Stores a set of words,
Y
, in a JavaSet
.
- Stores a set of words,
-
Spell Checker Method:
- Implements a method
spellChecker(a)
which performs the following:- If the word
a
is in the setY
, returns a list containing onlya
. - If the word
a
is not in the setY
, returns a list of words fromY
that might be correct spellings ofa
.
- If the word
- Implements a method
-
Handling Common Misspellings:
- Swapping adjacent characters in a word.
- Inserting a single character between two adjacent characters in a word.
- Deleting a single character from a word.
- Replacing a character in a word with another character.
- Main.java: The main Java file containing the implementation of the spell-checker application.
-
Clone the repository:
git clone https://github.com/nisal2002/Spell-Checker.git
-
Navigate to the project directory:
cd Spell-Checker
-
Compile and run the Java program:
javac Main.java java Main
The program will initialize the lexicon of words and perform spell checking based on the provided method.
-
Data Structures:
- Uses a
Set<String>
to store the lexicon of words,Y
.
- Uses a
-
Methods:
spellChecker(String a)
: Performs spell check on the input stringa
.
-
Correct Spelling:
- If
a
is in the setY
, return a list containing onlya
.
- If
-
Possible Misspellings:
- Generate and check possible correct spellings by:
- Swapping adjacent characters.
- Inserting a character at each possible position.
- Deleting each character from the word.
- Replacing each character with every other possible character.
- Generate and check possible correct spellings by:
- Java
- Author - Initial work
This project is licensed under the MIT License - see the LICENSE file for details.