template.dbedit.rul Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of corese-core Show documentation
Show all versions of corese-core Show documentation
Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1
Query and Update.
%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 dbfr:
prefix dc:
prefix xsd:
prefix o:
template st:dbpediafortest(?date) {
us:table(aggregate(us:cell(?l, ?c, ?res, ?i)), 5)
}
where {
bind (st:get(st:date) as ?date)
filter kg:slice(100)
service {
select distinct ?res ?x ?c ?date
where {
?rev dc:date ?date
?x dbfr:revPerMonth ?rev
?rev rdf:value ?c
?x foaf:primaryTopic ?res
}
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")
}
}
]]>
%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) {
us:table(aggregate(us:cell(?l, ?c, ?res, ?i)), 5)
}
where {
bind (st:get(st:date) as ?date)
bind (st:get(st:mode) as ?type)
filter kg:slice(100)
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")
}
}
]]>
}
function us:clean(?s){
if (strcontains(?s, "Swastika")
|| strcontains(?s, "Panzer-Division")
,
"", ?s)
}
#
# Generation of HTML table of DBpedia updates given ?list of updates
#
function us:table(?list, ?size){
let ( ?table = st:split(?list, ?size),
?ftable = coalesce(us:format("table.html"), "\n%s
\n"),
?frow = coalesce(us:format("tr.html"), "%s %s \n"),
?fcell = coalesce(us:format("td.html"), "%s \n"))
{
st:format(?ftable,
let (?n = 0){
loop (?row in ?table){
st:format(?frow,
set(?n = ?n + 1),
loop (?cell in ?row){
st:format(?fcell, ?cell)
})
}
}
)
}
}
# URL of HTML format in the server (/data/format/dbedit/name)
function us:format(?name) {
st:getFormat("dbedit", ?name)
}
#
# One cell of the HTML table of DBpedia updates
#
function us:cell(?l, ?c, ?x, ?i){
st:format (
coalesce(us:format("cell.html"),
"""
%s (%s)
""") ,
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
"""
if (bound(?type),
st:call-template(st:dbpediafortype, ?date, ?type),
st:call-template(st:dbpediafortest, ?date))
}
st:call-template(st:title, ?date)
st:call-template(st:tail)
}
where {
bind (st:get(st:uri) as ?uri)
# type of resoures to focus on
bind (st:get(st:mode) as ?type)
bind (strafter(?uri, us:root()) as ?str)
bind (strdt(?str, xsd:gYearMonth) as ?date)
bind (st:set(st:date, ?date) as ?tmp)
}
]]>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy