Question

I'm trying to take a String that and divide it into categories (Books, Food, & Medical Supplies) using Java programming. This is really very confusing to me since there's little automaton to the String. The String is one word only, but there are plenty of words in the English language. Are there any strategies I could take in implementing this?

Was it helpful?

Solution

You will have to keep maintain a data base(storage) of Books, Food and Medical Supplies to do something like this. Then when you can check your String with that three and decide.

As an example you can simulate simple case. Let's say you are going to keep three Maps

Map<String,String> store=new HashMap<String,String>();
store.put("GameOfThrowns","Book");
store.put("Rice","Food");

The you can simply get value for your String match with key of this Map.

FYI:

You can't reach your goal since it is more related to Artificial Intelligence you have to use Neural Network and that is still belongs to laboratory level, But this is just a try.

OTHER TIPS

The short answer of course, is you can't. If you think about it for a while it becomes intuitively obvious why. Take the value "My Cat" is that a book? Is that food? It could even be Medical Supplies I guess (for any sufficiently loose definition of Medical). In short, unless you know the context the words are used in, there is no way to categorize the word itself. Even less so if it's vague categories, where something could conceivably belong to multiple categories.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top