Help:In-text annotation

From semantic-mediawiki.org
(Redirected from Help:In-text annotation)
Help:In-text annotationAnotaciones en linea
Table of Contents
Beware that according to 1, in future versions of MediaWiki (with Parsoid), this method might be deprecated!
Figure 1:

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

[[Germany]]

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 special page "Properties"Lists properties and displays their usage. 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 MediaWiki configuration settings (e.g. configuration parameter $wgCapitalLinks) and if changed arbitrarily may cause content to be rendered invalid or unavailable during query execution.

Turning links into properties[edit]

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 all use a space as the alternate text.

The space after “|” is necessary. If the space is omitted, the MediaWiki pipe trick applies, but rarely with desirable effects. If the space is present, SMW will not print anything (the desired result in most cases). To make a space appear in the text, use   as a space symbol).
→ Consider using annotations with #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.0Released on 29 October 2015 and compatible with MW 1.19.0 - 1.25.x. it is possible to have property values which include a :: without creating an extra property (see just below), e.g.
The IPv6 address is fc00:123:8000::/%6.2
The IPv6 address is [[IPv6 address::fc00:123:8000::/%6]].

Square brackets “[“, wiki links “[[...]]”, double colons “::::” are not possible.3
→ 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]].

As of Semantic MediaWiki 2.3.0Released on 29 October 2015 and compatible with MW 1.19.0 - 1.25.x. it requires a disabled strict mode setting.4)
→ Consider using annotations with #set instead.

Turning values in text into properties[edit]

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

3,396,990 

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 article on Property declarations for more information.

Content classification[edit]

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[edit]

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:

{{#set:
 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

{{#set:
 Has text=fc00:123:8000::/%6
 |template=BySetTemplateSimpleValueOutput
}}
Result
fc00:123:8000::/%6

See also this help page for further information.

See also[edit]

References

  1. ^ gh:smw:4727 
  2. ^  Semantic MediaWiki: GitHub pull request gh:smw:1066
  3. ^  Semantic MediaWiki: GitHub issue gh:smw:893
  4. ^  Semantic MediaWiki: GitHub issue gh:smw:1252