File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Creating a spell checker - guidance/ideas? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a spell checker - guidance/ideas?" Watch "Creating a spell checker - guidance/ideas?" New topic

Creating a spell checker - guidance/ideas?

Matt Wilde
Ranch Hand

Joined: Feb 27, 2012
Posts: 34
I need to create a spell checker with hashing. So far I pretty much made a hash table with linked lists but don't really know how to 'Mod' strings.
The code below is my Dictionary class which takes in a .txt file that is a word bank. with single alphabet letters before the start of the words with that letter.


Then i have a scan class in which i attempt to go through the linked lists and try to identify the strings. I don't even know :P

How would i check words for misspellings and compare them to the dictionary then provide options for the user to change the words?

Any help is very appreciative

also i forgot to include the OpenFile method which opens a short .txt doc that is misspelled.

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955
  20 is my advice:


Throw this away. Do not keep working on this.

Why? I didn't have to get past your subject. Please read StopCoding. Then read its sister page at WhatNotHow.

Only after you follow all the instructions there should you consider writing a line of code.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Matt Wilde
Ranch Hand

Joined: Feb 27, 2012
Posts: 34
Point taken. Starting over. Thanks for the heads up

Are these even some plausible ideas? is there another way anyone suggests i should go about this?
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
Matt Wilde wrote:Are these even some plausible ideas? is there another way anyone suggests i should go about this?

This is nice, but it is still all written in terms of Java. We often want to start in with Java right away, because writing code is fun. Forget about Java. Forget about the computer. How would you, without the aid of a couputer, check the spelling in an excerpt of text? That's where you should start.
Matt Wilde
Ranch Hand

Joined: Feb 27, 2012
Posts: 34
Well, I would first start reading something. Then if i saw a word that did not look correct or i couldn't pronounce correctly, i would think back to all my years of vocabulary lessons in grade school and books i have read over the years and perhaps look in the dictionary for words that looked similar to that word. words that had the same general prefix or beginning?
Tony Docherty

Joined: Aug 07, 2007
Posts: 2836
This is good but it is a high level description of how you check the spelling of some text. For instance when you say:

"I would first start reading something" you really should say "for each word in the text" or "I look at the text and break it into individual words"

"Then if i saw a word that did not look correct ..." how do know you it doesn't look correct, as you say it is because you are referring to the words you have learned over time ie your internal dictionary. So maybe this should be "check every word against the dictionary to see if it is a known word".

Finding the correct spelling of an unknown word can be quite tricky to describe and even harder to compute. When you do come to code it I believe you can use the Damerau-Levenshtein distance to help find words that might be the correct ones, although there may also be other (possibly better) strategies. Google may help you here.
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8927

Matt Wilde wrote:The code below is my Dictionary class...


Please DontWriteLongLines (←click).

I've broken yours (line 24) up this time, but I suggest you also re-read the UseCodeTags page again thoroughly.



Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
I agree. Here's the link:
subject: Creating a spell checker - guidance/ideas?
jQuery in Action, 3rd edition