utils.py 文件源码

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

项目:pybel 作者: pybel 项目源码 文件源码
def parse_owl_rdf(url):
    """Downloads and parses an OWL resource in OWL/RDF format

    :param str url: The URL to the OWL resource
    :return: A directional graph representing the OWL document's hierarchy
    :rtype: networkx.DiGraph
    """
    g = nx.DiGraph(IRI=url)
    o = Ontospy(url)

    for cls in o.classes:
        g.add_node(cls.locale, type='Class')

        for parent in cls.parents():
            g.add_edge(cls.locale, parent.locale, type='SubClassOf')

        for instance in cls.instances():
            _, frag = urldefrag(instance)
            g.add_edge(frag, cls.locale, type='ClassAssertion')

    return g
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号