All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttl.dbhistory.profile.rq Maven / Gradle / Ivy

prefix ft: 
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
    )
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy