How should I face this problem? I basically need to implement a word of synonyms that it takes some "word / synonim" pairs as input and I should be able to "query" for a list of all synonims of a word. For example:
dictionary myDic; MyDic.Add ("Car", "Automobile"); MyDic.Add ("Car", "Autovallic"); MyDic.Add ("car", "vehicle"); MyDic.Add ("bike", "vehicle"); MyDic.ListOSyns ("car") / / "Automobile", "Autovallic", "vehicle" ± "car"} / back, but "bike" should not be back in words I'll code it in C ++, but I'm interested in an overall idea of implementation, so the question is not exactly language specific.
The main idea is that the words of some groups (synonyms) will have two such groups in the above example:
{"Automobile", "Autovallic", "vehicle", "car "}" "Bike", "vehicle"}
"vehicle" falls under both, "bike" for the second only, others only for the first time
I call it a graph + hash table / search tree I will apply each keyword as one vertex, and I 2 keywords between Yek connection will have an edge
a hash table or node of a search tree, each word will be added (and vice versa).
When a question is submitted - you get a node with your hash / tree and do necessary BFS / DFS of depth. (Meaning that you can not continue after a certain depth)
Complexity: o (e (d) + v (d) find the graph (d = depth) (e (d) = Depth of the edges in the relevant depth, similar to the V (D) o (1) to make the edge (detailed to its discovery, including the search for the node) o O (logon) / o (1) node To find a tree / hash table, add a word / ps to add a word for o (logon) / o (1) tree / hash table and o (1) As mentioned: Designer should keep in mind that he needs a guided or indirect graph, as explained in the answer to the question.
Hope that helps ...
Comments
Post a Comment