Semantic MediaWiki
From WhyNotWiki
Contents |
[edit] About
http://meta.wikimedia.org/wiki/Semantic_MediaWiki
The WikiProject "Semantic MediaWiki" provides a common platform for discussing extensions of the MediaWiki software that allow for simple, machine-based processing of Wiki content. This usually requires some form of "semantic annotation," but the special Wiki environment and the multitude of envisaged applications impose a number of additional requirements.
The overall objective of the project is to develop a single solution for semantic annotation that fits the needs of most Wikimedia projects and still meets the Wiki-specific requirements of usability and performance. It is understood that ad hoc implementations (i.e. "hacks") may sometimes solve single problems, but agreeing on common editing syntax, underlying technology, exchange formats, etc. bears huge advantages for all participants.
SMW allows users to add structured data to wiki pages through simple wikitext markup that identifies relations between pages and attribute values of pages. With this information, SMW can help to search, organise, browse, evaluate, and share the wiki's content.
Understanding Nothing. Annotating Links (http://nothing.tmtm.com/archives/2579).
The basic principle is extremely simple. Rather than just creating a normal wiki link from one article to another, you annotate that link with information what sort of relationship it represents. This is similar to XFN, and other microformats, except they live in wikitext rather than HTML. Being a wiki, however, they don’t need to be predefined anywhere - the first time you create such a relationship it springs into being as a new “blank” relationship that you can describe or define further.So, for example, on Nigov we store minutes from Belfast City Council meetings. One of the advantages of having them in a wiki, over the official Word documents, is the linking. The list of councillors who are in attendance can be linked to each of their individual pages. When minutes of previous meetings are approved, they can be linked to. With Semantic Mediawiki we can go even further. In a normal wiki there is no distinction between the link to a councillor who is in attendance, and the link to one who sent apologies. Now, however, we can annotate the links to differentiate between them. On the text of the wiki page for the minutes there is no obvious difference (other than the summary box at the bottom that shows all the semantic information known), but we now have two extra benefits.
Firstly, every page is now addressable as RDF. These can then be fed into a reasoner, or picked up by a semantic search engine. We’re in the early days of the semantic web so this isn’t really as useful yet as it will be in a few years time. But even now there’s still a major benefit: the internal query facility. As well as a built in “Simple Semantic Search”, you can also dynamically include the results of queries into other pages.
So, by annotating each councillor with links like: “Belfast City Council”, we can now auto-generate the list of all councillors. Of course, we were always able to do this if we added them to a Category, but if we extend this with “Pottinger”. and “DUP”, we can pull that data into our resulting table as well.
Thus, our list of councillors page, rather than having to be maintained by hand, is as simple as just “ask”ing:
<ask format=”table”> [[Is councillor for::Belfast City Council]] [[electoral area:=*]] [[party member of::*]] </ask>Most of the data in the Nigov wiki still needs to be annotated like this before we’ll be able to generate the interesting reports (how often do councillors attend meetings vs send apologies?), and we probably won’t be able to ask the really interesting questions (”have any councillors attended a meeting that allocated funds to an organisation they’re involved in where they didn’t declare a conflict of interest?”) until there’s a proper reasoning engine underneath, rather than the current SQL model.
But for a little extra work when adding links to a page, we get a pretty good payoff now as well as the potential of even more later without having to do any additional work then. Seems like a good deal to me.
[edit] Documentation / How to use
http://ontoworld.org/wiki/Help:Semantics "Complete software documentation"
[edit] Sandbox
Semantic MediaWiki / Sandbox edit
[edit] Examples
http://ontoworld.org/wiki/Category:Actor
[[category:person]] [[has subclass:category:female actor| ]] [[Category added by template::template:actor| ]] See also: *[[:Category:Film]] *[[:Category:Film character]] <ask link=all>[[Category:Actor]][[date of birth:=*]][[played in::*]][[played::*]]</ask>
http://ontoworld.org/wiki/People
The following list is cached for better performance. If it appears to be out of date, you can refresh it by clicking the link at the bottom of this page. You can also directly browse the <ask limit="0" searchlabel="current list of people">[[:+||User:+]] [[Category:Person]] [[affiliation::*|Affiliation]]</ask>. <ask limit="1000" link="all">[[:+||User:+]] [[Category:Person]] [[affiliation::*|Affiliation]]</ask>
http://ontoworld.org/wiki/Tyler_Rick
http://ontoworld.org/wiki/Help:Editing
http://ontoworld.org/wiki/Template:Person
http://ontoworld.org/wiki/FOAF
[edit] Annotations
http://ontoworld.org/wiki/Help:Annotation
This page explains the basic annotation features for Semantic MediaWiki. Annotations are special markup-elements which allow editors to make some parts of the wiki's content explicit so that software tools can use them to assist the users. In particular, semantic annotations provide the basis for more powerful search functions within the wiki. They also allow changes in data on one page to automatically propagate to other pages containing the same data (somewhat comparable with what can be done with templates). Users who are not familiar with the basics of editing MediaWiki should read Help:Editing first.Annotations in Semantic MediaWiki can be viewed as an extension of the existing system of categories in MediaWiki. Categories are a means to classify articles according to certain criteria. For example, by adding to an article, the page is tagged as describing a city. Software tools can use this information to generate an ordered list of all cities in a wiki, and thus help users to browse the information.
Semantic MediaWiki provides further means of structuring the wiki:
- Relations basically are "categories for links." They describe the meaning of hyperlinks between articles. For example, the link from the article Berlin to the article Germany describes the relationship of being the capital of some country.
- Attributes describe the meaning of data values in articles. For example, the text 3,396,990 in the article Berlin describes its population.
[edit] Attributes
http://ontoworld.org/wiki/Attribute:Date_of_birth
Attribute implying attribute Attribute:Birthday +
Attribute implying relation Relation:Born in year +
Related Attribute:Age +
Special properties
Has type Type:Date
My name is [[foaf:firstName:=Tyler]] [[foaf:surname:=Rick]].
http://ontoworld.org/index.php?title=Template:Born&action=edit
[[born in year::{{{1}}}| ]]
[[birthday:={{{{{subst|}}}monthabbrev|{{{2}}}|subst={{{subst|}}}}} {{{3}}}| ]]
[[date of birth:={{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}-{{padleft:{{{3}}}|2|0}}| ]]
[[date of birth sortkey:={{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}-{{padleft:{{{3}}}|2|0}}| ]]
[[has age::{{age|{{{1}}}|{{{2}}}|{{{3}}}}}| ]]
[[age:={{age|{{{1}}}|{{{2}}}|{{{3}}}}} years| ]]
http://ontoworld.org/wiki/Attribute:Weekday_number
[edit] Types
http://wiki.ontoworld.org/wiki/Relation:Has_type
http://www.ontoworld.org/wiki/Help:Annotation.
The first is achieved by writing in the article on Berlin the text[[population:=3,396,990]]The only difference to a relation is that we write ":=" instead of "::" as before. The number 3,396,990 now appears as normal text and no link is created. The label "population" again is our free choice. We could have used any other text as well. As in the case of relations, our attribute "population" gets an own article where we can add descriptions for other users. The article name starts with "Attribute:", i.e. the article is called "Attribute:Population" in our case.
We still have to say that "population" is a number. Semantic MediaWiki knows a number of different datatypes that we can choose for attributes. In our case, the type is called Type:Integer. The prefix "Type:" is again a separate namespace that distinguishes descriptive articles about types from normal pages. What we want to say is that the attribute population has the type integer, i.e. that the two things have a special relation. As with all relations, this is stated in the population's article Attribute:population. There, we write
[[has type::Type:integer]]to say that the special relation "has type" holds between Attribute:population and Type:integer. Semantic MediaWiki knows a number of special relations like Relation:has type. Regardless of whether these relations have their own articles in the wiki, they have a special built-in meaning and are not evaluated like other relations.
...
Using different types, attributes can be used to describe very different properties. A complete list of available types is available from Special:Types. Basic types include:
- Type:String (text strings)
- Type:Integer (whole numbers)
- Type:Float (decimal numbers with optional exponent)
These can be used creatively for very different purposes. For instance, attributes of type string can be used for encoding phone numbers (which in fact can contain non-numeric symbols).
...
- Type:Enumeration (new in SMW 0.7) is like Type:String but restricts the value of an attribute to a limited set of values.
- Type:Temperature can't be user-defined since converting temperature units is more complicated than multiplying by a conversion factor.
- Type:Geographic coordinate describes geographic locations. It includes functions for recognizing different forms of geographic coordinates, and it dynamically provides links to online map services.
- Type:Date specifies particular points in time. This type is still somewhat experimental, but may feature complex conversions between (historic) calendar models in the future.
For specifying URLs and emails, there are some special variations of the string type:
- Type:URL and Type:URI both just seem to work like Type:String. (In SMW 0.6, when a value of this type is produced in a query it does not work as a link.)
- Type:Annotation URI: attributes of this type are interpreted as relations to external objects, denoted by the URI. They are special since they are interpreted as annotation properties on export. See the type page for documentation. (Again, in SMW 0.6 when a value of this type is produced in a query it does not work as a link.)
- Type:Email stores emails as a string datavalue, but automatically links them (with mailto:) within the page.
[edit] Relations
Example:
http://ontoworld.org/wiki/Relation:Category_added_by_template
http://ontoworld.org/wiki/Category:Actor
[[Category added by template::template:actor| ]]
[[is a::foaf:Person]] [[works at::___]].
http://ontoworld.org/wiki/Relation:Is_a
The relation "is a" is deprecated. Use a category, or use some relation or attribute that replaces several categories, e.g. Relation:Released in year instead of Category:Released in 2006 etc. (Relation:Subclass of or Relation:Instance of may also not be a good choice).
[edit] [Limitations (category)]
Your relations can apparently only be between objects in your wiki...
So you can't have a relation to:
- an external object/URL/URI, like this:
[[Based on:: http://wiki.videolan.org/List_of_templates]]
- plain text that isn't an object/article in your wiki:
[[Based on:: my vast experience in this area]]
You can [work around (category)] this limitation some of the time by using inter-wiki links:
[[Based on:: w:List_of_templates]] (where w: is the inter-wiki prefix for Wikipedia)
but that requires setting up an inter-wiki prefix for every external site you intend to link to!
[edit] Queries / Searching
Special:Ask (one-time queries) or inline queries
http://ontoworld.org/wiki/Help:Browsing_and_searching
http://ontoworld.org/wiki/Help:SearchTriple
http://ontoworld.org/wiki/Help:Selection
http://ontoworld.org/wiki/Help:Semantic_search
The syntax for asking for pages that satisfy some condition is exactly the syntax for explicitly asserting that this condition holds.The following queries show what this means: 1. gives all pages directly or indirectly (through a sub-, subsub-, etc. category) in the category. 2. Boston gives all pages annotated as being about someone born in Boston. 3. 180cm gives all pages annotated as being about someone having a height of 180cm.
It's easy to say that thing A depends on thing B, and this relation will show up on article A. But how do you cause this relation to be displayed on article B as well? In other words, how do we make the relation appear to be bi-directional? It looks like we can do queries like this (put this on page B):
<ask>[[Depends on:: {{PAGENAME}}]] [[Depends on::*]]</ask>
http://ontoworld.org/wiki/Help:Ask
<ask>[[Category:Country]] [[located in::Africa]] [[Population:=*]]</ask>
http://ontoworld.org/wiki/Attribute:Weekday_number
<ask link="all" limit="1000">
[[{{PAGENAME}}::+]] [[{{PAGENAME}}::*]]</ask>
<ask sort="weekday number" link="all" limit="1000">
[[{{PAGENAME}}:=+]] [[{{PAGENAME}}:=*]]</ask>
<ask>weekday number:=3</ask> gives <ask>weekday number:=3</ask>
[edit] Using queries in templates
http://ontoworld.org/wiki/Template:Ask [1] (deprecated)
[edit] Use cases / Reasons to use
http://ontoworld.org/wiki/Semantic_MediaWiki
Semantic MediaWiki introduces some additional markup into the wiki-text which allows users to add "semantic annotations" to the wiki. While this first appears to make things more complex, it can also greatly simplify the structure of the wiki, help users to find more information in less time, and improve the overall quality and consistency of the wiki. To illustrate this, we provide some examples from the daily business of Wikipedia:1. Manually generated lists. Wikipedia is full of manually edited listings such as this one. Those lists are prone to errors, since they have to be updated manually. Furthermore, the number of potentially interesting lists is huge, and it is impossible to provide all of them in acceptable quality. In SMW, lists are generated automatically like this. They are always up-to-date and can easily be customized to obtain further information.
2. Searching information. Much of Wikipedia's knowledge is hopelessly buried within millions of pages of text, and can hardly be retrieved at all. For example, at the time of this writing, there is no list of female physicists in Wikipedia. When trying to find all women of this profession that are featured in Wikipedia, one has to resort to textual search. Obviously, this attempt is doomed to fail miserably. Note that among the 20 first results, only 5 are about people at all, and that Marie Curie is not contained in the whole result set (since "female" does not appear on her page). Again, querying in SMW easily solves this problem (in this case even without further annotation, since existing categories suffice to find the results).
3. Inflationary use of categories. The need for better structuring becomes apparent by the enormous use of categories in Wikipedia. While this is generally helpful, it has also led to a number of categories that would be mere query results in SMW. For some examples consider the categories Rivers in Buckinghamshire, Asteroids named for people, and 1620s deaths, all of which could easily be replaced by simple queries that use just a handful of annotations. Indeed, in this example Category:Rivers, Relation:located in, Category:Asteroids, Category:People, Relation:named after, and Attribute:date of death would suffice to create thousands of similar listings on the fly, and to remove hundreds of Wikipedia categories.
4. Inter-language consistency. Most articles in Wikipedia are linked to according pages in different languages, and this can be done for SMW's semantic annotation as well. With this knowledge, you can ask for the population of Bejing that is given in Chinese Wikipedia without reading a single word of this language. This can be exploited to detect possible inconsistencies that can then be resolved by editors. For example, the population of Edinburgh at the time of this writing is different in English, German, and French Wikipedia.
5. External reuse. Some desktop tools today make use of Wikipedia's content, e.g. the media player Amarok displays articles about artists during playback. However, such reuse is limited to fetching some article for immediate reading. The progam cannot exploit the information (e.g. to find songs of artists that have worked for the same label), but can only show the text in some other context. SMW leverages a wiki's knowledge to be useable outside the context of its textual article. Since semantic data can be published under a free license, it could even be shipped with a software to save bandwidth and download time.
http://ontoworld.org/wiki/Semantic_Wiki_Use_Cases
Here are some very simple sample Use Cases of a semantic wiki:1. Duplication Avoidance A semantic wiki can 'know' about related concepts and help detect duplicate concepts
2. Integrity Checks A semantic wiki could use tags to check the consistency of structures. For example if you are a subclass of a more general concept and the parent is moved or is renamed, your page could be notified
3. Metadata Registry A Semantic Wiki can take the place of a ISO/IEC 11179 metadata registry. This would require some template development.
4. Synonym mapping Wiki pages could store mappings to other wikis or other ontologies using statements similar to the OWL sameAs property.
5. Structured Search Because a semantic wiki can add structured tags users can perform more complex searches. For example a user should be able to ask for all wiki pages about cities in California.
[edit] News
April 2007: Release of Semantic MediaWiki 0.7. Inline query templates, Enumeration type, Special:Browse page for knowledge exploring, informative listings on all pages in the namespaces Attribute, Relation, and Type. Get the code from SourceForge.
[edit] In use on
This is ontoworld.org, the wiki for the Semantic Web community. Our mission is to provide a knowledge repository and platform for advertising events, spreading news, and announcing new developments. It is a wiki: everybody can quickly edit its content, even without logging in. So look around and participate!
...
Ontoworld.org runs on Semantic MediaWiki and thus is a true semantic wiki not just with respect to its content. Semantic features are used in many places, such as on this very page: e.g. the lists of events and portals above are computed automatically from the contents of the wiki. In other places, semantic data serves as a basis to enable reuse in external tools. For example, the wiki employs the FOAF vocabulary in descriptions of people, and via RDF export this information can be evaluated in external tools. For more information, go to the Semantic MediaWiki portal page.
[edit] Installation
See MediaWiki / Installation of Semantic MediaWiki 0.7
http://ontoworld.org/wiki/Help:Installation
http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticMediaWiki/INSTALL
Depends on mbstring
"mb_strpos cannot be found."
http://ontoworld.org/wiki/Help_talk:Inline_queries
Everything works find but as soon as i use a * in ask queries and safe the page the article is not loaded and shows a blank page instead. This is of course extremely annoying as all advanced useful queries need that sign.http://us2.php.net/manual/en/ref.mbstring.php PHP: Multibyte String Functions - Manual
You can also try just removing the mb_ prefix from all function calls...
(wikidir/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php)
Semantic MediaWiki edit (Category edit)
| Born in | Boston + |
| Is councillor for | Belfast City Council + |
| Party member of | DUP + |
| Electoral area | [Oops! No type defined for attribute] |
| Height | [Oops! No type defined for attribute] |
