• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing a dictionary application  RSS feed

 
nagarjuna borra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how should one write a dictionary app,i mean the back end part to store the 'word-meaning' mappings.

1.using text files with indexing, Like a text file with all the words starting with a,another text file for b-words.....so on.
One can also think of further indexing by including sub-folders too.
for an example - for the meaning of the word 'ranch',i could put the word-meaning in a text file /r/a/n/ran.txt.where 'r','a','n' are sub-folders.

2.using java collections and serialization.i mean add the entries to the collection, then write it to disk, load it when the app is executed.(put aside the constraint that this approach might require lot of RAM,however its faster right???).

3.use some sort of database.I see a lot of dictionary apps doing this.

giving the pros and cons is appreciated.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"How should I write application X?" is far too broad a question to be answered in a forum, even if you provide specific requirements, which you haven't. I don't know what you mean by a "dictionary app."

Your post seems to focus on how to model the data. If all you want to do is associate words with their meanings, then a simple Map should suffice. There are about 250,000 words in the English language, and if even if we assume 1 kB per definition (a large estimate, in my opinion) that's 250 MB, which, while not tiny, will fit comfortably in the memory of any modern personal computer.

If you want to be able to do more complex queries like "show me all the forms of the verb 'to be'" or "show me all the nouns that are not pluralized by added 's' or 'es'" then a database would be more appropriate.
 
nagarjuna borra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:"How should I write application X?" is far too broad a question to be answered in a forum, even if you provide specific requirements, which you haven't. I don't know what you mean by a "dictionary app."

i didnt mean designing the entire application,what i meant was how the word-meaning data should be stored.
ok,i should have mentioned it clearly,my bad.
also, by dictionary app - i meant dictionary application.

what about the text files?,whats wrong with that approach?.

Jeff Verdegan wrote:
If you want to be able to do more complex queries like "show me all the forms of the verb 'to be'" or "show me all the nouns that are not pluralized by added 's' or 'es'" then a database would be more appropriate.

no,it is'nt a complex one,and most of the dictionaries i've installed didnt show me such features,still they used some kind of database files.Lingoes for example used .ldx files and clearly they aren't plain text files.

also 250MB is still too much even if you are equipped with 2 GB RAM.Lingoes,the dictionary i've installed,its cool and it occupies only 26MB,and sufficiently fast enough.


anyways,thanks for your concern.


 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nagarjuna borra wrote:
also, by dictionary app - i meant dictionary application.

I think most folks here know that "app" means "application". The question is more "what do you expect/want your application to DO exactly?"

nagarjuna borra wrote:what about the text files?,whats wrong with that approach?.

What about text files...for WHAT? For storing everything? If that is what you mean, the potential problems are that it can take a long time to search through a file. It can take a long time to insert a new entry in. It can take a long time to delete an entry out.

However, depending on what you want you application to do (see above) none of this may matter - or all of it might.

The dictionaries you mention probably use database files to solve the above problems. It makes access/updates to specific entries very fast and efficient.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nagarjuna borra wrote:
Jeff Verdegan wrote:
also, by dictionary app - i meant dictionary application.


Yes, I know that. My point was the "dictionary app" or "dictionary application" can mean lots of different things in terms of features, requirements, use cases, etc., that can drive wildly different answers to the "how do I store the data?" question, and since you didn't provide any of that information, all anyone can do is point out some general ideas and examples.

what about the text files?,whats wrong with that approach?.


I didn't say anything was wrong with them. I merely gave two different examples of situations where you might use two of the different things you proposed; I didn't happen to give examples for all three. There may be cases where the text files are appropriate. Since I still know nothing about the requirements or use cases of this "dictionary app", I cannot make any concrete suggestions as to what is appropriate for you in this particular situation.

Jeff Verdegan wrote:
If you want to be able to do more complex queries like "show me all the forms of the verb 'to be'" or "show me all the nouns that are not pluralized by added 's' or 'es'" then a database would be more appropriate.

no,it is'nt a complex one,and most of the dictionaries i've installed didnt show me such features,still they used some kind of database files.Lingoes for example used .ldx files and clearly they aren't plain text files.


Okay, so maybe you need a DB and maybe you don't. Again, the problem statement is still too broad and vague to say for sure.

also 250MB is still too much even if you are equipped with 2 GB RAM.Lingoes,the dictionary i've installed,its cool and it occupies only 26MB,and sufficiently fast enough.


I wasn't trying to give you a concrete solution, nor was I saying "It will take 250 MB and that is not too big for you." I was simply putting an upper bound on one particular representation, as a starting point to get you thinking. The idea is that you then take my first pass, adapt it to your situation using what you know about your requirements and use cases that I don't know, refine it, and see if it makes sense for you.

Maybe you combine the Map with the text files. Or maybe you realize my estimate was way to high and find that a more reasonable estimate actually gives you a value you can work with. (I assumed 1kB per entry, and I told you I considered that to be on the large side. Did you do any research to see how many bytes an average entry might actually take? My guess is that 100 bytes is probably a better estimate--like I said, I was just putting an upper bound on it--and if it is in the neighbohood of 100 bytes, then that gets us close to your 26 MB example.)

The whole point of my post was not to solve your problem for you, but to give you ideas of the kinds of things to think about and the kinds of questions you have to ask before you can decide on details like how to store the data.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops. Double post.
 
nagarjuna borra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:

I think most folks here know that "app" means "application". The question is more "what do you expect/want your application to DO exactly?"



yeah,lot of folks like you know what app means.
i could'nt just figure out what he's asking exactly....and gave him a literal answer.

thank you.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nagarjuna borra wrote:
fred rosenberger wrote:

I think most folks here know that "app" means "application". The question is more "what do you expect/want your application to DO exactly?"



yeah,lot of folks like you know what app means.


I think everybody who has ever visited this site knows what it means.
 
nagarjuna borra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
nagarjuna borra wrote:
fred rosenberger wrote:

I think most folks here know that "app" means "application". The question is more "what do you expect/want your application to DO exactly?"



yeah,lot of folks like you know what app means.


I think everybody who has ever visited this site knows what it means.


ok,ok....lets just forget about it..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!