EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
Content: The database contains information about a past ISWC conference, and in one table called "persons" there is information about the people that organized or attended the conference. | Content: The database contains information about a past ISWC conference, and in one table called "persons" there is information about the people that organized or attended the conference. | ||
+ | |||
+ | '''The Semion rule language syntax:''' | ||
+ | |||
+ | The complete Semion rule syntax can be found [http://www.ontologydesignpatterns.org/ont/training/foi/SemionRules.pdf here], however you don't need it for the first part of this exercise. | ||
Line 53: | Line 57: | ||
* Go back to the tab of the alignment, and select the Alignment Rules tab. | * Go back to the tab of the alignment, and select the Alignment Rules tab. | ||
* At the top you see the list of rules currently inserted in this alignment (at the moment it is empty). Click on the Add-button below the table. | * At the top you see the list of rules currently inserted in this alignment (at the moment it is empty). Click on the Add-button below the table. | ||
− | * Give a name to the rule, e.g. foaf_person. Then copy the following text as the content of the rule: | + | * Give a name to the rule, e.g. foaf_person. Then copy the following text as the content of the rule and click Finish: |
− | ** | + | ** has(dbs:isRecordOf, ?person, dbSchema:persons_table) . has(dbs:isDatumOf, ?y, ?person) . has(dbs:bindsToColumn, ?y, dbSchema:persons_FirstName-column) . values(dbs:hasContent, ?y, ?fname) . has(dbs:isDatumOf, ?z, ?person) . has(dbs:bindsToColumn, ?z, dbSchema:persons_LastName-column) . values(dbs:hasContent, ?z, ?lname) -> is(foaf:Person, ?person) . values(foaf:firstName, ?person, ?fname) . values(foaf:lastName, ?person, ?lname) |
+ | ** This may seems like a very complex rule, but lets break it down to see what it means. "has" is the keyword for object property assertions, "is" indicates a rdf:type relation, and "values" indicates a data property assertion. The condition then consists of three parts: | ||
+ | *** has(dbs:isRecordOf, ?person, dbSchema:persons_table) - this matches triples that says that something (the variable ?person) is a record of the table person of the reengineered database, i.e. ?person is a row in the persons table. | ||
+ | *** has(dbs:isDatumOf, ?y, ?person) . has(dbs:bindsToColumn, ?y, dbSchema:persons_FirstName-column) . values(dbs:hasContent, ?y, ?fname) - this gets the the entry in that row that is the first name, and extracts the value into the variable ?fname | ||
+ | *** has(dbs:isDatumOf, ?z, ?person) . has(dbs:bindsToColumn, ?z, dbSchema:persons_LastName-column) . values(dbs:hasContent, ?z, ?lname) - does the corresponding thing for the lastname | ||
+ | ** Then look at the consequent, i.e. what happens if we find something that fulfills the conditions above: | ||
+ | *** is(foaf:Person, ?person) - set the record we found as an instance of foaf:Person, i.e. we align our data to the foaf ontology | ||
+ | *** values(foaf:firstName, ?person, ?fname) - relate that person instance through the foaf:firstName property to the string value we have extracted | ||
+ | *** values(foaf:lastName, ?person, ?lname) - same for the lastname | ||
+ | * After clicking Finish the rule should appear in the table of rules. Now click on Run Refactoring, to apply the rule to our RDF data. | ||
+ | * Wait until the processing has finished and then go to the SPARQL tab of the alignment. Run the default query that gets all the triples generated by the alignment. | ||
+ | * Now you should see a set of triples representing a set of instances of foaf:Person, each with a foaf:firstName and foaf:lastName - this is our refactored dataset! | ||
+ | |||
+ | |||
+ | If you have time left, proceed to write your own rules to extract more data from the database. For instance, you could write additional rules that extract more of the information about people from the persons table! | ||
+ | |||
+ | Otherwise, proceed to try out the D2R virtual RDF server below. | ||
=== Using D2R === | === Using D2R === | ||
Line 66: | Line 86: | ||
The example data is already loaded into the database, but you have to edit the example mapping to reflect the details of the database above. Then you can run the D2R server (with the mapping file in the same directory) and try accessing the DB through SPARQL in your browser. | The example data is already loaded into the database, but you have to edit the example mapping to reflect the details of the database above. Then you can run the D2R server (with the mapping file in the same directory) and try accessing the DB through SPARQL in your browser. | ||
+ | |||
+ | How do the results compare to the ones we got with Semion? |
Tutorial | Training:Advanced Ontology Engineering at FOI - 2011 |
---|---|
Title | Reengineering |
Solutions:
In this exercise you will use the Semion tool to reengieer a database table from an example database into RDF, and then to refactor it so that the data is expressed using the FOAF vocabulary.
The database:
host: mysql315.loopia.se
user name: d2r@o45820
password: (given at the course)
database name: ontology_se_db_2
Content: The database contains information about a past ISWC conference, and in one table called "persons" there is information about the people that organized or attended the conference.
The Semion rule language syntax:
The complete Semion rule syntax can be found here, however you don't need it for the first part of this exercise.
Task 1:
Your task is to use Semion to express this data in terms of the FOAF vocabulary, at the following URI: http://xmlns.com/foaf/0.1/
Start Semion from the commandline as follows (from the directory where you unpacked Semion):
Mac: java -jar -Xmx512m -XstartOnFirstThread it.cnr.istc.semion.tool-0.6-SNAPSHOT.one-jar.jar
Windows: java -jar -Xmx512m it.cnr.istc.semion.tool-0.6-SNAPSHOT.one-jar.jar
When the tool starts, the following procedure lets you do the first syntactical transformation (reengineering):
If you have time left, proceed to write your own rules to extract more data from the database. For instance, you could write additional rules that extract more of the information about people from the persons table!
Otherwise, proceed to try out the D2R virtual RDF server below.
Now, you should try to use D2R to instead create a runtime mapping to the DB, so that you can query the DB using SPARQL.
Task 2:
Use the same database as above, and run the following tutorial: http://sw.cs.technion.ac.il/d2rq/tutorial
The example data is already loaded into the database, but you have to edit the example mapping to reflect the details of the database above. Then you can run the D2R server (with the mapping file in the same directory) and try accessing the DB through SPARQL in your browser.
How do the results compare to the ones we got with Semion?