Search code examples
javastringcategorization

How to categorize Strings based on their values


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?


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.