In [1]:
import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from networkx.drawing.nx_agraph import write_dot, graphviz_layout
In [2]:
df = pd.read_csv(
'taxi_output/simple_full/science_en.csv-relations.csv-taxo-knn1.csv',
sep='\t',
header=None,
names=['hyponym', 'hypernym'],
usecols=[1,2],
)
In [3]:
df.head()
Out[3]:
In [4]:
G = nx.DiGraph()
for rel in zip(list(df['hypernym']), list(df['hyponym'])):
G.add_edge(rel[0], rel[1])
In [5]:
pos = graphviz_layout(G, prog='dot', args="-Grankdir=LR")
plt.figure(3,figsize=(48,144))
nx.draw(G, pos, with_labels=True, arrows=True)
plt.show()
In [ ]: