A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/venue_articles-by-intention.sparql
Venue aspect: articles by intention
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
#defaultView:BarChart
PREFIX target: <http://www.wikidata.org/entity/Q6294930>
# Inspired from LEGOLAS - http://abel.lis.illinois.edu/legolas/
# Shubhanshu Mishra, Vetle Torvik
select ?year (count(?work) as ?number_of_publications) ?intention where {
{
select (str(?year_) as ?year) (0 as ?pages) ("_" as ?intention) where {
# default values = 0
?year_item wdt:P31 wd:Q577 .
?year_item wdt:P585 ?date .
bind(year(?date) as ?year_)
{
select (min(?year_) as ?earliest_year) (max(?year_) as ?latest_year) where {
VALUES ?JOURNAL { target: }
?work wdt:P1433 ?JOURNAL .
?work wdt:P577 ?publication_date .
bind(year(?publication_date) as ?year_)
}
}
bind(year(now())+1 as ?next_year)
filter (?year_ >= ?earliest_year && ?year_ <= ?latest_year)
}
}
union {
select ?work ?intention (min(?years) as ?year) where {
VALUES ?JOURNAL { target: }
?work wdt:P577 ?dates ;
p:P2860 / pq:P3712 / rdfs:label ?intention ;
wdt:P1433 ?JOURNAL .
bind(str(year(?dates)) as ?years) .
FILTER (LANG(?intention) = "en")
}
group by ?work ?intention
}
}
group by ?year ?intention
order by ?year
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?JOURNAL")
v6("?date")
v13("?dates")
v10("?earliest_year")
v12("?intention"):::projected
v10("?latest_year")
v10("?next_year")
v15("?number_of_publications")
v11("?pages")
v9("?publication_date")
v8("?work"):::projected
v15("?year"):::projected
v10("?year_")
v5("?year_item")
v14("?years")
a1((" "))
a2((" "))
c2([http://wikidata.org/entity/Q577]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f0[["?intention = 'en'"]]
f0 --> v12
bind1[/VALUES ?JOURNAL/]
bind1-->v13
bind10(["wd:Q6294930"])
bind10 --> bind1
v8 --"p:direct/P577"--> v13
v8 --"p:P2860"--> a1
a1 --"p:qualifier/P3712"--> a2
a2 --"rdfs:label"--> v12
v8 --"p:direct/P1433"--> v13
bind2[/"str(year-from-dateTime(?dates))"/]
v13 --o bind2
bind2 --as--o v14
bind4[/"min(?years)"/]
v14 --o bind4
bind4 --as--o v15
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f5[["?year_ >= ?earliest_year?year_ <= ?latest_year"]]
f5 --> v10
f5 --> v10
f5 --> v10
v5 --"p:direct/P31"--> c2
v5 --"p:direct/P585"--> v6
bind6[/"year-from-dateTime(?date)"/]
v6 --o bind6
bind6 --as--o v10
bind7[/VALUES ?JOURNAL/]
bind7-->v13
bind70(["wd:Q6294930"])
bind70 --> bind7
v8 --"p:direct/P1433"--> v13
v8 --"p:direct/P577"--> v9
bind8[/"year-from-dateTime(?publication_date)"/]
v9 --o bind8
bind8 --as--o v10
bind11[/"min(?year_)"/]
v10 --o bind11
bind11 --as--o v10
bind12[/"max(?year_)"/]
v10 --o bind12
bind12 --as--o v10
bind13[/"year-from-dateTime(NOW()) + '+1^^xsd:integer'"/]
bind13 --as--o v10
bind14[/"str(?year_)"/]
v10 --o bind14
bind14 --as--o v15
bind15[/"'0^^xsd:integer'"/]
bind15 --as--o v11
bind16[/"'_'"/]
bind16 --as--o v12
end
union0r <== or ==> union0l
end
bind18[/"count(?work)"/]
v8 --o bind18
bind18 --as--o v15