Member Avatar

Hi all, I need a little bit help in creating a small thesaurus like application in java.
The application consists of some 50-100 categories and each category have some 2-10words of similar meaning.

e.g Close-{shutdown,fold,end,come together}

The words are hard-coded but I don't know which data structure suits the best. I don't want arrays(sequential search) but If i Construct a binary search tree for each category means here also I need to jump from one tree to another.Any idea?

How do you want to access the words?
Is a category a word? Or a phrase? Is it something that you search for?

An idea: Map<Category, ArrayList<Word>>

Member Avatar

Is a category a word? Or a phrase?

Category is a Word but it contains words|phrases.

How do you want to access the words?

Consider the user says
"I need to pay my bill".
The category 'Account' will analyse the
text according to its context and extract the word 'bill' only.

The category 'Account' will analyse the text

Category is a Word

How does a word "analyze" anything?

Member Avatar

An extract from IEEE paper(
"consider the sentence, “I want to make a payment online,”
under the subject account and web-banking. In the case of
subject account, the lexicon module will extract the word
payment only, and in the case of web-banking, the lexicon
module will extract the words online and payment."

So, given a category you want to take each of the words in that category and see if they appear in a given text?

If so, NormR1's idea is a good way to go.

Sorry, I'll leave the algorithm design stuff to you. Your last post doesn't define to me how a word (a String) would do any processing/analysis. methods do processing.
A String's value can be used to select a method to do the processing.

Member Avatar

@JamesCherril:fine go I with map<#,#>.
@NormR1: fine no problem. And thanks for your suggestion(Map) I will go with it.

Hi Ravi
I can't let this thread expire without making one more point...
That data structure + methods accessing it is a perfectly OK solution, don't worry, but it's a very traditional approach that takes no advantage of the Object Oriented side of Java. Just for future reference, here's how you could do this in a more OO way:
Create a class for Categories. Each instance will have its own name and a collection of keywords. They will have public instance methods to check if a given word is in that category, or to highlight all the matching words in a sentence (etc etc). It could also have methods to save/load the category data from disk.
You main application class can then set up the instances of Category, do the user I/O to get requests and display results, while using the Category instances to do the matching etc.
This breaks up one big program into smaller classes each with clearly separated functionality. These classes can be developed and tested and modified and enhanced independently, making your life a lot easier.
I'm not suggesting you should re-write your current project, but as you move forward with Java, this is an example of how your thinking should develop.
Good Luck.