ranking-agent / aragorn-ranker

Exposes TRAPI functions to add literature co-occurrence edges, convert publications to edge weights, and provide scores for answers.
MIT License
0 stars 1 forks source link

Fixed bug where rgraph contains edges between nodes with the same qedge_id #69

Closed adamviola closed 2 years ago

adamviola commented 2 years ago

The existing logic to generate rgraph edges creates invalid edges when adjacent qnodes are bound to the same CURIE.

Consider this onehop:

Query Graph:
 _________                   _________
|         |                 |         |
| Disease | --related_to--> | Disease |
|_________|       e0        |_________|
    n0                          n1    

Knowledge Graph:
 ___________                   ___________
|           |                 |           |
| Disease:0 | --related_to--> | Disease:1 |
|___________|    kedge_0      |___________|       

Result:
"node_bindings": {
    "n0": [{ "id": "Disease:0"}],
    "n1": [{ "id": "Disease:0"}, { "id": "Disease:1"}],
},
"edge_bindings": {
    "e0": { "id": "kedge_0" }
}

In this case, the current code generates multiple edges in the ranking graph:

("n0", "Disease:0") -> ("n1", "Disease:1") # Valid
("n1", "Disease:0") -> ("n1", "Disease:1") # Invalid