Results 1 to 6 of 6
  1. #1
    Alexis is offline Member
    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0

    Default I need a little direction for a dictionary app

    Hello ,

    i need a little hand to build a dictionary application.
    i thought to store the words in a serialize file and use an app to read the file and show the words ( at least 500.000 different words )

    1. Is it my thought right ?????
    2. How can i search a serialize file for a specific word ????

    Thanks !

  2. #2
    Alexis is offline Member
    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0

    Default

    I find solution to search the file . But what about my strategy to store the words ?

  3. #3
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    It's not clear what kind of dictionary you're trying to build. If you're storing words and their definitions, and if the definitions are simple Java Strings, then you can use a HashMap<String, String> to store them. You may want to consider writing a Definition class, if you want your definitions to be more than simple Strings.

    -Gary-

  4. #4
    Alexis is offline Member
    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0

    Default

    Thanks for your answer .

    I want to store words and their definitions .
    Normally word1 - definition1.
    But in some cases word1 - definition1,definition2..definition..n

  5. #5
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Quote Originally Posted by Alexis View Post
    Thanks for your answer .

    I want to store words and their definitions .
    Normally word1 - definition1.
    But in some cases word1 - definition1,definition2..definition..n
    If a word has multiple definitions, maybe you can just separate them in the map value with a character like '^', then call split("^") on the definition string to get the individual definitions later. If you choose this route, do NOT use a HashMap; use a TreeMap, which keeps the keys in sorted order, and that's exactly what you want for fast lookup of Strings.

    If that won't work, you'll need to find a multimap implementation in Java. The JDK doesn't provide one, but Apache does.

    Oh, and serializing all of this to a file should be pretty straightforward. Make your Dictionary class implement Serializable. If you're using the standard JDK TreeMap, which is already serializable, then you don't have to do anything else. If you use the Apache multimap, which isn't, then implement these two methods in your Dictionary class:

    Java Code:
    private void writeObject(java.io.ObjectOutputStream out) throws IOException
    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
    to write and read from the multimap.
    Last edited by NRitH; 02-11-2011 at 07:00 PM.

  6. #6
    Alexis is offline Member
    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 01-31-2011, 03:38 AM
  2. dictionary
    By aizen92 in forum New To Java
    Replies: 49
    Last Post: 01-01-2011, 10:07 AM
  3. Replies: 2
    Last Post: 12-27-2010, 05:28 AM
  4. Phrases in Lucene dictionary?
    By TheShar in forum Lucene
    Replies: 0
    Last Post: 05-27-2010, 03:42 PM
  5. add dictionary
    By monir6464 in forum New To Java
    Replies: 2
    Last Post: 04-07-2008, 07:27 PM

Posting Permissions

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