�Ontology testing �in eXtreme Design����
Fiorela Ciroku
PhD student, cycle XXXV, University of Bologna
fiorela.ciroku2@unibo.it
Outline
User stories
A user story is a set of sentences which describe by example the kind of facts that the knowledge graph is required to encode.
User stories may be described by:
User stories�Carolina – Sources Cross Analysis
Persona���Carolina is a music historian with a passion for the Baroque. She is a researcher and collaborates with the International Museum and the Music Library of Bologna.
Goal���Carolina has to prepare a conference for the anniversary of the birth of the composer Giacomo Antonio Perti and she needs to collect some information about his career.
Scenario��In order to accomplish her goal first Carolina must find the scores that constitute her primary sources. Thus, Carolina should find the places where these compositions were played for the first time how many musicians were involved, how many musical instruments, the names of the musicians. Carolina is also interested in the singers involved and the choir. Carolina has to find written evidence that says how these Masses were received. Carolina is also interested in finding out in which tonality the compositions were written.
User stories�Carolina – Competency Questions
1. Where was a musical composition performed?
- In which buildings was a musical composition performed?
2. Where was a musical composition performed for the first time?
- In which buildings was a musical composition performed for the first time?
3. Which performers (musicians, singers) have performed a musical composition?
- Which performers (musicians, singers) have performed a musical composition for the first time?�
Testing in XD
Competency question verification�Select a requirement!
Where was a musical composition performed?
Understanding the requirement�Competency question verification test
Where did the prefixes come from?�Competency question verification test
Define test case�Competency question verification test
@prefix owlunit: <https://w3id.org/OWLunit/ontology/> .
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/> .
@prefix tc: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/test-case/> .
@prefix mp: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/musical-performance.owl> .
tc:CQ1.ttl a owlunit:CompetencyQuestionVerification ;
owlunit:hasCompetencyQuestion "Where was a musical composition performed?" ;
owlunit:hasSPARQLUnitTest ” " ;
owlunit:hasInputData td: ;
owlunit:hasInputTestDataCategory owlunit:ToyDataset ;
owlunit:hasExpectedResult “ ";
owlunit:testsOntology mp: .
Natural language to SPARQL�Competency question verification test
First step: Translate the competency question from natural language to SPARQL query.
Where was a musical composition performed?
PREFIX mp: <https://w3id.org/polifonia/ON/musical-performance/>
PREFIX core: <https://w3id.org/polifonia/ON/core/>
SELECT DISTINCT ?place
WHERE {
?musicalComposition mp:isInvolvedInMusicalPerformance ?performance .
?performance core:hasPlace ?place }
Add test data
Creating a toy dataset, from either real or made-up data!
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/> .
@prefix mp: <https://w3id.org/polifonia/ON/musical-performance/> .
@prefix core: <https://w3id.org/polifonia/ON/core/> .
td:Toxicity mp:isInvolvedInMusicalPerformance td:SystemOfADown-FirenzeRocks2017 .
td:SystemOfADown-FirenzeRocks2017 core:hasPlace td:Florence .
Determine expected results
- Depending on the test data, determine what output would be correct.
- For example, specify the data with testAnnotationSchema:hasExpectedResult property.
- Expected results can be specified as a JSON serialization or using this vocabulary.
{ \"head\":
{ \"vars\": [ \"place\" ] } ,
\"results\": { \"bindings\":
[ { \"place\": { \"type\": \"uri\" , \"value\": \"https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/Florence\" } } ] } }
JSON serialization
Define test case�Competency question verification test
@prefix owlunit: <https://w3id.org/OWLunit/ontology/> .
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/> .
@prefix tc: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/test-case/> .
@prefix mp: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/musical-performance.owl> .
tc:CQ1.ttl a owlunit:CompetencyQuestionVerification ;
owlunit:hasCompetencyQuestion "Where was a musical composition performed?" ;
owlunit:hasSPARQLUnitTest "PREFIX mp: <https://w3id.org/polifonia/ON/musical-performance/> PREFIX core: <https://w3id.org/polifonia/ON/core/> SELECT DISTINCT ?place WHERE {?composition mp:isInvolvedInMusicalPerformance ?performance . ?performance core:hasPlace ?place }" ;
owlunit:hasInputData td:TD1.ttl ;
owlunit:hasInputTestDataCategory owlunit:ToyDataset ;
owlunit:hasExpectedResult "{ \"head\": { \"vars\": [ \"place\" ] } , \"results\": { \"bindings\": [ { \"place\": { \"type\": \"uri\" , \"value\": \"https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/Florence\" } } ] } }";
owlunit:testsOntology mp: .
Inference verification test
@prefix owlunit: <https://w3id.org/OWLunit/ontology/> .
@prefix mp: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/musical-performance.owl> .
@prefix tc: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/inference/test-case/> .
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/inference/toy-dataset/> .
tc:iv1.ttl a owlunit:InferenceVerification ;
owlunit:hasInputData ex:TD2.ttl ;
owlunit:hasSPARQLUnitTest " PREFIX core: <https://w3id.org/polifonia/ON/core/> ASK {td:SystemOfADown-FirenzeRocks2017 a mp:MusicalPerformance}" ;
owlunit:hasReasoner owlunit:HermiT ;
owlunit:hasExpectedResult true ;
owlunit:testsOntology mp: .
Error provocation test
@prefix owlunit: <https://w3id.org/OWLunit/ontology/> .
@prefix mp: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/musical-performance.owl> .
@prefix tc: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/error/test-case/> .
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/error/toy-dataset/> .
tc:ep1.ttl a owlunit:ErrorProvocation ;
owlunit:hasInputData td:epdata.ttl ;
owlunit:testsOntology mp: .
@prefix td: <https://raw.githubusercontent.com/polifonia-project/musical-performance/main/test/competency-question/toy-dataset/> .
@prefix mp: <https://w3id.org/polifonia/ON/musical-performance/> .
@prefix core: <https://w3id.org/polifonia/ON/core/> .
td:Florence a core:Place .
td:Toxicity mp:isInvolvedInMusicalPerformance td:Florence .
td:SystemOfADown-FirenzeRocks2017 core:hasPlace td:Florence .
Executing the test case�Competency question verification test
java -jar OWLUnit-0.3.2.jar –c https://github.com/polifonia-project/musical-performance-ontology/blob/main/test/competency-question/test-case/CQ1.ttl
Executing the test case�Competency question verification test
Exercise�
Requirement:
When was a recording produced?
- Translate the competency question to a SPARQL query.�- Create a toy dataset for the test case.�- Create an expected result file.�- Create a unit test case for the competency question.�- Create an inference verification test case.�- Create an error provocation test case.
Exercise�
Sources:
- Graffoo diagram�- Relevant ontology owl files: � - Musical performace ontology� - Core ontology�
Grazie!