简体   繁体   中英

finding shortest path between two phrases in a graph

For the below sentence, I earned a dependency graph, and I transformed this dependency graph to a networkx graph. Now, I would like to find the shortest path between the words "Acute Kidney Injury" and "CYP3A4" .

Because "Acute Kidney Injury" has 3 nodes in the graph, I don't know, how I can find path between the aforementioned words.

Below the dependency_graph of the sentence:

依赖图

Sentence:
"Acute Kidney Injury from Excessive Potentiation of Calcium-channel Blocker via Synergistic CYP3A4 Inhibition by Clarithromycin Plus Voriconazole."

Is there any way to do so?

As this is a non-trivial question I will try to provide some possible directions instead of a clear answer.

According to the question, you are able to find the shortest paths between two nodes in the dependency graph, but not able to do this on a phrase.

You can try to:

  1. There are many parsers in NLP tools (like Spacy) that will provide you dependency parse with phrases merged.
  2. You can also merge the phrases into a single node from the dependency parse itself. Eg Acute Kidney has the dependencies compound with Injury , meaning Acute Kidney is actually a part of the phrase.
  3. In such scenarios, you can simply consider the parent node of the phrase in the dependency subtree to calculate the path. Eg, in Acute Kidney Injury , Injury is the parent node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM