Results 1 to 6 of 6
- 02-11-2011, 09:31 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 17
- Rep Power
- 0
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 !
- 02-11-2011, 10:29 AM #2
Member
- Join Date
- Nov 2010
- Posts
- 17
- Rep Power
- 0
I find solution to search the file . But what about my strategy to store the words ?
- 02-11-2011, 01:30 PM #3
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
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-
- 02-11-2011, 05:26 PM #4
Member
- Join Date
- Nov 2010
- Posts
- 17
- Rep Power
- 0
Thanks for your answer .
I want to store words and their definitions .
Normally word1 - definition1.
But in some cases word1 - definition1,definition2..definition..n
- 02-11-2011, 05:55 PM #5
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
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:
to write and read from the multimap.Java Code:private void writeObject(java.io.ObjectOutputStream out) throws IOException private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
Last edited by NRitH; 02-11-2011 at 06:00 PM.
- 02-11-2011, 07:43 PM #6
Member
- Join Date
- Nov 2010
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
Implementation of Big Dictionary without using data storage in tables
By sanver99 in forum New To JavaReplies: 1Last Post: 01-31-2011, 02:38 AM -
dictionary
By aizen92 in forum New To JavaReplies: 49Last Post: 01-01-2011, 09:07 AM -
Need plugin for creating dictionary project in eclipse
By cbklp in forum EclipseReplies: 2Last Post: 12-27-2010, 04:28 AM -
Phrases in Lucene dictionary?
By TheShar in forum LuceneReplies: 0Last Post: 05-27-2010, 02:42 PM -
add dictionary
By monir6464 in forum New To JavaReplies: 2Last Post: 04-07-2008, 06:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks