使用 sqarql 更新具有空白节点的三元组时出现问题

发布于 2025-01-13 02:18:06 字数 3019 浏览 0 评论 0原文

  • 这是我的查询,此查询适用于没有空白节点的节点 但是在使用空白节点更新时出现了问题

    这些节点在更新后会重复 100 次

    DELETE {
    it:4D9AT21jAasfL9ah schema:description ?o_0 .
    it:4D9AT21jAasfL9ah it:hasArea ?o_1 .
    ?o_1 rdf:type ?o_1_0 .  ?o_1 schema:unitCode ?o_1_1 .
    ?o_1 schema:value ?o_1_2 .  ?o_1 schema:unitText ?o_1_3 .
    it:4D9AT21jAasfL9ah it:unresolvedWikidataType ?o_2 .
    it:4D9AT21jAasfL9ah schema:longitude ?o_3 .
    it:4D9AT21jAasfL9ah schema:addressCountry ?o_4 .
    it:4D9AT21jAasfL9ah rdfs:label ?o_5 .
    it:4D9AT21jAasfL9ah rdf:type ?o_6 .
    it:4D9AT21jAasfL9ah schema:url ?o_7 .
    it:4D9AT21jAasfL9ah it:wikiLink ?o_8 .
 }
    INSERT {
    it:4D9AT21jAasfL9ah  schema:description 'city and capital of Bali, Indonesia' . 
    it:4D9AT21jAasfL9ah  it:hasArea _:bQRrRFzX1zv9qUGWy . 
    _:bQRrRFzX1zv9qUGWy  rdf:type schema:QuantitativeValue; 
    schema:unitCode 'KMK'; 
    schema:value '123.98'; 
    schema:unitText 'km²' . 
    it:4D9AT21jAasfL9ah  it:unresolvedWikidataType 'Q3199141', 'Q13220204' . 
    it:4D9AT21jAasfL9ah  schema:longitude '115.21666666667' . 
    it:4D9AT21jAasfL9ah  schema:addressCountry it:WtC49aYLe8s0lsFC . 
    it:4D9AT21jAasfL9ah  rdfs:label 'Denpasar' . 
    it:4D9AT21jAasfL9ah  rdf:type schema:City . 
    it:4D9AT21jAasfL9ah  schema:url <http://www.denpasarkota.go.id/> . 
    it:4D9AT21jAasfL9ah  it:wikiLink <https://en.wikipedia.org/wiki/Denpasar> .
     }
     WHERE {
    it:4D9AT21jAasfL9ah ?p ?o .
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:description ?o_0 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:hasArea ?o_1 }
    OPTIONAL {  ?o_1 rdf:type ?o_1_0 }
    OPTIONAL {  ?o_1 schema:unitCode ?o_1_1 }
    OPTIONAL {  ?o_1 schema:value ?o_1_2 }
    OPTIONAL {  ?o_1 schema:unitText ?o_1_3 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:unresolvedWikidataType ?o_2 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:longitude ?o_3 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:addressCountry ?o_4 }
    OPTIONAL {  it:4D9AT21jAasfL9ah rdfs:label ?o_5 }
    OPTIONAL {  it:4D9AT21jAasfL9ah rdf:type ?o_6 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:url ?o_7 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:wikiLink ?o_8 }
 }

这是json格式的输出, 并且只有具有空白节点值的 hasArea 被重复多次

"schema:latitude": [
  "-7.164444444444444"
],
"it:hasArea": [
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },...
],
"rdfs:label": [
  "Denpasar"
],
...

提前致谢

  • This is my query, this query works fine for nodes with no blank node
    but the issue with arrives while updating with blank node

    here those nodes get repeated 100 times after updating

    DELETE {
    it:4D9AT21jAasfL9ah schema:description ?o_0 .
    it:4D9AT21jAasfL9ah it:hasArea ?o_1 .
    ?o_1 rdf:type ?o_1_0 .  ?o_1 schema:unitCode ?o_1_1 .
    ?o_1 schema:value ?o_1_2 .  ?o_1 schema:unitText ?o_1_3 .
    it:4D9AT21jAasfL9ah it:unresolvedWikidataType ?o_2 .
    it:4D9AT21jAasfL9ah schema:longitude ?o_3 .
    it:4D9AT21jAasfL9ah schema:addressCountry ?o_4 .
    it:4D9AT21jAasfL9ah rdfs:label ?o_5 .
    it:4D9AT21jAasfL9ah rdf:type ?o_6 .
    it:4D9AT21jAasfL9ah schema:url ?o_7 .
    it:4D9AT21jAasfL9ah it:wikiLink ?o_8 .
 }
    INSERT {
    it:4D9AT21jAasfL9ah  schema:description 'city and capital of Bali, Indonesia' . 
    it:4D9AT21jAasfL9ah  it:hasArea _:bQRrRFzX1zv9qUGWy . 
    _:bQRrRFzX1zv9qUGWy  rdf:type schema:QuantitativeValue; 
    schema:unitCode 'KMK'; 
    schema:value '123.98'; 
    schema:unitText 'km²' . 
    it:4D9AT21jAasfL9ah  it:unresolvedWikidataType 'Q3199141', 'Q13220204' . 
    it:4D9AT21jAasfL9ah  schema:longitude '115.21666666667' . 
    it:4D9AT21jAasfL9ah  schema:addressCountry it:WtC49aYLe8s0lsFC . 
    it:4D9AT21jAasfL9ah  rdfs:label 'Denpasar' . 
    it:4D9AT21jAasfL9ah  rdf:type schema:City . 
    it:4D9AT21jAasfL9ah  schema:url <http://www.denpasarkota.go.id/> . 
    it:4D9AT21jAasfL9ah  it:wikiLink <https://en.wikipedia.org/wiki/Denpasar> .
     }
     WHERE {
    it:4D9AT21jAasfL9ah ?p ?o .
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:description ?o_0 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:hasArea ?o_1 }
    OPTIONAL {  ?o_1 rdf:type ?o_1_0 }
    OPTIONAL {  ?o_1 schema:unitCode ?o_1_1 }
    OPTIONAL {  ?o_1 schema:value ?o_1_2 }
    OPTIONAL {  ?o_1 schema:unitText ?o_1_3 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:unresolvedWikidataType ?o_2 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:longitude ?o_3 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:addressCountry ?o_4 }
    OPTIONAL {  it:4D9AT21jAasfL9ah rdfs:label ?o_5 }
    OPTIONAL {  it:4D9AT21jAasfL9ah rdf:type ?o_6 }
    OPTIONAL {  it:4D9AT21jAasfL9ah schema:url ?o_7 }
    OPTIONAL {  it:4D9AT21jAasfL9ah it:wikiLink ?o_8 }
 }

This is the output in json format,
and only hasArea which has blank node values is being repeated many times

"schema:latitude": [
  "-7.164444444444444"
],
"it:hasArea": [
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },
  {
    "rdf:type": [
      "schema:QuantitativeValue"
    ],
    "schema:unitCode": [
      "KMK"
    ],
    "schema:value": [
      "392.47"
    ],
    "schema:unitText": [
      "km²"
    ]
  },...
],
"rdfs:label": [
  "Denpasar"
],
...

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文