Sparql CONSTRUCT 与 DISTINCT
Sparql CONSTRUCT with DISTINCT
PREFIX content: <http://example.com/content#>
construct { ?s content:field ?o}
WHERE { ?s content:field ?o }
我收到的所有 ?o
中的 90% 都是相同的 URI <http://example.com/name>
。
我试图找到一种方法来过滤掉所有具有相同 ?o
值的四边形,所以最后我得到了一个四边形列表,这些四边形的 ?o
是独一无二的
我试过 DISTINCT ?o CONSTRUCT{...}
但据我所知,你不能在 CONSTRUCT
上使用 DISTINCT
。
您将如何过滤返回的四边形列表
I'm trying to find a way to filter out all quads that have the same
value for ?o
, so in the end I get a list of quads which are unique by
its ?o
如果将哪个确切值绑定到 ?s
并不重要,那么使用 group by ?o
的子 select 是可行的方法。使用 (SAMPLE(?s) as ?subj)
例如就像是:
`
PREFIX content: <http://example.com/content#>
construct { ?s content:field ?o}
WHERE {
{ select ?o (SAMPLE(?subj) as ?s)
{ ?subj content:field ?o }
group by ?o
}
}
`
PREFIX content: <http://example.com/content#>
construct { ?s content:field ?o}
WHERE { ?s content:field ?o }
我收到的所有 ?o
中的 90% 都是相同的 URI <http://example.com/name>
。
我试图找到一种方法来过滤掉所有具有相同 ?o
值的四边形,所以最后我得到了一个四边形列表,这些四边形的 ?o
是独一无二的
我试过 DISTINCT ?o CONSTRUCT{...}
但据我所知,你不能在 CONSTRUCT
上使用 DISTINCT
。
您将如何过滤返回的四边形列表
I'm trying to find a way to filter out all quads that have the same value for
?o
, so in the end I get a list of quads which are unique by its?o
如果将哪个确切值绑定到 ?s
并不重要,那么使用 group by ?o
的子 select 是可行的方法。使用 (SAMPLE(?s) as ?subj)
例如就像是:
`
PREFIX content: <http://example.com/content#>
construct { ?s content:field ?o}
WHERE {
{ select ?o (SAMPLE(?subj) as ?s)
{ ?subj content:field ?o }
group by ?o
}
}
`