(I have another thread on the main page here but that was directed towards getting some basic file structure issues worked out)

Problem: I need to create a dictionary that has words that are look-up-able, from a text file.

I need to have two classes (Word, Meaning), one for the definition and one for the word. The definition holding class also needs to be a child class of the word class. I am pretty sure I have the inheritance stuff covered.

What is the best way to go about doing this? How do I go about correctly extracting definitions from a text file and having them match up? I'll post whatever code you guys would like that I have so far.

I have been looking around the net for some time now and everyone seems to have a different and more confusing way of doing things.

Recommended Answers

All 3 Replies

I'll post whatever code you guys would like that I have so far.

Most welcomed

The best way?
Probably a database of some sort, either just a file or an actual database (SQL, Access, etc.)

Main thing is, you need a way to store the word, and it's definition in a logically related manner. You could use markers to mark the begin/end of data in the file or something.

For the file - I second pseudorandom21. If you want, you can use a library for XML.

If you want to store the whole thing in the memory - I'd suggest a tree, where every node can have 26 children (one for each alphabet letter) and the node contains the description for a word containing the letters on the way from root to it.
Or a hash table.

Other then that - go through the file, store the positions in the file in a way similar to what I described above, and just read the file from the stored position to the next marker.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.