How to generate all triples that fit a particular node type or/and edge type using SPARQL query?

偶尔善良 提交于 2019-12-20 07:23:10

问题


It is a follow up question to :

How to list and count the different types of node and edge entities in the graph data using SPARQL query?

So assuming I have the different node entities and edge entities of a given graph, how do I go about listing all triples, given a node-edge-node pattern? And how do I generate ALL node-edge-node patterns given the node and edge entities?

Example: If there is a network consisting of papers(nodes), authors(nodes), conferences(nodes), iswrittenby(edge), ispublishedin(edge), presentsin(edge) and so on , I'd have node entity type : papers authors conferences and for edge entity type: iswrittenby, ispublishedin , presentsin etc

What I'm looking to do now is generate patterns like:

1) paper(node)-iswrittenby(edge)-author(node) 2) paper(node)-iscitedby(edge)-paper(node) and so on... and then generate all triples from the dataset which satisfy these patterns.


回答1:


I think what you're looking for is

construct {   
  ?paper :isWrittenBy ?author .
  ?paper :isCitedBy ?paper2
}
where {
  ?paper :isWrittenBy ?author .
  ?paper :isCitedBy ?paper2
}

The spec section on construct queries might be a helpful reference.



来源:https://stackoverflow.com/questions/24197081/how-to-generate-all-triples-that-fit-a-particular-node-type-or-and-edge-type-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!