Difference between revisions of "Help:SemanticMW"
(→Calling up the data) |
|||
Line 35: | Line 35: | ||
*#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. | ||
+ | |||
+ | ===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 <pre> | ||
+ | {{#ask: [[NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage = }} | ||
+ | </pre> | ||
+ | The result is: | ||
+ | {{#ask: [[NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage = }} | ||
+ | Simply inverse the property -NamePage in the above query, as in: | ||
+ | <pre> | ||
+ | {{#ask: [[-NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage = }} | ||
+ | </pre> | ||
+ | The result is: | ||
+ | {{#ask: [[-NamePage::!{{PAGENAME}}| Pages of interest]] |?NamePage = }} | ||
==Installation== | ==Installation== |
Revision as of 09:56, 23 April 2010
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.
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 is:
Simply inverse the property -NamePage in the above query, as in:
{{#ask: [[-NamePage::!{{PAGENAME}}| Pages of interest]] | ?NamePage = }}
The result is:
Installation
For enabling the SemanticMW on another wiki of the biowikifarm follow the guidelines in the section for extensions: Semantic Mediawiki.