From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Implementation Hook
Description Render revision history of the Wiki in semantic forms.
Author(s) Jie Bao and Li Ding
Latest version 0.1 (2009-09-10)
MediaWiki 1.15
License MIT License
Download Zip File

Subversion [Help]

Browse source code
#Change Log
Example examples
Translate the SemanticHistory extension if it is available at translatewiki.net
Check usage and version matrix.

What This Extension Does[edit]

SemanticHistory is an extension to be used along with Semantic Mediawiki. It tracks revisions of a wiki and enables their translation into semantic forms so that they can be better queried and represented. The current version offers the follows functionalities:

  • Capturing edit revisions (editing, deletion, undeletion and moving) and representing them as SMW scripts (via additional templates)
  • Enabling parsing of editing summaries into SMW scripts.

How It Works[edit]


  1. A user (potentially a software agent) makes some edit actions to a wiki page. Typical edit actions include creating new pages, modifying a existing page, moving a page and deleting/undeleting a page.
  2. The Semantic History (SH) extension monitors user actions and captures various types of revision changes happened on the wiki. At this step, the SH extension will
    • Create a revision instance that contains basic context information of the revision, e.g., revision id, author, timestamp, page location and editing summary (in raw text). This revision instance will be stored as a special wiki page. For example, an editing revision with id 1234 may be stored as a page rev:1234, where rev: is a name space for all revision pages and can be protected according the wiki's access control policy.
    • Compare triple changes before and after the editing, identify all triple insertions and deletions during the process. Each triple is identified by a unique id and stored as a special wiki page along with its insertion and deletion history.
  3. The output of this step is a set of wiki pages (i.e., revision pages and triple pages), marked up using a set of templates (details given below).
  4. Generate triple representation for the revision history via a set of predefined templates. For example, the template SH_Triple will perform a reification of a triple into three triples, such as {{SH_Triple|s|p|o}} on a page triple:123 will generate :
      triple:123 subject s
      triple:123 predicate p
      triple:123 object o
    Other type of information, such as timestamp of a revision or an deletion revision associated with a triple, will be triplified in the similar fashion.
  5. Add the triplified revision history back to the triple store of the SMW by SH templates.
  6. Enable applications to query the SMW triple store about the semantic representation of the revision history for various purposes, e.g., statistics, visualization, temporal inference and explanation (please see the Demo section).

Templates and Customization[edit]


The following constants in "SemanticHistory_Setting.php" can be customized

  • NS_HISTORY: the numeric value of a namespace to store triple history (default 200)
  • PREFIX_HISTORY: the string prefix of the 'NS_HISTORY' namespace (default 'his')
  • NS_REVISION: the numeric value of a namespace to store revision actions (default 202)
  • PREFIX_REVISION: the string prefix of the 'NS_REVISION' namespace (default 'rev')

Template names and parameters[edit]

The following template names in "SemanticHistory_Setting.php" can be customized. Their parameters are predefined.

  • HISTORY_OBSOLETE: for "obsolete" flag of a triple (default 'SH_Obsolete'); Example
    • parameter 1: '1' or '0'
    • e.g. {{SH Obsolete|1}}
  • HISTORY_REV: for revision basic information (default 'SH_Rev'); Example
    • parameter 1: id
    • parameter 2: time
    • parameter 3: author
    • parameter 4: the page where the revision is made
    • parameter 5: category of the page (default 'Revision', could be 'Deletion', 'Undeletion', or 'Move')
    • e.g. {{SH Rev|1386|20090708165813|User:Baojie|Jie Bao}}
  • HISTORY_TRIPLE: for triple basic information (default 'SH_Triple'); Example
    • parameter 1: subject
    • parameter 2: predicate
    • parameter 3: object
    • e.g., {{SH Triple|RPI|Location|Troy, NY}}
  • HISTORY_ADD: for adding action of a triple (default 'SH_Add'); Example
    • parameter 1: revision id of this action
    • parameter 2: timestamp
    • parameter 3: author
    • e.g. {{SH Add|3305|20090713115342|User:Baojie}}
  • HISTORY_DELETE: for deletion action of a tripl (default 'SH_Delete'); Example
    • parameter 1: revision id of this action
    • parameter 2: timestamp
    • parameter 3: author
    • e.g. {{SH Delete|1372|20090708163740|User:Baojie}}
  • HISTORY_MINOR: for "minor" flag of a revision (default 'SH_Minor'); Example
    • no parameter
    • e.g. {{SH Minor}}
  • HISTORY_SUMMARY: for "summary" raw text of a revision (default 'SH_Summary'); Example
    • parameter 1: the raw text of the editing summary (with some special characters escaped)
    • e.g. {{SH Summary|this is a typo fix}}
  • HISTORY_TEMPLATE: for used templates information of a revision (default 'SH_UseTemplate'); Example
    • parameter 1: template name
    • parameter 2: revision of the template currently used
    • e.g. {{SH UseTemplate|Template:T1|2661}}
  • HISTORY_PROPERTIES: for property annotations that may be created on a revision (default 'SH_Properties'); Example
    • parameter 1: list of property names, separated by ';'
    • e.g. {{SH Properties|P1;P2}}
  • HISTORY_CATEGORIES: for category annotations that may be created on a revision(default 'SH_Categories'); Example
    • parameter 1: list of category names, separated by ';'
    • e.g. {{SH Categories |C1;C2}}

Configuration Flags[edit]

  • $wgSemanticHistoryAllowEdit = false : if common users can edit history and revision data
  • $wgSemanticHistoryAllowRead = false : if common users can read history and revision data
  • $wgSemanticHistoryAnalyzeTemplate = true: if to analyze the triple-template dependency (experimental)

Semantic Modeling Vocabulary[edit]

The SH set of template will take care of transforming history data into SMW scripts and finally into the SMW triple store. For example, the Template:SH Triple on our demo site uses "subject", "object" and "predicate" as property names to store a triple's basic information. Wiki admins may adopt their own property naming conventions by defining their own SH templates, or modifying the demonstration templates.

Parsing "semantic" summary[edit]

The template HISTORY_SUMMARY (default 'SH_Summary') can be used to parse a raw text summary into semantic forms. One example is to enable SMW-style of editing summary (example parser). For example :

reason::data is outdated; source::CIA World Factbook; category:Fact Update; Update GDP numbers to the 2008 data

It contains three semantic annotations similar to the SMW syntax, and one non-semantic sentence explaining the change. This may be parsed into SMW scripts:

[[reason::data is outdated]]
[[source::CIA World Factbook]]
[[category:Fact Update]]

The non-semantic text will not be parsed and stored in the original form. By semanticizing the editing summary, we will be able to do more powerful query over the revision data. For example, to ask revisions about a country that uses some information from an almanac (CIA World Factbook is one instance of it), we use the SMW query (based an ontology used on our demo site)


Other forms of parsers may also be used, e.g., a Twitter-style syntax: one may use “#” to add tag to a summary. For instance, a sentence

 fact update for 2008 #gdp #infobox change

maybe generate SMW annotations


Demo and Examples[edit]

A demo site is at: http://tw.rpi.edu/semhis

The demo site uses a set of other MediaWiki or SMW extensions, see [1] for details


Please use the following instructions to install this extension.

1. Install from SVN: you can copy the source code from SVN, and put them under "WIKI-PATH/extentions/SemanticHistory"

  • or if you have shell access, you can install using svn
 svn co http://smwbp.googlecode.com/svn/trunk/mediawiki/extensions/SemanticHistory/


1. Install from a zip file: you can download a zip file and unzip it to the "WIKI-PATH/extentions/SemanticHistory" folder.

2. Append the following to LocalSettings.php (near the bottom) of your MediaWiki installation:

require_once ("$IP/extensions/SemanticHistory/SemanticHistory.php");

3. (optional) edit the "WIKI-PATH/extentions/SemanticHistory/SemanticHistory_Setting.php" file to customize naming conventions, name spaces, and access policies.

4. (optional) Download a predefined set of templates used by the SH extension from [2], put "Category:SH_Templates" in the "Add pages from category" box, and save the generated file. To import those templates, go to your wiki's "Special:Import" page, and upload the file.

  • Note: you may need additional extensions to use these templates, including ArrayExtension, LoopFunctions, ParserFunctions, RegexFunctions, StringFunctions, and Variables. Please check [3] for their information.
  • Note: you can define your own set of templates instead.

Change Log[edit]

the latest SemanticHistory has been tested on MediaWiki versions 1.15 and Semantic MediaWiki version 1.4.2. It may work with some earlier versions of MW.


  • Sept 10, 2009 version 0.1 -first release