1
0

MisplacedClassesOrPropertiesMetric.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //© 2019 Dublin City University, Trinity College Dublin. All rights reserved. This material may not be reproduced, displayed, modified or distributed without the express prior written permission of the copyright holder.
  2. const prefix = `
  3. PREFIX qpro: <http://purl.org/eis/vocab/qpro#>
  4. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  5. PREFIX dqm-prob: <http://www.diachron-fp7.eu/dqm-prob#>
  6. `;
  7. export const MisplacedClassesOrPropertiesMetric = (qualityGraph,dataGraph,observationURI,datasetSource) =>{
  8. let query = `
  9. SELECT ?ProblematicThing (?ProblematicThingResource AS ?Subject) ?Predicate ?Object ?FailedMertic ?Exception
  10. FROM NAMED <${qualityGraph}>
  11. FROM NAMED <${dataGraph}>
  12. WHERE
  13. {
  14. {GRAPH <${qualityGraph}>
  15. {?QualityProblem qpro:generatedBy ?Observation;
  16. a qpro:QualityProblem;
  17. qpro:isDescribedBy ?FailedMertic;
  18. qpro:problemStructure qpro:ModelContainer;
  19. qpro:problematicThing ?ProblematicThingResource}.
  20. }
  21. {{GRAPH <${qualityGraph}>
  22. {?ProblematicThingResource qpro:exceptionDescription ?Exception;
  23. ?Property ?Predicate}.
  24. FILTER(?Exception IN (dqm-prob:MisplacedClass)).
  25. FILTER(?Property IN (dqm-prob:hasMisplacedClass)).}
  26. UNION
  27. {GRAPH <${qualityGraph}>
  28. {?ProblematicThingResource qpro:exceptionDescription ?Exception;
  29. ?Property ?Object}.
  30. FILTER(?Exception IN (dqm-prob:MisplacedProperty)).
  31. FILTER(?Property IN (dqm-prob:hasMisplacedProperty)).}
  32. }
  33. {${datasetSource} <${dataGraph}>
  34. {?ProblematicThingResource ?Predicate ?Object
  35. }.
  36. }
  37. BIND(COALESCE(
  38. IF(?Exception = dqm-prob:MisplacedClass, "Predicate",IF(?Exception = dqm-prob:MisplacedProperty, "Object",""))
  39. ) AS ?ProblematicThing).
  40. FILTER(str(?Observation) = "${observationURI}").
  41. }
  42. `;
  43. return prefix + query;
  44. }
  45. export default {MisplacedClassesOrPropertiesMetric};