Help:SemanticMW
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.
Contents
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:
- 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 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 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. For example: The property Property:General Keyword is defined as [[subproperty of::Property:Any Keyword]]. Like already has seen before, the last one is [[subproperty of::Property:Text Search]]. Once this has been stated, a query [[Any Keyword::Galium odoratum]] will also return the [[Scientific Name::Galium odoratum]] 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.
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.
Calling up the data
For retrieving or querying the data like in the Category: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:
- it retrieves all data assigned to the property "population" in a separate column,
- 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.
- 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.
Using inverse properties
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.