0

I have a list of frequent terms obtained from different search queries of a certain user.
For example:
sports, badminton, soccer
soccer, sports
research, AI, algorithm
research, adaptive, personalized search
research, AI, neuro network

The goal here is to build a hierarchical user profile based on these frequent terms with the hypothesis that terms that frequently appear in such queries represent topics that interest the user. In the hierarchy, general terms with higher frequency are placed at higher levels, while specific terms with lower frequency are placed at lower levels of the hierarchic user profile.

The expected result would be a tree of the user profile looking somehow like this :

  • User profile
    • research
      • AI
      • algorithm
      • personalized search
      • ..
    • sports
      • soccer
      • badminton

So, I'm currently stuck and I don't even know how to begin or what libraries to use. (I'm working with java on this project).
I would be very grateful if somebody could provide me with some help.
Thanks in advance.

paskun
  • 89
  • 1
  • 6

1 Answers1

0

You're probably looking for a nested Map data structure. Something along the following lines will provide you with ability to store hierarchical data and easily access it:

//creating the data structure
Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();

//adding data
map.put( "key", new HashMap<String, String>() ); //adding category
map.get("key").put("nested_key", "value"); //adding TO the category

//reading entries
map.get( "key" )).get( "nested_key" );
pdeschain
  • 1,411
  • 12
  • 21
  • Thanks for the answer. Maybe I didn't explain well but the number of queries vary and the terms too. Also I would like the structure to have some logic or semantic in it. For example the part sports which contains soccer and badminton which are specific sports. – paskun Oct 24 '14 at 22:21
  • you would need some sort of wrapper api, but the underlying data structure would remain as described. A class, that contains an instance of such map + helper functions, e.g. addCAtegory, addToCategory, getCategory, getFromCategory, processRequest etc. "key", "nested_key" and "value" are placeholders for your own data. – pdeschain Oct 24 '14 at 22:26
  • Okay :) During my searches, I've seen the term "ontolgy" but I didn't understand well how to use it. Would you have some information concerning that? Thanks again – paskun Oct 24 '14 at 22:33
  • http://stackoverflow.com/questions/5841123/how-to-create-ontology-in-java The accepted answer contains a good writeup on ontology - the problem stated in the question doesn't call for a more sophisticated solution than a map of maps, but if your real application does - I suggest you read that question and answer. – pdeschain Oct 24 '14 at 22:41
  • Thanks for you help. I will try to get more information about Jena and OWL API to better understand that post and get back here if I still have some questions. Sorry that I wasn't very clear at the beginning. – paskun Oct 24 '14 at 22:52