EvaBlomqvist (Talk | contribs) |
EvaBlomqvist (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | Below you find general descriptions of three testing methods that you will apply during this exercise. Read through the descriptions of the methods, then proceed with solving the tasks that are described at the bottom of this page. Try to make sure you have enough time to try out all three methods, i.e. if you don't have time to complete the testing using one method, proceed anyway so that you have time to try all three. | ||
+ | Don't forget to document what you are doing while you solve the task! | ||
+ | |||
+ | |||
== Method 1: Unit testing through SPARQL queries == | == Method 1: Unit testing through SPARQL queries == | ||
Line 16: | Line 20: | ||
− | ''' | + | '''Example''' |
+ | I have built an ontology for the theater domain. In the ontology there is a module modelling plays and theater productions, that realize the CQ "What play is this production based on?", i.e. modelling the distinction between plays (as abstract literary works) and theater productions (where an ensemble has set up a certain play). The module specializes the Information Realization ODP and contains the classes "Play" (as a subclass of InformationObject) and "Production" (as a subclass of InformationRealization), as well as the properties "producesPlay"/"playProducedIn" as subproperties of the pattern properties. To test this using the method described above, I formulate the CQ as the following SPARQL query: | ||
− | + | SELECT ?production ?play | |
+ | WHERE { ?production :producesPlay ?play . } | ||
− | + | Next, I create a new empty ontology, where I import the module about plays and productions. I add some concrete instances of plays and productions, and relate them through the available properties, for instance triples like ''merchantOfVeniceProduction producesPlay merchantOfVenice''. I then list the "correct answers" that the SPARQL query should return, in the case of the triple above it would be the variable bindins ?production - merchantOfVeniceProduction and ?play - merchantOfVenice. Then I run the query and check that that is actually what I get. | |
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 42: | Line 38: | ||
# Inspect the explicit reasoning requirements that you can find among the requirements of the module, if any. Also, determine if there are any implicit reasoning requirements, i.e. reasoning requirements that should be added to the set of requirements. This may include some interaction with the customer or a domain expert, if the requirements are ambiguous. | # Inspect the explicit reasoning requirements that you can find among the requirements of the module, if any. Also, determine if there are any implicit reasoning requirements, i.e. reasoning requirements that should be added to the set of requirements. This may include some interaction with the customer or a domain expert, if the requirements are ambiguous. | ||
# For each such requirement (in the list from step 1), list what is the input and expected output, e.g. what facts (triples) need to be present before actually running the inference engine, and what facts (triples) can be produced by the inference procedure. | # For each such requirement (in the list from step 1), list what is the input and expected output, e.g. what facts (triples) need to be present before actually running the inference engine, and what facts (triples) can be produced by the inference procedure. | ||
− | # Create a new "test case"-module, by importing the module to be tested and adding facts to it. For each reasoning requirement in the list from step 1, add some facts that can be considered as the "input" to the reasoning process (according to the result of step 2) | + | # Create a new "test case"-module, by importing the module to be tested and adding facts to it. For each reasoning requirement in the list from step 1, add some facts that can be considered as the "input" to the reasoning process (according to the result of step 2). |
# List the expected inferences that should be made based on your test data, i.e. the expected test output. | # List the expected inferences that should be made based on your test data, i.e. the expected test output. | ||
# Run an OWL reasoner over the "test case"-module and record the results. | # Run an OWL reasoner over the "test case"-module and record the results. | ||
Line 49: | Line 45: | ||
− | ''' | + | '''Example''' |
+ | I have built an ontology for the theater domain. In the ontology there is a module modelling persons, including their roles as actors and authors of plays. The requirements include a reasoning requirement, saying that I want to be able to classify persons as either authors or actors, based on if on one hand they have written a play or on the other hand have participate in any production. The module contains the classes "Person", with "Author" and "Actor" as subclasses, "Play" and "Production". The property "wrote" relates a person to a play, and the property "playsIn" relates a person to a production. Additionally I have defined Author as equivalent to instances that are persons and wrote some play, and similarly Actor as equivalent to instances that are persons and playsIn some production. | ||
− | + | The input needed for this reasoning requirement are triples relating persons to either plays or productions through the "wrote" and "playsIn" properties respectively. The expected output are triples of the form <person-instance> rdf:type Actor/Author. I proceed to create a new test case module, i.e. an empty ontology, where I import the module described above. Then I add a number of triples using the "wrote" and "playsIn" properties, e.g. ''Anne playsIn merchantOfVeniceProduction''. I list the expected inferences, i.e. for the example triple if would be the new triple ''Anne rdf:type Actor''. I run the reasoner and check that this triple is actually inferred, and that no other strange things appear as inference results. | |
− | |||
Line 72: | Line 68: | ||
# For each run in step 5, check the result against the expected result determined in step 2, and decide if the test was successful or not. A test is successful if it produces the expected inferences, e.g. an inconsistency, and no harmful side-effects. | # For each run in step 5, check the result against the expected result determined in step 2, and decide if the test was successful or not. A test is successful if it produces the expected inferences, e.g. an inconsistency, and no harmful side-effects. | ||
# For any unsuccessful tests, analyze the reason for the failure by inspecting the ontology. Document the problem, so that it can be solved by you or other ontology developers. | # For any unsuccessful tests, analyze the reason for the failure by inspecting the ontology. Document the problem, so that it can be solved by you or other ontology developers. | ||
+ | |||
+ | |||
+ | == Tasks == | ||
+ | |||
+ | |||
+ | |||
+ | '''Task:''' | ||
+ | |||
+ | Download the following ontology module xxx.owl, and put it in your NeOn Toolkit workspace folder. Access the ontology through the NeOn toolkit. Start the SPARQL plugin. The requirements for this module are the following: | ||
+ | |||
+ | CQs: | ||
+ | *... | ||
+ | *... | ||
+ | *... | ||
+ | |||
+ | Contextual statements: | ||
+ | * ... | ||
+ | |||
+ | Reasoning requirements: | ||
+ | * ... | ||
+ | |||
+ | Now, use the method described above to test the ontology module. While you are working, document what you are doing, e.g. are you following the steps exactly or not, how are you performing your task in practice, how long time does it take, and what errors are you able to find. When you feel satisfied with the testing, please answer the questionnaire for ''method 1''. | ||
+ | |||
+ | |||
+ | '''Task:''' | ||
+ | |||
+ | Load the same ontology as you used for '''Method 1''' (you see the requirements listed under the task for method 1). | ||
+ | |||
+ | Now, use the method described above to test the ontology module. While you are working, document what you are doing, e.g. are you following the steps exactly or not, how are you performing your task in practice, how long time does it take, and what errors are you able to find. When you feel satisfied with the testing, please answer the questionnaire for ''method 2''. | ||
Below you find general descriptions of three testing methods that you will apply during this exercise. Read through the descriptions of the methods, then proceed with solving the tasks that are described at the bottom of this page. Try to make sure you have enough time to try out all three methods, i.e. if you don't have time to complete the testing using one method, proceed anyway so that you have time to try all three. Don't forget to document what you are doing while you solve the task!
Parts of the ontology requirements are usually expressed as competency questions (CQs), i.e. natural language questions that the ontology should be able to provide answers to. One way to practically allow the ontology to answer such questions is to reformulate them as SPARQL queries, in order to retrieve the appropriate facts from the knowledge base. This also introduces a way of testing your ontology module!
Assuming that your ontology attempts to solve the two CQs, CQ1 and CQ2. Then each of those should be possible to formulate as a SPARQL query, Q1 and Q2, over the ontology module, such that the retrieved instances and/or literal values constitute the answer to the CQs. Q1 and Q2 could be considered as unit tests for the module, since they assure that the requirements CQ1 and CQ2 are actually met.
This method of testing contains the following steps:
Example
I have built an ontology for the theater domain. In the ontology there is a module modelling plays and theater productions, that realize the CQ "What play is this production based on?", i.e. modelling the distinction between plays (as abstract literary works) and theater productions (where an ensemble has set up a certain play). The module specializes the Information Realization ODP and contains the classes "Play" (as a subclass of InformationObject) and "Production" (as a subclass of InformationRealization), as well as the properties "producesPlay"/"playProducedIn" as subproperties of the pattern properties. To test this using the method described above, I formulate the CQ as the following SPARQL query:
SELECT ?production ?play WHERE { ?production :producesPlay ?play . }
Next, I create a new empty ontology, where I import the module about plays and productions. I add some concrete instances of plays and productions, and relate them through the available properties, for instance triples like merchantOfVeniceProduction producesPlay merchantOfVenice. I then list the "correct answers" that the SPARQL query should return, in the case of the triple above it would be the variable bindins ?production - merchantOfVeniceProduction and ?play - merchantOfVenice. Then I run the query and check that that is actually what I get.
Although CQs express what information the ontology should be able to provide, they do not say how this information is produced, i.e. if it is input into the ontology explicitly as assertions or produced from other facts through some inference mechanism. Therefore an ontology can have additional requirements, describing some desired inferences that the ontology should support. For instance, in an ontology about people we may define the class "parent" and say that any person who has at least one child is a parent. If we are not expecting the information about being a parent or not to be explicitly entered into the ontology's knowledge base, we may instead expect it to be derived from the presence of "hasChild" relations. This is a reasoning requirement that requires the ontology to include the appropriate axioms to make this inference.
To test the desired inferences of the ontology module, follow these steps:
Example
I have built an ontology for the theater domain. In the ontology there is a module modelling persons, including their roles as actors and authors of plays. The requirements include a reasoning requirement, saying that I want to be able to classify persons as either authors or actors, based on if on one hand they have written a play or on the other hand have participate in any production. The module contains the classes "Person", with "Author" and "Actor" as subclasses, "Play" and "Production". The property "wrote" relates a person to a play, and the property "playsIn" relates a person to a production. Additionally I have defined Author as equivalent to instances that are persons and wrote some play, and similarly Actor as equivalent to instances that are persons and playsIn some production.
The input needed for this reasoning requirement are triples relating persons to either plays or productions through the "wrote" and "playsIn" properties respectively. The expected output are triples of the form <person-instance> rdf:type Actor/Author. I proceed to create a new test case module, i.e. an empty ontology, where I import the module described above. Then I add a number of triples using the "wrote" and "playsIn" properties, e.g. Anne playsIn merchantOfVeniceProduction. I list the expected inferences, i.e. for the example triple if would be the new triple Anne rdf:type Actor. I run the reasoner and check that this triple is actually inferred, and that no other strange things appear as inference results.
Although the ability to perform correct inferences, and provide the resulting information as a result of queries, allow us to see that the ontology actually realizes its requirements, another important characteristic of an ontology is to allow as few erroneous facts and/or inferences as possible. A high-quality ontology allows exactly the desired inferences and queries, while avoiding to produce irrelevant or erroneous side-effects. It may also be desirable to be able to check input data against some constraints and business rules.
This category of testing can be compared to software testing, when usually a system is fed random data, data known to be incorrect, or data considered as "boundary values" for the data, e.g. the extremes of value ranges, in order to check its robustness and capability to handle unexpected input. When dealing with ontologies, we are not evaluating how good error messages and recovery strategies are, as for software, but rather that erroneous facts and data is detected in the first place. One way to detect such problems is by using the consistency checking facilities of a reasoning engine. A high-quality ontology facilitates the reasoner to detect inconsistencies when inappropriate or erroneous facts are entered.
For instance, in a user model ontology with the classes "female user" and "male user", where this information is going to be collected from a web form with a radio button, the classes should most likely be disjoint, i.e. since no user can select both alternatives from the form any given user can only be an instance of one class. After detecting such implicit requirements, or common sense constraints, and expressing them as contextual statements, they can be tested by entering obviously inconsistent facts, and checking that the reasoner is able to detect the inconsistency.
To test this ability of the ontology, the following steps can be used:
Task:
Download the following ontology module xxx.owl, and put it in your NeOn Toolkit workspace folder. Access the ontology through the NeOn toolkit. Start the SPARQL plugin. The requirements for this module are the following:
CQs:
Contextual statements:
Reasoning requirements:
Now, use the method described above to test the ontology module. While you are working, document what you are doing, e.g. are you following the steps exactly or not, how are you performing your task in practice, how long time does it take, and what errors are you able to find. When you feel satisfied with the testing, please answer the questionnaire for method 1.
Task:
Load the same ontology as you used for Method 1 (you see the requirements listed under the task for method 1).
Now, use the method described above to test the ontology module. While you are working, document what you are doing, e.g. are you following the steps exactly or not, how are you performing your task in practice, how long time does it take, and what errors are you able to find. When you feel satisfied with the testing, please answer the questionnaire for method 2.
Task:
Load the same ontology as you used for Method 1 (you see the requirements listed under the task for method 1).
Now, use the method described above to test the ontology module. While you are working, document what you are doing, e.g. are you following the steps exactly or not, how are you performing your task in practice, how long time does it take, and what errors are you able to find. When you feel satisfied with the testing, please answer the questionnaire for method 3.