sparnatural
Version:
Visual client-side SPARQL query builder and knowledge graph exploration tool
59 lines • 2.07 kB
JavaScript
import { DataFactory } from "rdf-data-factory";
import { DCT } from "../../rdf/vocabularies/DCT";
import { VOID } from "../../rdf/vocabularies/VOID";
let factory = new DataFactory();
export class StatisticsReader {
constructor(store) {
this.store = store;
}
hasStatistics(shape) {
let found = false;
let partitions = this.store
.findSubjectsOf(DCT.CONFORMS_TO, shape);
partitions.forEach(partition => {
if (this.store.hasTriple(partition, VOID.TRIPLES, null)
||
this.store.hasTriple(partition, VOID.ENTITIES, null)) {
found = true;
}
});
return found;
}
getDistinctObjectsCountForShape(shape) {
let partitions = this.store
.findSubjectsOf(DCT.CONFORMS_TO, shape);
let result = undefined;
partitions.forEach(partition => {
// here we cannot make a sum
result = this.store.readSinglePropertyAsNumber(partition, VOID.DISTINCT_OBJECTS);
});
return result;
}
getTriplesCountForShape(shape) {
let partitions = this.store
.findSubjectsOf(DCT.CONFORMS_TO, shape);
let result = undefined;
partitions.forEach(partition => {
if (result === undefined) {
result = 0;
}
// make the sum of every statistics we have
result += this.store.readSinglePropertyAsNumber(partition, VOID.TRIPLES);
});
return result;
}
getEntitiesCountForShape(shape) {
let partitions = this.store
.findSubjectsOf(DCT.CONFORMS_TO, shape);
let result = undefined;
partitions.forEach(partition => {
if (result === undefined) {
result = 0;
}
// make the sum of every statistics we have
result += this.store.readSinglePropertyAsNumber(partition, VOID.ENTITIES);
});
return result;
}
}
//# sourceMappingURL=StatisticsReader.js.map