RDF in Semantic Mediawiki

From artserver wiki


Notes on importing ontologies to SMW

How to importing ontology?

The documentation on importing existing ontologies to SMW in its Manual Section Help:Import_vocabulary

MediaWiki:Smw_import

To import existing Semantic Web ontologies SMW uses the MediaWiki:Smw_import_ONTOGOLOGYNAME pages, such as MediaWiki:Smw_import_foaf for the Friend Of A Friend ontology.

SMW manual mentions the following ontologies, some of which are already present in SMW instances, others need to be create from the examples provided by the SMW manual:

I will be adding and making use of in this wiki of the foaf ontology.


Property pages

Each one of the properties listed in the MediaWiki:Smw_import_XYZ page has to be created with the following template

* [[Imported from::ONTOLOGYNAME:PROPERTY]] 
* [[Has property description::DESCRIPTION OF PROPERTY.@langcode]] 

[[Category:Imported vocabulary]]{{DISPLAYTITLE:ONTOLOGYNAME:PROPERTY}}


As for instance the Property:foaf:name:

* [[Imported from::foaf:name]] 
* [[Has property description::A name for some thing or agent.@en]] 

[[Category:Imported vocabulary]]{{DISPLAYTITLE:foaf:name}}

Note in that Property page that the Property Type is not declared on this page, but its assignment is done at the ontology import page

Because it can be quite tedious to create all those Property pages manually we can resort to scripts which create wiki pages, by interaction with the Mediawiki API [1]

After the Properties have been created ensure to run MW's scripts:

  • maintenance/runJobs.php to run pending jpbs
  • maintenance/update.php since we made change to Property types


The created Properties should be visible in Special:Properties

Classes == Categories

As it is visible in MediaWiki:Smw_import_foaf the entries Person and Organization both haveCategory as their type, which makes them not a Property but a Category. And as a result they do not have property pages but category pages: Category:Person, Category:Organization.


In the category page, you have to inform SWM that this is an imported class from an external vocabulary. This is done via the Imported from special property declaration:

[[Imported from::foaf:Person]]


Why Categories?

The reason they are Categories is because SMW uses categories to state that something is an element of a class, as categories are mapped internally as rdf:type.. In Semantic Web ontologies classes create semantic classification groupings. And according to the RDF Schema" "rdf:type is an instance of rdf:Property that is used to state that a resource is an instance of a class." [2]


A class in OWL is a classification of individuals into groups which share common characteristics. If an individual is a member of a class, it tells a machine reader that it falls under the semantic classification given by the OWL class.[3]

The FOAF specification[4] stipulates the following classes: Agent | Document | Group | Image | LabelProperty | OnlineAccount | OnlineChatAccount | OnlineEcommerceAccount | OnlineGamingAccount | Organization | Person | PersonalProfileDocument | Project out of which the MediaWiki:Smw_import_foaf uses Person and Organization.


Annotating

As an example of semantic annotations, which use and imported vocabulary I will use the pages Rana Hamadeh - The Ten Murders of Josephine, Rana Hamadeh and Witte de With Center for Contemporary Art

In Rana Hamadeh - The Ten Murders of Josephine belongs to Class Category:Project

* '''Location:''' [[Foaf:maker::Witte de With Center for Contemporary Art]], Rotterdam
* '''Author:''' [[Foaf:maker::Rana Hamadeh]]

[[Category:Project]]


Rana Hamadeh belongs to the Class Category:Person with the FOAF descriptors:

{{#set: Foaf:name=Rana Hamadeh
|Foaf:homepage=http://ranahamadeh.com/
|Foaf:depiction=https://dutchartinstitute.eu/image/2014/5/12/r_hamadeh_self_portrait_2.jpg
|Foaf:knows=User:Andre|Jorg Schellekens
|Foaf:made=Rana Hamadeh - The Ten Murders of Josephine
}}
[[Category:Person]]

Witte de With Center for Contemporary Art belongs to the Class Category:Organization

{{#set: foaf:website=http://www.wdw.nl/en/
|foaf:knows=Rana Hamadeh
|foaf:made=Rana Hamadeh - The Ten Murders of Josephine
}}

Inverse Properties: not supported by SMW

It is worth noting that both Rana Hamadeh and Witte de With Center for Contemporary Art use the Property:foaf:made which is the inverse of Property:foaf:maker. In a normal situation, since they are inverse we would not need to also define the Property:foaf:made in Rana Hamadeh and Witte de With Center for Contemporary Art. However SMW Semantic MediaWiki does not internally support inverse relationships. So a bit of redundancy is necessary

Ask

We can ask who made something

{{#ask: [[Foaf:made::+]]
 |?Foaf:made
 |format=broadtable
 |limit=50
 |offset=0
 |link=all
 |sort=
 |order=asc
 |headers=show
 |mainlabel=Foaf:maker
 |searchlabel=... further results
 |class=sortable wikitable smwtable
}}
Foaf:makerFoaf:made
Witte de With Center for Contemporary ArtRana Hamadeh - The Ten Murders of Josephine


Or What entities know other entities and what aretheir classes. In other words Who knows Who

{{#ask: [[Foaf:knows::+]]
 |?Category=Class
 |?Foaf:knows
 |format=broadtable
 |limit=50
 |offset=0
 |link=all
 |sort=
 |order=asc
 |headers=show
 |mainlabel=Entity
 |searchlabel=... further results
 |class=sortable wikitable smwtable
}}
EntityClassFoaf:knows
Femke SneltingPersonAndre
Renée Turner
Cristina Cochior
Rana HamadehPersonAndre
Jorg Schellekens
Renée TurnerPersonAndre
Cristina Cochior
Femke Snelting
Witte de With Center for Contemporary ArtOrganizationRana Hamadeh

RDF export


Code Notes 2020

... more about "RDF in Semantic Mediawiki"
Code Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2020 +