I have data which consists of list of synonyms and within each list there is a preferred synonym. For example, [A,b,c,d,e] and [Z,y,x,w,v], with the capitalized letter being the preferred name for that particular list of synonyms. I want to be able to access all the members of the synonym list with any member of that list, and I want to be able to access the preferred name for a synonym list by any member of the list.
The things that come to mind in C++ are maps and multimaps, and in Python Dictionaries. I don't know of a version of multimap in Python. Even with these, though it seems clunky.
For maps/dictionaries, I could create a vector/list of each synonym list which is stored in a map/dictionary multiple times, once for each item in the synonym list. If this were in C++ I could store the pointer to the vector of each one to save some space. Something like:
std::map<std::string, std::vector<string> > syn_map
std::map<std::string, std::string> > pref_map
syn_map["A"] = &syn_list_a
syn_map["b"] = &syn_list_a
syn_map["Z"] = &syn_list_z
syn_map["y"] = &syn_list_z
pref_map["A"] = "A"
pref_map["b"] = "A"
pref_map["Z"] = "B"
pref_map["y"] = "B"
For Python, I could translate this to dictionaries.
But, this all seems very inelegant and clunky. Any suggestions for a better way??