I am working on a problem to represent knowledge extracted from a paragraph and rank it to produce abstractive summaries. I have implemented dependency parsing using Stanford NLP, which gives dot
format graph as an output.
The dependency-parsed output of the following two sentences are as follows.
Sentence 1 - John is a computer scientist
Dot format -
digraph G{
edge [dir=forward]
node [shape=plaintext]
0 [label="0 (None)"]
0 -> 5 [label="root"]
1 [label="1 (John)"]
2 [label="2 (is)"]
3 [label="3 (a)"]
4 [label="4 (computer)"]
5 [label="5 (scientist)"]
5 -> 2 [label="cop"]
5 -> 4 [label="compound"]
5 -> 3 [label="det"]
5 -> 1 [label="nsubj"]
}
Sentence 2 - John has an elder sister named Mary.
Dot Format -
digraph G{
edge [dir=forward]
node [shape=plaintext]
0 [label="0 (None)"]
0 -> 2 [label="root"]
1 [label="1 (John)"]
2 [label="2 (has)"]
2 -> 5 [label="dobj"]
2 -> 1 [label="nsubj"]
3 [label="3 (an)"]
4 [label="4 (elder)"]
5 [label="5 (sister)"]
5 -> 6 [label="acl"]
5 -> 3 [label="det"]
5 -> 4 [label="amod"]
6 [label="6 (named)"]
6 -> 7 [label="dobj"]
7 [label="7 (Mary)"]
}
Now I want to merge this graph at a common node, John
. I am currently using graphviz to import dot
graph like this,
from graphviz import Source
s = Source(dotGraph, filename=filepath, format="png")
But there seems to be no functionality to merge graphs in Graphviz
, or Networkx
. So how can this be done?
Merge
Signal. This is a case for the Biosyntax Squad.