Difference between revisions of "Help:SemanticMW"

From Biowikifarm Metawiki
Jump to: navigation, search
(Calling up the data)
(Extensions -> MediaWiki Extensions)
 
(7 intermediate revisions by 4 users not shown)
Line 4: Line 4:
  
 
==Introduction==
 
==Introduction==
The Semantic MediaWiki (SemanticMW) extension is useful if you want to summarize and compare information which is located in different wiki pages. The '''[[:Category:Countries]]''' gives an example of how information on different countries can be combined in a table. This has 2 advantages:
+
The Semantic MediaWiki (SemanticMW) extension is useful if you want to summarize and compare information which is located in different wiki pages. The page '''[[Countries]]''' gives an example of how information on different countries can be combined in a table. This has 2 advantages:
 
*In the table you can sort the countries, e.g. by their population size or by the height of their highest mountain.
 
*In the table you can sort the countries, e.g. by their population size or by the height of their highest mountain.
 
*If the information in the source page changes (e.g. the figure for the total population in a given country is adjusted) then the table updates itself automatically.
 
*If the information in the source page changes (e.g. the figure for the total population in a given country is adjusted) then the table updates itself automatically.
Line 14: Line 14:
  
 
  <nowiki>[[Category:Help]]</nowiki>
 
  <nowiki>[[Category:Help]]</nowiki>
  <nowiki>[[Category:Extensions]]</nowiki>
+
  <nowiki>[[Category: MediaWiki Extensions]]</nowiki>
  
 
===Defining subcategories===
 
===Defining subcategories===
Line 34: Line 34:
 
  <nowiki>[[subproperty of::Property:Text Search]]</nowiki>
 
  <nowiki>[[subproperty of::Property:Text Search]]</nowiki>
  
These can be organized in a hierarchical, so one property could be defined as sub-property of an property and the last could be defined as a sub-property of an other property and so on.  
+
These can be organized hierarchically, so one property could be defined as sub-property of a property and the latter could be defined as a sub-property of another property and so on.  
 
For example:
 
For example:
The property '''Property:General Keyword''' is defined as '''<nowiki>[[subproperty of::Property:Any Keyword]]</nowiki>'''. Like already has seen before, the last one is '''<nowiki>[[subproperty of::Property:Text Search]]</nowiki>'''.
+
The properties '''Property:General Keyword''', '''Property:Scientific Name''' and others are defined as '''<nowiki>[[subproperty of::Property:Any Keyword]]</nowiki>'''. Like already seen before, the last one is '''<nowiki>[[subproperty of::Property:Text Search]]</nowiki>'''.
Once this has been stated, a query '''<nowiki>[[Any Keyword::Galium odoratum]]</nowiki>''' will also return the '''<nowiki>[[Scientific Name::Galium odoratum]]</nowiki>'''  even if no «Any Keyword» property is given on that page. Similar considerations as in the case of cateogries apply, and detailed descriptions on property pages are a good method for avoiding semantic drift.
+
Once this has been stated, a query (see Inline queries usage below) for '''<nowiki>[[Any Keyword::Galium odoratum]]</nowiki>''' will also return the '''<nowiki>[[Scientific Name::Galium odoratum]]</nowiki>'''  even if no «Any Keyword» property is given on that page. The same is true for a query '''<nowiki>[[Text Search::Galium odoratum]]</nowiki>'''. Similar considerations as in the case of categories apply, and detailed descriptions on property pages are a good method for avoiding semantic drift.
  
 
==Entering data==
 
==Entering data==
Line 44: Line 44:
 
  [[Area::83.9| ]]
 
  [[Area::83.9| ]]
 
  [[Population::8.3| ]]</pre>
 
  [[Population::8.3| ]]</pre>
Note the '''2 colons'''. In the above format the data assignment in the page "Austria" does not produce any text in the page. However, you can also combine the data assignment with the text displayed.
+
Note the '''2 colons'''. In the above format the data assignment in the page "Austria" does not produce any text in the page. However, you can also combine the data assignment with the text displayed by using the format <nowiki>[[Capital::Vienna]]</nowiki>
 +
 
 +
 
 +
 
  
 
==Calling up the data==
 
==Calling up the data==
Line 52: Line 55:
 
*# concepts which represent a so called "dynamic categories" through use of #concept parser function usage. A concept is a page in the Concept: namespace that is always described by a semantic query.
 
*# concepts which represent a so called "dynamic categories" through use of #concept parser function usage. A concept is a page in the Concept: namespace that is always described by a semantic query.
 
===Inline queries usage===
 
===Inline queries usage===
For retrieving or querying the data like in the '''[[:Category:Countries]]''' use the format:<pre>
+
For retrieving or querying the data like in the page '''[[Countries]]''' use the format:<pre>
 
  {{#ask: [[Category:Countries| country]]  
 
  {{#ask: [[Category:Countries| country]]  
 
  | ?Capital# = capital
 
  | ?Capital# = capital
Line 66: Line 69:
 
*#the "# " states that the values in the column are not page links (otherwise the system would display the values in red, as non-existing pages), and
 
*#the "# " states that the values in the column are not page links (otherwise the system would display the values in red, as non-existing pages), and
 
*#the "= population (millions)" labels the header for this column.
 
*#the "= population (millions)" labels the header for this column.
*There are many different ways of formatting such a table, for example you can display numbers in many different formats, but additional extensions might be needed for some.
+
*There are many different ways of formatting such a table, for example you can display numbers in many different formats, but additional extensions might be needed for some. For more details on inline queries descriptions see '''[http://semantic-mediawiki.org/wiki/Help:Inline_queries SemanticMW Help:Inline_queries]'''.
  
 
===Concept usage===
 
===Concept usage===
  
 +
These pages can be viewed as «dynamic categories», i.e. as collections of pages that are not created manually, but that are computed by SMW from the description given by a query. A concept is a page in the Concept: namespace that is always described by a semantic query, as result of parser function <nowiki>#concept</nowiki>.
 +
It is possible to have other content on the concept page as well. Any normal wiki text can go before and after the use of <nowiki>#concept</nowiki> but it will not have any effect on the definition of the concept. The #concept parser function can only be used on pages in the Concept: namespace, and it can only be used once on each such page.
  
 +
For example, the page [http://biowikifarm.net/test/Concept:TestConcept Concept:TestConcept] has been created as:
  
===Using inverse properties===
+
<pre>{{#concept:
 +
[[Category:Metadata Sources]] [[Type:: Collection || StillImage || Sound || TaxonPage || IdentificationTool || Map]]
 +
| This is a first test for Concepts.
 +
}}</pre>
 +
 
 +
Concept pages as such can be browsed to view the contents of some concept, similar to category pages. But they can also be used in other semantic queries just like categories. For example, the following query would show all pages in the above concept:
 +
 
 +
<pre>{{#ask:
 +
[[Concept:TestConcept]] [[Type::StillImage]]
 +
}}</pre>
 +
 
 +
===Using inverse properties for retrieving data===
 
It is now possible to invert the direction of a page type property in queries and browsing interfaces. Simply write "-" in front of property names anywhere in SMW to refer to the inverse direction of a property, that is to the property that relates the same pages but with annotated page and annotation value exchanged. SMW does not support naming of inverses, but allows them to be used for retrieving data.  
 
It is now possible to invert the direction of a page type property in queries and browsing interfaces. Simply write "-" in front of property names anywhere in SMW to refer to the inverse direction of a property, that is to the property that relates the same pages but with annotated page and annotation value exchanged. SMW does not support naming of inverses, but allows them to be used for retrieving data.  
 
The following query return the name of the pages as values of property '''NamePage''', not equals with the current page <pre>
 
The following query return the name of the pages as values of property '''NamePage''', not equals with the current page <pre>
Line 78: Line 95:
 
</pre>
 
</pre>
 
The result shows all the pages as values of property '''NamePage'''.
 
The result shows all the pages as values of property '''NamePage'''.
 +
  
 
Simply inverse the property -NamePage in the above query, as in:
 
Simply inverse the property -NamePage in the above query, as in:
Line 87: Line 105:
 
==Installation==
 
==Installation==
 
For enabling the SemanticMW on another wiki of the biowikifarm follow the guidelines in the section for extensions: '''[[Semantic Mediawiki]]'''.
 
For enabling the SemanticMW on another wiki of the biowikifarm follow the guidelines in the section for extensions: '''[[Semantic Mediawiki]]'''.
 +
 +
==Comparing used vocabularies==
 +
 +
From [http://sandbox.semantic-mediawiki.org/wiki/Semantic_Web_Vocabulary?oldid=15133 Semantic Web Vocabulary on sandbox.semantic-mediawiki.org]:<br/> there are a number of tools and directions on the Semantic Web. And sometimes they seem to be conceptually equivalent modulo some details. But their vocabulary differs quite a lot. In this table some terms from different communities and / or tools are compared, so that a simple mapping and introduction can be achieved.
 +
 +
{|  border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! [http://www.w3.org/RDF/ RDF] !! [[OWL DL]]      !! [[DL]]              !! [http://semantic-mediawiki.org Semantic MediaWiki] !! [[Freebase]] !! [http://let.sysops.be/wiki/Living_ontology LO]
 +
|-
 +
| model || ontology    || TBox and ABox  || -                  || domain  || faction
 +
|-
 +
| class || class        || class, concept  || category          || type    || type
 +
|-
 +
| resource || individual  || individual, instance || article, page || topic  || noun
 +
|-
 +
| property || object property || role        || relation          || property || role
 +
|-
 +
| property || datatype property || concrete role || attribute          || property  || verb
 +
|}
 +
  
 
[[Category:Help]]
 
[[Category:Help]]
[[Category:Extensions]]
+
[[Category: MediaWiki Extensions]]
 +
[[Category:Semantic Mediawiki]]

Latest revision as of 21:25, 13 November 2017

Help sections
Contents · Semantic MediaWiki · Semantic Forms
Add Ontology · Semantic links and import/export features · Import external vocabulary
Other SemanticMW extensions · Other extensions



This section gives some guidance on, and provides some examples for the use the Semantic MediaWiki extension. For more detailed descriptions see the SemanticMW website.

Introduction

The Semantic MediaWiki (SemanticMW) extension is useful if you want to summarize and compare information which is located in different wiki pages. The page Countries gives an example of how information on different countries can be combined in a table. This has 2 advantages:

  • In the table you can sort the countries, e.g. by their population size or by the height of their highest mountain.
  • If the information in the source page changes (e.g. the figure for the total population in a given country is adjusted) then the table updates itself automatically.

The Semantic MediaWiki extension is well advanced and provides many different ways of formatting and retrieving the data. We can only give a few examples here.

Defining categories

Categories have been introduced by MediaWiki and represent the former way meant to structure wiki articles. One article might belong to many categories. The present article belongs to:

[[Category:Help]]
[[Category: MediaWiki Extensions]]

Defining subcategories

MediaWiki supports a hierarchy of categories that helps to simplify the category statements needed on each page. To indicate that one category is more specific than another, MediaWiki supports a category hierarchy where users can state that one category is a subcategory of another, simply by putting a category on the subcategory's page, e.g. the page Category:Metadata Sources could contain the text:

Category for media using [[Template:Metadata|template metadata]].
[[Category:Images]]

So named «semantic drift» occurs if the exact intention of some category is not really specified, e.g. because it lacks a detailed description on its page. Different users then may have slightly different readings of the categories meaning, and this may influence how they use sub-category statements. It is therefore important to always clearly describe on a category page what should go into a category and what shouldn't, and also to point to alternative catgegories that may be suitable.


Defining properties and data types

SemanticMW works with "properties". These define the type of information you want to collect and compare. For example, by creating the page Property:Population SemanticMW knows that "population" is a clearly defined information unit for a country (which could have been also named "number of inhabitants" or something else). In this case it is also important to assign the Type:Number to the "population" property. Otherwise data entered for this property would be regarded as plain text and we might get a sorting order like 179, 2499, 280, 4808, and 560.

Defining sub-properties

Sub-property feature allows inference. For defining sub-properties, its' necessary only to add in the property page the specification for sub-property, i.e., for the Property:Any Keyword:

This is a property of type [[Has type::String]].
[[subproperty of::Property:Text Search]]

These can be organized hierarchically, so one property could be defined as sub-property of a property and the latter could be defined as a sub-property of another property and so on. For example: The properties Property:General Keyword, Property:Scientific Name and others are defined as [[subproperty of::Property:Any Keyword]]. Like already seen before, the last one is [[subproperty of::Property:Text Search]]. Once this has been stated, a query (see Inline queries usage below) for [[Any Keyword::Galium odoratum]] will also return the [[Scientific Name::Galium odoratum]] even if no «Any Keyword» property is given on that page. The same is true for a query [[Text Search::Galium odoratum]]. Similar considerations as in the case of categories apply, and detailed descriptions on property pages are a good method for avoiding semantic drift.

Entering data

Data are assigned to each property by using the format:
 [[Capital::Vienna| ]]
 [[Area::83.9| ]]
 [[Population::8.3| ]]

Note the 2 colons. In the above format the data assignment in the page "Austria" does not produce any text in the page. However, you can also combine the data assignment with the text displayed by using the format [[Capital::Vienna]]



Calling up the data

In Semantic MediaWiki, retrieving the data is possible in two formats and using two different parser functions, as follows:

    1. inline queries which can be used in any wiki page, regardless of categories or namespaces. For expressing inline queries, #ask parser function is used. Into an article page, any number of inline queries might exists.
    2. concepts which represent a so called "dynamic categories" through use of #concept parser function usage. A concept is a page in the Concept: namespace that is always described by a semantic query.

Inline queries usage

For retrieving or querying the data like in the page Countries use the format:
 {{#ask: [[Category:Countries| country]] 
 | ?Capital# = capital
 | ?Area# = land area (1000 km²)
 | ?Population# = population (millions)
 | ?Highest mountain# = highest mountain
 | ?Highest mountain height# = height (m above SL)
 }}

Note that:

  • In the 1st line the statement "| country" makes a header for the first column.
  • On the 4th line the statement "| ?Population# = population (millions)" does 3 things:
    1. it retrieves all data assigned to the property "population" in a separate column,
    2. the "# " states that the values in the column are not page links (otherwise the system would display the values in red, as non-existing pages), and
    3. the "= population (millions)" labels the header for this column.
  • There are many different ways of formatting such a table, for example you can display numbers in many different formats, but additional extensions might be needed for some. For more details on inline queries descriptions see SemanticMW Help:Inline_queries.

Concept usage

These pages can be viewed as «dynamic categories», i.e. as collections of pages that are not created manually, but that are computed by SMW from the description given by a query. A concept is a page in the Concept: namespace that is always described by a semantic query, as result of parser function #concept. It is possible to have other content on the concept page as well. Any normal wiki text can go before and after the use of #concept but it will not have any effect on the definition of the concept. The #concept parser function can only be used on pages in the Concept: namespace, and it can only be used once on each such page.

For example, the page Concept:TestConcept has been created as:

{{#concept: 
 [[Category:Metadata Sources]] [[Type:: Collection || StillImage || Sound || TaxonPage || IdentificationTool || Map]]
 | This is a first test for Concepts.
 }}

Concept pages as such can be browsed to view the contents of some concept, similar to category pages. But they can also be used in other semantic queries just like categories. For example, the following query would show all pages in the above concept:

{{#ask:
 [[Concept:TestConcept]] [[Type::StillImage]]
 }}

Using inverse properties for retrieving data

It is now possible to invert the direction of a page type property in queries and browsing interfaces. Simply write "-" in front of property names anywhere in SMW to refer to the inverse direction of a property, that is to the property that relates the same pages but with annotated page and annotation value exchanged. SMW does not support naming of inverses, but allows them to be used for retrieving data.

The following query return the name of the pages as values of property NamePage, not equals with the current page
 {{#ask: [[NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage =  }} 

The result shows all the pages as values of property NamePage.


Simply inverse the property -NamePage in the above query, as in:

{{#ask: [[-NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage =  }}

The result shows all the pages refered by the values of property NamePage.

Installation

For enabling the SemanticMW on another wiki of the biowikifarm follow the guidelines in the section for extensions: Semantic Mediawiki.

Comparing used vocabularies

From Semantic Web Vocabulary on sandbox.semantic-mediawiki.org:
there are a number of tools and directions on the Semantic Web. And sometimes they seem to be conceptually equivalent modulo some details. But their vocabulary differs quite a lot. In this table some terms from different communities and / or tools are compared, so that a simple mapping and introduction can be achieved.

RDF OWL DL DL Semantic MediaWiki Freebase LO
model ontology TBox and ABox - domain faction
class class class, concept category type type
resource individual individual, instance article, page topic noun
property object property role relation property role
property datatype property concrete role attribute property verb