Results 1 to 3 of 3
  1. #1
    Avatar399 is offline Member
    Join Date
    Apr 2012
    Rep Power

    Post Need some help to manage Strings in hashtable.

    Last edited by Avatar399; 04-28-2012 at 05:01 PM.

  2. #2
    bhatt.umang7 is offline Umang Bhatt
    Join Date
    Apr 2012
    Nadiad, Gujarat, India.
    Rep Power

    Default Re: Need some help to manage Strings in hashtable.

    please explain problem in detail

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Need some help to manage Strings in hashtable.

    Avater399, please don't remove content after there is a response. I'm quoting your original post and closing this thread.



    Quote Originally Posted by Avatar399 View Post

    Don't worry about the hash table guys but just give me some idea how to manage Strings.

    I need to do spell check a word entered by the user in dictionary using hashtables. I got a method named checkDictionary() from hash tables to check whether the given word is present in dictionary or not. It returns a Boolean value if the word is present or false if not.

    What I want to do is, I just want to check the word in dictionary when it is misspelled, making some possible corrections.

    possible corrections :

    Change one letter: For example, if the misspelled word is kest, i want to try all possibilities of
    changing one character at a time, and look the modified word up in the dictionary. The
    possibilities will be aest, best,...,zest, kast,...,kzst, etc.

    ---How can I change a single character at a time and that too from a to z.

    Exchange adjacent letters: For example, if the misspelled word is ebst, try best, esbt
    and ebts.

    ---How can I change the adjacent letters , need to swap or something?..

    Remove one letter: For example, if the misspelled word is
    tbird, try all possibilities of removing one letter at a time, and look the modified word up
    in the dictionary, which are: bird, tird, tbrd, and tbir.

    ---How can I remove each letter every time?

    GUYS!! PLEASE DO REMEMBER THAT THE WORD ENTERED MAY BE OF ANY LENGTH, like 5-20 charaters. or may be of any length.

    I need to return this suggestions to the user after checking the words in dictionary.
    Is there any methods in Strings that I can use.
    Please help in implementing above the above methods Change, Exchange and Remove.

    Java Code:
     import java.util.*;
     import java .io.*;
     public class HashTableDemo
     public static void main(String [] args)
     // constructs a new empty hashtable with default initial capacity
     HashTable hashtable = new HashTable();
     Scanner keyboard = null;
     Scanner input=null;
     System.out.println("Enter a word to check in dictionary");
     keyboard = new Scanner(;
     String word = (keyboard.nextLine().toUpperCase());
     //Adding aal dictionary words from a text file to hash table.
     input=new Scanner(new FileInputStream("TWL.txt"));
     int i=1;
     // adding value into hashtable
     String hello = input.nextLine();
     hashtable.put( hello, new Integer(i) ); 
     System.out.println("The word "+word+" is there in the dictionary.");
     System.out.println("The word "+word+" is not there in the dictionary.");
     //Here I need to implement the required methods if the word is not in dictionary and misspelled.
     catch(FileNotFoundException e)
     System.out.println("Cannot open file");
     }//end catch
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Hashtable question. Getting info from a hashtable
    By sindrem in forum New To Java
    Replies: 4
    Last Post: 01-19-2012, 05:00 PM
  2. Best way to manage images?
    By sgthale in forum New To Java
    Replies: 3
    Last Post: 09-30-2011, 02:11 AM
  3. Program to manage books
    By datreta in forum New To Java
    Replies: 6
    Last Post: 12-16-2010, 09:30 AM
  4. JMX to to manage server application
    By shiva in forum Advanced Java
    Replies: 0
    Last Post: 03-26-2009, 07:47 AM
  5. can't manage to get this
    By mollentze in forum New To Java
    Replies: 3
    Last Post: 01-11-2008, 11:03 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts