parsemis_wrapper.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:parsemis_wrapper 作者: tomkdickinson 项目源码 文件源码
def get_label_from_edge(g, edge, attribute_name='label'):
        edge_attributes = g.get_edge_data(edge[0], edge[1])
        if edge_attributes is None and nx.is_directed(g):
            edge_attributes = g.get_edge_data(edge[1], edge[0])

        labels = []
        if type(g) == nx.MultiDiGraph or type(g) == nx.MultiGraph:
            for index in edge_attributes:
                if attribute_name in edge_attributes[index]:
                    labels.append(edge_attributes[index][attribute_name])
        else:
            if attribute_name in edge_attributes:
                labels.append(edge_attributes[attribute_name])

        return labels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号