def isas(path):
G = nx.DiGraph()
with open(path, newline='') as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
if len(row) > 1 and row[0] and row[1]:
G.add_edge(sanitize(row[0]), sanitize(row[1]))
# Note that we store the sense inventory as an attribute of G.
# TODO: nx.DiGraph subclass?
G.senses = defaultdict(list)
for node in G.nodes():
G.senses[node.rsplit('#', 1)[0]].append(node)
return G
评论列表
文章目录