template.dbhistory.rul Maven / Gradle / Ivy
%s
"""
st:call-template(st:dbpedia10, ?date)
}
}
where {
bind (st:get(st:uri) as ?uri)
bind (strafter(?uri, ) as ?year)
bind (unnest(xt:iota(1, 12)) as ?month)
bind (concat(us:digit(?month), "/", ?year) as ?str)
bind (strdt(?str, xsd:gYearMonth) as ?date)
filter kg:display(?date)
}
]]>
prefix dc:
prefix o:
template st:dbpediafortest {
us:table(aggregate(us:cell(?l, ?c, ?res, ?i)), 5)
}
where {
select distinct ?res ?l ?c ?i
where {
?rev dc:date ?date
?x dbfr:revPerMonth ?rev
?rev rdf:value ?c
?x foaf:primaryTopic ?res
?res o:thumbnail ?i
?res rdfs:label ?l
}
order by desc(?c)
}
]]>
%s
"""
st:plink(uri(concat(us:root(), ?date)))
?date
}
}
where {
}
]]>
DBpedia History %s
%s << %s << %s >> %s >> %s
"""
?date
st:call-template(st:link, us:year(?date, -1))
st:call-template(st:link, us:before(?date))
?date
st:call-template(st:link, us:after(?date))
st:call-template(st:link, us:year(?date, 1))
}
}
where {
}
]]>
This table is generated according to DBpedia history. It shows the topmost edited Wikipedia resources on a given month of a year.
It is generated by sending a SPARQL query to DBpedia history and processing the result using a STTL transformation. Each cell contains a link to a DBpedia Navigator.
%s
"""
now()
}
}
where {
}
]]>
prefix dbfr:
prefix dc:
prefix xsd:
prefix o:
prefix foaf:
template st:dbpediafortype(?date, ?type) {
us:table(aggregate(us:cell(?l, ?c, ?res, ?i)), 5)
}
where {
service {
select distinct ?res ?x ?c ?date ?type
where {
?rev dc:date ?date .
?x dbfr:revPerMonth ?rev .
?x foaf:primaryTopic ?res .
?res a ?type .
?rev rdf:value ?c
}
order by desc(?c)
limit 50
}
# split in two services appears to be much more efficient !
service {
?res o:thumbnail ?i
?res rdfs:label ?l filter langMatches(lang(?l), "fr")
}
}
]]>
template st:profile {}
where {}
# "10/2015"^^xsd:gYearMonth
function us:before(?date){
let (?m = xsd:integer(strbefore(?date, "/")),
?y = xsd:integer(strafter(?date, "/")),
?mm = if (?m = 1, 12, ?m - 1),
?yy = if (?m = 1, ?y - 1, ?y))
{
strdt(concat(us:digit(?mm), "/", ?yy), xsd:gYearMonth)
}
}
function us:after(?date){
let (?m = xsd:integer(strbefore(?date, "/")),
?y = xsd:integer(strafter(?date, "/")),
?mm = if (?m = 12, 1, ?m + 1),
?yy = if (?m = 12, ?y + 1, ?y))
{
strdt(concat(us:digit(?mm), "/", ?yy), xsd:gYearMonth)
}
}
function us:digit(?n){
if (?n < 10 && strlen(str(?n)) = 1, concat("0", ?n), ?n)
}
function us:year(?date, ?incr){
let (?m = xsd:integer(strbefore(?date, "/")),
?y = ?incr + xsd:integer(strafter(?date, "/")))
{
strdt(concat(us:digit(?m), "/", ?y), xsd:gYearMonth)
}
}
function us:root(){
}
function us:clean(?s){
if (contains(?s, "Swastika")
|| contains(?s, "Panzer-Division")
,
"", ?s)
}
function us:split(?list, ?n) {
let (?table = xt:list()) {
xt:add(?table, xt:list());
for (?e in ?list) {
if (xt:size(xt:first(?table)) = ?n) {
xt:add(?table, 0, xt:list())
} ;
xt:add(xt:first(?table), ?e)
} ;
return (xt:reverse(?table))
}
}
#
# Generation of HTML table of DBpedia updates given ?list of updates
#
function us:table(list, size){
let (table = us:split(list, size)) {
st:format(ft:table.html,
letdyn (n = 0) {
us:mapconcat (
lambda(row) {
st:format(ft:tr.html,
set(n = n + 1),
us:mapconcat (lambda(cell) { st:format(ft:td.html, cell) }, row ) )
}, table)
}
)
}
}
function us:mapconcat(fun, exp) {
reduce(rq:concat, maplist(fun, exp))
}
#
# One cell of the HTML table of DBpedia updates
#
function us:cell(?l, ?c, ?x, ?i){
st:format (ft:cell.html ,
st:plink(?x, st:dbpedia),
?x,
us:clean(?i),
?l,
?c
)
}
]]>
# translated as "10/2015"^^xsd:gYearMonth
#
template st:month {
st:call-template(st:title, ?date)
format {
"""%s
"""
st:call-template(st:dbpediafortest)
}
st:call-template-with(st:d3, st:frame)
st:call-template(st:title, ?date)
st:call-template(st:tail)
}
where {
bind (st:get(st:date) as ?date)
}
# for st:d3
@public
function us:clean(?s) {
if (strstarts(?s, "nodeID://"), "", ?s)
}
]]>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy