相关疑难解决方法(0)

带有限制的 sparql 中的嵌套查询

我目前正在尝试为我必须展示的用例创建一个 dbpedia 数据示例。我的主要目标是要求每位欧洲艺术家 5 幅五幅画(而且我想在开始时每个国家只展示两位艺术家)。

没有限制的查询如下。

    PREFIX dbpedia-owl:<http://dbpedia.org/ontology/>
    PREFIX category: <http://dbpedia.org/resource/Category:>
    PREFIX dcterms:<http://purl.org/dc/terms/>
    PREFIX prop:<http://dbpedia.org/property/>
    PREFIX geonames:<http://sws.geonames.org/>
    PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
    PREFIX dbpedia:<http://dbpedia.org/resource/>
    PREFIX geo-ont:<http://www.geonames.org/ontology#>
    PREFIX ourvocab:<http://example.org/>
    prefix foaf:<http://xmlns.com/foaf/0.1/>

    SELECT DISTINCT ?painting_name ?artist_name ?european_country ?description ?artist_birthday_year
    WHERE {

    ?european_country dcterms:subject category:Countries_in_Europe.
    ?european_country rdf:type dbpedia-owl:Place.

    ?painting prop:artist ?artist.
    ?painting rdfs:label ?painting_name.
    ?painting prop:type dbpedia:Oil_painting.
    ?painting rdfs:comment ?description.

    ?artist foaf:name ?artist_name.
    ?artist rdf:type dbpedia-owl:Artist.
    ?artist prop:placeOfBirth ?european_country.
    ?artist dbpedia-owl:birthDate ?artist_birthday.


     FILTER (lang(?painting_name) = "" || lang(?painting_name) = "en")
     FILTER (lang(?description) = "" || lang(?description) …
Run Code Online (Sandbox Code Playgroud)

semantic-web sparql dbpedia

6
推荐指数
0
解决办法
1691
查看次数

SPARQL 限制变量每个值的结果

这是重现问题所需的最少数据

@prefix : <http://example.org/rs#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

:artist1 rdf:type :Artist .
:artist2 rdf:type :Artist .
:artist3 rdf:type :Artist .
:en rdf:type :Language .
:it rdf:type :Language .
:gr rdf:type :Language .

:c1
    rdf:type :CountableClass ;
    :appliedOnClass :Artist ;
    :appliedOnProperty :hasArtist
.

:c2
    rdf:type :CountableClass ;
    :appliedOnClass :Language ;
    :appliedOnProperty :hasLanguage
.

:i1
    rdf:type :RecommendableClass ;
    :hasArtist :artist1 ;
    :hasLanguage :en
.

:i2
    rdf:type :RecommendableClass ;
    :hasArtist :artist1 ;
    :hasLanguage :en
.


:i3
    rdf:type :RecommendableClass;
    :hasArtist :artist1 ; …
Run Code Online (Sandbox Code Playgroud)

sparql

1
推荐指数
1
解决办法
1215
查看次数

标签 统计

sparql ×2

dbpedia ×1

semantic-web ×1