Meaningless Drivel is fun!*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a spell checker - guidance/ideas?" Watch "Creating a spell checker - guidance/ideas?" New topic
Author

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.

ex.
a
airplain
apple
astronaut
b
ball
big
bunny
c
cat
cow
etc.....








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
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

Ok...here is my advice:

Stop.

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
Bartender

Joined: Aug 07, 2007
Posts: 2158
    
  47
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
Bartender

Joined: Mar 17, 2011
Posts: 7484
    
  18

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

Matt,

Please DontWriteLongLines (←click).

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

Thanks.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating a spell checker - guidance/ideas?
 
Similar Threads
here is a question and i have a very similar code but i need to convert it
My head is about to explode!
how to use array in array?
using compareTo() in string
StackOverflow error using QuickSort