Skip to content

Commit

Permalink
Update stats (add triples and sameAs links total count)
Browse files Browse the repository at this point in the history
  • Loading branch information
solenn-tl committed Oct 31, 2023
1 parent 76909f2 commit f952f92
Showing 1 changed file with 85 additions and 37 deletions.
122 changes: 85 additions & 37 deletions stats.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
const prefixes = "PREFIX adb: <http://rdf.geohistoricaldata.org/def/directory#> "+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX owl: <http://www.w3.org/2002/07/owl#> "+
"PREFIX fn: <http://www.w3.org/2005/xpath-functions#> "+
"PREFIX prov: <http://www.w3.org/ns/prov#> "+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "+
"PREFIX pav: <http://purl.org/pav/> "+
"PREFIX locn: <http://www.w3.org/ns/locn#> "+
"PREFIX gsp: <http://www.opengis.net/ont/geosparql#> "

function totalNumEntries(graphname_){
var totalEntries;
var statsdiv = document.getElementById('totalstats')
var statsdiv = document.getElementById('totalstatsE')

//SPARQL request to get total number of entries
var query = "PREFIX adb: <http://rdf.geohistoricaldata.org/def/directory#> "+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX owl: <http://www.w3.org/2002/07/owl#> "+
"PREFIX fn: <http://www.w3.org/2005/xpath-functions#> "+
"PREFIX prov: <http://www.w3.org/ns/prov#> "+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "+
"PREFIX pav: <http://purl.org/pav/> "+
"PREFIX locn: <http://www.w3.org/ns/locn#> "+
"PREFIX gsp: <http://www.opengis.net/ont/geosparql#> "+
var query = prefixes +
'SELECT (count(distinct ?index) as ?count) '+
"WHERE { "+
"GRAPH <" + graphname_ + "> {" +
"?uri a adb:Entry."+
"?uri adb:numEntry ?index.}}"
var queryURL = repertoireGraphDB + "?query="+encodeURIComponent(query)+"&?outputFormat=rawResponse";
console.log(query)
//console.log(query)

$.ajax({
url: queryURL,
Expand All @@ -29,32 +31,23 @@ function totalNumEntries(graphname_){
}).done((promise) => {
console.log(promise)
totalEntries = promise.results.bindings[0].count.value
statsdiv.innerHTML += '<p style="text-align:center;">Nombre d\'entrées<br><span style="color:purple;font-size: medium">' + totalEntries + '<span></p>'
statsdiv.innerHTML += '<p style="text-align:center;">Nombre d\'entrées d\'annuaires<br><span style="color:purple;font-size: medium">' + totalEntries + '<span></p>'
})

};

function totalNumRessources(graphname_){
var totalRessources;
var statsdiv = document.getElementById('totalstats')
var statsdiv = document.getElementById('totalstatsR')

//SPARQL request to get total number of entries
var query = "PREFIX adb: <http://rdf.geohistoricaldata.org/def/directory#> "+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX owl: <http://www.w3.org/2002/07/owl#> "+
"PREFIX fn: <http://www.w3.org/2005/xpath-functions#> "+
"PREFIX prov: <http://www.w3.org/ns/prov#> "+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "+
"PREFIX pav: <http://purl.org/pav/> "+
"PREFIX locn: <http://www.w3.org/ns/locn#> "+
"PREFIX gsp: <http://www.opengis.net/ont/geosparql#> "+
var query = prefixes+
'SELECT (count(distinct ?uri) as ?count) '+
"WHERE { "+
"GRAPH <" + graphname_ + "> {" +
"?uri a adb:Entry."+
"?uri adb:numEntry ?index.}}"
"?uri a adb:Entry.}}"
var queryURL = repertoireGraphDB + "?query="+encodeURIComponent(query)+"&?outputFormat=rawResponse";
console.log(query)
//console.log(query)

$.ajax({
url: queryURL,
Expand All @@ -64,22 +57,70 @@ function totalNumRessources(graphname_){
data:''
}).done((promise) => {
totalRessources = promise.results.bindings[0].count.value
statsdiv.innerHTML += '<p style="text-align:center;">Nombre de ressources RDF<br><span style="color:purple;font-size: medium">' + totalRessources + '<span></p>'
statsdiv.innerHTML += '<p style="text-align:center;">Nombre de ressources RDF <br><span style="color:purple;font-size: medium">' + totalRessources + '<span></p>'
})

};

function numTriples(graphname_){
var countTriples;
var statsdiv = document.getElementById('totalstatsT')

//SPARQL request to get total number of entries
var query = prefixes+
'SELECT (count(distinct *) as ?count) '+
"WHERE { "+
"GRAPH <" + graphname_ + "> {" +
"?s ?p ?o}}"
var queryURL = repertoireGraphDB + "?query="+encodeURIComponent(query)+"&?outputFormat=rawResponse";
//console.log(query)

$.ajax({
url: queryURL,
Accept: "application/sparql-results+json",
contentType:"application/sparql-results+json",
dataType:"json",
data:''
}).done((promise) => {
countTriples = promise.results.bindings[0].count.value
statsdiv.innerHTML += '<p style="text-align:center;">Nombre de triplets RDF <br><span style="color:purple;font-size: medium">' + countTriples + '<span></p>'
})

};

function numSameAS(graphname_){
var countSameAS;
var statsdiv = document.getElementById('totalstatsSameAs')

//SPARQL request to get total number of sameAs link where ?s != ?p
var query = prefixes+
'SELECT (count(distinct *) as ?count) '+
"WHERE { "+
"GRAPH <" + graphname_ + "> {" +
"?e1 a adb:Entry."+
"?e2 a adb:Entry."+
"?e1 owl:sameAs ?e2."+
"FILTER (?e1 != ?e2)"+
"}}"
var queryURL = repertoireGraphDB + "?query="+encodeURIComponent(query)+"&?outputFormat=rawResponse";
//console.log(query)

$.ajax({
url: queryURL,
Accept: "application/sparql-results+json",
contentType:"application/sparql-results+json",
dataType:"json",
data:''
}).done((promise) => {
countSameAS = promise.results.bindings[0].count.value
statsdiv.innerHTML += '<p style="text-align:center;">Nombre de liens sameAs entre des ressources différentes<br><span style="color:purple;font-size: medium">' + countSameAS + '<span></p>'
})

};

function statsCountByYear(graphname_){
//SPARQL request
var query = "PREFIX adb: <http://rdf.geohistoricaldata.org/def/directory#> "+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX owl: <http://www.w3.org/2002/07/owl#> "+
"PREFIX fn: <http://www.w3.org/2005/xpath-functions#> "+
"PREFIX prov: <http://www.w3.org/ns/prov#> "+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "+
"PREFIX pav: <http://purl.org/pav/> "+
"PREFIX locn: <http://www.w3.org/ns/locn#> "+
"PREFIX gsp: <http://www.opengis.net/ont/geosparql#> "+
var query = prefixes +
'SELECT (count(distinct ?index) as ?count) ?directoryDate '+
"WHERE { "+
"GRAPH <" + graphname_ + "> {" +
Expand All @@ -90,7 +131,7 @@ function statsCountByYear(graphname_){
"} } GROUP BY ?directoryDate"+
" ORDER BY ASC(?directoryDate)"
var queryURL = repertoireGraphDB + "?query="+encodeURIComponent(query)+"&?outputFormat=rawResponse";
console.log(query)
//console.log(query)

var json = []

Expand Down Expand Up @@ -150,9 +191,16 @@ function getStats(){
var statsdiv = document.getElementById("statistiques")
statsdiv.innerHTML = ''
statsdiv.innerHTML += '<h3 style="margin:10px;">Statistiques du jeu de données ' + '"'+ graphlabel_ + '"' + '</h3>'+
'<div id="totalstats"></div>'+
'<div id="totalstats">'+
'<div id="totalstatsE"></div>'+
'<div id="totalstatsR"></div>'+
'<div id="totalstatsT"></div>'+
'<div id="totalstatsSameAs"></div>'+
'</div>'+
'<div id="barplot"></div>'
totalNumEntries(graphname_)
totalNumRessources(graphname_)
numTriples(graphname_)
numSameAS(graphname_)
statsCountByYear(graphname_)
}

0 comments on commit f952f92

Please sign in to comment.