Semantic MediaWiki is an extension for which MediaWiki is worth putting: it helps to deal with the mess and chaos that sooner or later reigns in any wiki system.
- It allows you to maintain consistency of data on the wiki.
- It can be used to treat a wiki as a database.
- With it, you can generate beautiful graphs, charts and graphs based on wiki data.
- It allows users to enter data using forms rather than wiki markup, thereby lowering the entry threshold for users.
SMW allows you to use a wiki as part of a knowledge management system, you can use it to create commercial systems that combine the simplicity of a wiki, the clarity of collaborative databases, and the best of the world of the Semantic Web. In general, this thing is more than worthy of close attention and detailed review.
Pro semantic wiki
There are quite a few
semantic wiki engines . Many of them were created by scientists from Europe at a time when the use of the word "semantic" guaranteed subsidies, grants, contracts with large companies, each of which tried to be more semantic than the others, and published in reputable journals. And these engines lived from grant to grant, and as soon as the development money ended, the repositories immediately overgrown with heather and horsetail, and only the groans of random users broke the silence of their bug trackers. As far as I know, only
Semantic MediaWiki ,
OntoWiki and
Information Workbench avoided this fate, all thanks to the established user community and participation in the development of commercial companies.
Semantic wikis allow you to add pieces of structured information to wiki pages, and then make it possible to work with this information: build queries, display data in the form of various visualizations, and even make logical inference (reasoning, inference). Specifically, Semantic MediaWiki (SMW) uses a mechanism similar to tagging for linking text on a page with structured data, and introduces a special language for queries that will not be difficult to master the media viicoid.
')
Categories, properties and queries
SMW is based on the concept of
semantic properties (for creating data) and
semantic queries (for using data). Users annotate (tag) articles with categories and properties so that information becomes available for requests. Consider an example: take a travel wiki: it will describe some of the cities with their sights and restaurants. The pages of this wiki, connected by hyperlinks, are depicted like this:

Categories
Using the
categories of MediaWiki , we can combine articles from our example into several sets. Categories can be nested within each other, forming hierarchies. In order to relate the page to a specific category, we add the following code to the text of the article:
[[:_]]
For example, in our wiki, you can select objects related to the categories
, , , ,
.


Categories are the basic mechanism for structuring content in MediaWiki. After installing SMW, you can make dynamic selections by category, for example, display all restaurants, which are also landmarks. Such selections are made using
#ask-
. Just paste the following code anywhere in any wiki article:
Request
| Result
|
---|
: {{#ask: [[:]] [[:]] }}.
| Some restaurants may be interesting for tourists and like sights: Le Chateaubriand, Curry 36.
|
Properties
Internal links in any wiki are very simple, for example, in MediaWiki, double square brackets are used for this:
[[1]], [[2]]
. The problem with references is that they carry extremely scarce information: one object is associated with another object, that's all. SMW allows you to name links. The link between the restaurant and the city in which it is located will be called "
", and the link from the restaurant’s page to the description of the kitchen that is served in it is good to call it "
". In SMW terminology, such named links are called
page.
Edit the article on the restaurant Le Chateaubriand from our example and add the following text
Wiki markup
| Result
|
---|
Le Chateaubriand [[ :: | ]]. , , [[:: | ]].
| Restaurant Le Chateaubriand is located in the heart of Paris . The cuisine is, of course, French .
|
The general formula for setting properties in Semantic MediaWiki is as follows:
[[ :: | ]]
Let's look at our link graph. If we use the properties for our articles among themselves, then the picture takes the following form:

Requests
Now the links are distinguishable, which means we can form quite interesting samples. For example, let's select all the restaurants that are located in Paris. SMW uses
# ask queries for this , and they look something like this:
Request
| Result
|
---|
: {{#ask: [[:]] [[ ::]] }}
| : Bistrotters, Pizza Rossi, Le Chateaubriand.
|
Please note that the search terms in the query are written in the same way as the corresponding properties were set in the wiki article text. Technically, the query is implemented as
a parser function , and a slightly unpleasant syntax is inherited from MediaWiki:
{{# :1|2|3}}
Everything related to the selection of pages are recorded in the first parameter of the function.
Types of properties
The “
” property points to a wiki page, in other words, this is a “
" type property. There are other types in SMW. For example, the
type will be useful to us when we indicate the time of occurrence of a particular landmark, the
used to mark up geo-information. Of course, the “
" type is also available to us, it is useful when specifying the population of cities and the average daily number of scuffles in restaurants. Update our picture by adding two properties of cities there:
and
.

You can write a few queries related to cities. Through a straight line, add a couple more parameters:
Request
| Result
|
---|
, {{#ask: [[:]] [[::<20000]] | limit=4 }}.
| We have small cities, for example Tuusniemi, Kaluga, Veeze, Vinci.
|
, {{#ask: [[:]] [[::>20000]] [[::<1000000]] | limit=4 | format=ol }}
| We have medium cities, for example
- Vancouver
- Amsterdam
- Nuremberg
- Cambridge
|
-, : {{#ask: [[:]] [[::>1000000]] [[ ::<1.01.1513]] | format=ul }}
| And here is our list of millionaire cities, over five hundred years old:
|
Here is another example - simple pattern-matching:
: {{#ask: [[:]] [[::]] [[::~-*]] }}
Page info
Sometimes we are interested not so much in the names of the pages that meet the conditions of the requests, as in the information presented on these pages. In other words, we would like to know the meanings of some semantic properties of these pages. You can use
printouts (printout statements, I will be happy with the translation options): after the request body, list the properties of interest to us, preceding them with a question mark:
{{#ask: [[:]] | ? | ? |? }}
This will give us a nice table of the following form:
| Number of seats | Time of creation | Kitchen |
---|
Le Chateaubriand | 100 | 1792 | French |
Curry 36 | 50 | 1955 | International |
Pir.O.G.I | 60 | 2001 | International |
With printouts you can make many different interesting things, for example, taking into account the units of measurement, converting inches to centimeters, and liters to gallons, on the go. In our example, each printout is displayed as a separate column, but the result of the query can be not only a table ...
Output formats
Data - they are data, and how to display them to the user - you decide. By default, SMW displays data in the form of tables and lists, but you have a few dozen other
output formats in your arsenal. Thus, numerical data can be represented by
graphs and
diagrams .

Data type "Date" can be displayed in the form of
calendars and
timelines :


Geodata can be displayed as
maps , and in tooltips to show the values ​​of properties. Moreover, it is possible to semantically mark not only points, but also polygons:


Some output formats are interactive, for example,
filtered
allows users to
filter results by semantic property values.

There are many more formats, and it's not so difficult to write your own.
Next
Who would want to force their users to learn extra wiki markup, no matter how simple it is? Fortunately, this is not necessary, and it is quite possible to get all the buns of the semantic wiki so that users don't even know that something has changed in the wiki configuration. For this purpose, semantic patterns and semantic forms are used. Perhaps we will tell about them in the next article.
Links
Russian documentation - I will be glad to help in translation
The SMW admin mailing list is very friendly. The community generally makes me very happy, we even organize conferences (I am waiting for everyone to Berlin).
SMW Programmers Mailing ListContest “Wiki of the Month” - there you can look at beautiful wikis using SMW
All pictures published under the license
CC-BY 3.0