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

    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
    Location
    Nadiad, Gujarat, India.
    Posts
    3
    Rep Power
    0

    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
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    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.

    db

    THREAD CLOSED

    Quote Originally Posted by Avatar399 View Post
    Hey,

    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;
     try
     {
     System.out.println("Enter a word to check in dictionary");
     keyboard = new Scanner(System.in);
     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
     while(input.hasNextLine())
     {
     String hello = input.nextLine();
     hashtable.put( hello, new Integer(i) ); 
     i++;
     }
     );
    
    
     if(hashtable.checkDictionary(word))
     System.out.println("The word "+word+" is there in the dictionary.");
     else 
     System.out.println("The word "+word+" is not there in the dictionary.");
     }//try
    
    
    
     //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");
     System.exit(0);
     }//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
  •