【问题标题】:Visual Graph showing blank nodes显示空白节点的可视化图表
【发布时间】:2019-10-18 16:00:44
【问题描述】:

Ontotext GraphDB 9.0.0,免费版,Ubuntu Workstation Linux 4.15.0-65-generic x86_64

我有一个包含空白节点的图表:

@prefix : <urn:ex:> .

:Dave :hasFather [ :name "John" ] .

当我查看默认图表的 Explore/Graphs Overview 时,会显示两个三元组,并且主题 :Dave 有一个父亲 _:node3。但是,该对象显示为文本,而不是像 :Dave 这样的资源链接。当我选择 :Dave 时,只有一行(如预期的那样),当我选择 Visual graph 时显示“此节点没有可见的连接。”

Explore/Visual Graph/Easy Graph 下尝试搜索 _:node3 表示它是无效的 URI。

如何在带有空白节点的图表中直观地导航?

【问题讨论】:

    标签: graphdb


    【解决方案1】:

    GraphDB Visual Graph 仅显示 IRI。空白节点不会向用户提供任何信息。为什么要为父亲使用空白节点?我发现这与 :Dave 是 IRI 的事实不一致。我建议您将数据更新为:

    
    :Dave :hasFather :Jonh  .
    

    如果您仍想保留 bnode,您可以修改查询以进行可视化。在 SPARQL 编辑器中执行 Construct 查询:

    CONSTRUCT { 
        :Dave :hasFather ?fatherIRI
    } WHERE {
        :Dave :hasFather ?bnode.
        ?bnode :name ?nameLiteral.
        BIND( IRI(CONCAT("http://test", ?nameLiteral)) as ?fatherIRI)
    }
    

    然后单击“视觉”按钮。这将为您的 bnode 创建一个可以直观显示的虚拟 IRI。 此外,如果这种方法适合您,您可以创建自定义可视化图表。 请参阅 GraphDB 文档中的“在您的 RDF 数据上创建自定义图形视图”。

    【讨论】:

      【解决方案2】:

      要完全构建可视化,您需要创建一个自定义“图形扩展”查询,如下所示:

      # Note that ?node is the node you clicked and must be used in the query
      PREFIX rank: <http://www.ontotext.com/owlim/RDFRank#>
      PREFIX ent: <http://www.ontotext.com/owlim/entity#>
      
      CONSTRUCT
      {
          # The triples that will be added to the visual graph
          ?newNodeLX  ?edge  ?newNodeRX .
      }
      WHERE
      {
        {
          {
              # Left to right relations (starting IRI is the subject)
              ?node ?edge ?newNodeR .
              # ?node is always an IRI, ?newNodeR must be checked for IRI or Blank
              FILTER(isIRI(?newNodeR) || isBlank(?newNodeR))
              BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))), ?newNodeR) AS ?newNodeRX)
              BIND(?node AS ?newNodeLX)
          }
          UNION
          {
              # Right to left relations (starting IRI is the object)
              ?newNodeL ?edge ?node .
              # ?node is always an IRI, ?newNodeL is always an IRI or Blank
              BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))), ?newNodeL) AS ?newNodeLX)
              BIND(?node AS ?newNodeRX)
          }
        }
        UNION
        {
          {
              # Left to right relations (starting Blank is the subject)
              ?nodeC ?edge ?newNodeR .
              # ?nodeC must be checked for Blank, ?newNodeR must be checked for IRI or Blank
              FILTER(isBlank(?nodeC))
              FILTER(isIRI(?newNodeR) || isBlank(?newNodeR))
              BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))), ?newNodeR) AS ?newNodeRX)
              BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeLX)
              FILTER(?newNodeLX = ?node)
          }
          UNION
          {
              # Right to left relations (starting Blank is the object)
              ?newNodeL ?edge ?nodeC .
              # ?nodeC must be checked for Blank, ?newNodeL is always an IRI or Blank
              FILTER(isBlank(?nodeC))
              BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))), ?newNodeL) AS ?newNodeLX)
              BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeRX)
              FILTER(?newNodeRX = ?node)
          }
        }
      }
      #ORDER BY ?edge
      

      并使用“节点基础”查询来扩充它,如下所示:

      # Note that ?node is the relevant node's IRI and must be used in the query
      PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
      PREFIX ent: <http://www.ontotext.com/owlim/entity#>
      
      SELECT ?type {
        {
          # Get node direct type
          ?node sesame:directType ?type.
        }
        UNION
        {
          # Get node direct type
          ?nodeB sesame:directType ?type.
          FILTER(isBlank(?nodeB) && URI(CONCAT("BNode:", STR(ent:id(?nodeB)))) = ?node)
        }
      } ORDER BY ?type
      

      还有一个像这样的“Node extra”查询:

      # Note that ?node is the node you clicked and must be used in the query
      PREFIX ent: <http://www.ontotext.com/owlim/entity#>
      
      SELECT ?property ?value {
        {
          # Gets all datatype properties (?property) with literals as values (?value)
          ?node ?property ?value .
          # Select only literals
          FILTER(isLiteral(?value))
        }
        UNION
        {
          ?nodeB ?property ?value .
          FILTER(isLiteral(?value))
          FILTER(isBlank(?nodeB) && URI(CONCAT("BNode:", STR(ent:id(?nodeB)))) = ?node)
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2020-01-01
        • 2021-11-04
        • 2018-07-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多