Help:In-text annotation

Jump to: navigation, search
Table of Contents
Figure 1: Semantic MediaWiki statement (property-value pair)

Consider the Wikipedia article on Berlin. This article contains many links to other articles, such as «Germany», «European Union», and «United States». However, the link to «Germany» has a special meaning: it was put there since Berlin is the capital of Germany. To make this knowledge available to computer programs, one would like to «tag» the link


in the article text, identifying it as a link that describes a «capital property». With Semantic MediaWiki, this is done by putting a property name and :: in front of the link inside the brackets, thus:

[[Is capital of::Germany]]

In the article, this text still is displayed as a simple hyperlink to «Germany». The additional text Is capital of is the name of the property that classifies the link to Germany. As in the case of categories, the name of the property is arbitrary, but users should try to re-use properties that already appear elsewhere.

To simplify this re-use, every property has its own article in the wiki, just as every category has an article. You can see all the properties in use in the wiki with the special page "Properties". Just as category articles are prefixed with Category:, all property articles are prefixed with Property: to distinguish them from other articles. So you can also also use MediaWiki's special page "Search" to find existing properties. As with categories, a property's article can be empty, but it is strongly recommended to add a description that explains the intent of the property and its proper usage.

In-text annotations and property declarations are case-sensitive and therefore adhere certain environmental MediaWiki settings (e.g. $wgCapitalLinks) and if changed arbitrarily may cause content to be rendered invalid or unavailable during query execution.

Turning links into properties

There are various ways of adding properties to pages:

What it does What you type What is to note
Classify a link with the property "example property."
Classify a [[Example property::link]] with the property "example property."
Make alternate text appear in place of the link.
Make [[Example property::link|alternate text]] appear in place of the link.
To hide the property from appearing at all, use a space as the alternate text.
To hide the property [[Example property::link| ]] from appearing at alluse a space as the alternate text.
  • The space after | is necessary. If left away, the MediaWiki pipe trick applies, but rarely with desirable effects. Even if a space is given, SMW will not print anything, which should be the desired result in most cases (to make a space appear in the text, use   as a space symbol).
→ Consider doing silent annotations using #set instead.
To make an ordinary link with :: without creating a property, escape the markup with a colon in front, e.g.
The C++ :: operator.
The [[:C++ :: operator]].
Since Semantic MediaWiki 2.3.0 is is possible to have property values which include a :: without creating a extra property (see just below), e.g.
The IPv6 address is fc00:123:8000::/%6.1
The IPv6 address is [[IPv6 address::fc00:123:8000::/%6]].
  • Square brackets “[“, wiki links “[[...]]”, double colons “::::” are not possible.2
→ Consider using annotations with #set instead.
To assign one value to multiple properties, add :: between each name, e.g. link.
e.g. [[Property1::Property2::link]].
→ Consider using annotations with #set instead.

Turning values in text into properties

There is other useful information in wiki articles besides links to other articles. For example, there is a number in the Berlin article giving its population. To make this knowledge available to computer programs, one would like to "tag" the text


in the article, identifying it as a value for the "Has population" property. With Semantic MediaWiki, this is done by putting the property name and :: in front of the text and surrounding it with [[ ]] brackets, thus:

[[Has population::3,396,990]]

This works fine. However, it creates a link to a 3,396,990 page, and having an article for every population value probably does not make sense. Furthermore, if you wanted to create a list of all German cities ordered by population, numeric order is different from the alphabetical order that you would expect for article names. For example, in alphabetical order, "1,000,000" comes before "345". We want to be able to tell Semantic MediaWiki that "Has population" is a number, not a link to a page in the wiki. The way to do this is to specify a type for the "Has population" property; see the section on datatypes for more information.

Content classification

The following help page on data classification describes some principles on how to use categories and properties to classify and distinguish content from another.

Silent annotations using #set

See Help:Setting values using #set for more detailed information

Instead of using the standard double-brackets markup, you can also define semantic data using the #set parser function. This function takes in pairs of property names and values and stores them semantically; but it does not print anything to the screen. An example call would be:

 Has population=3,396,990
 |Has country=Germany

The #set call is specifically helpful when trying to save a Text value that contains square brackets, such as wiki-links; such brackets often don't work with conventional Semantic MediaWiki markup.

If the parser strict mode is disabled (note: default is enabled) then extra colons can cause unexpected pattern matching which should be mitigated by using the #set parser function instead.

For example

[[Has text::fc00:123:8000::/%6]]

can be expressed by

 Has text=fc00:123:8000::/%6

See also this help page for further information.

See also