Extension:SemanticHistory

What This Extension Does
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



 * 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
 * 3) * 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.
 * 4) * 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.
 * 5) 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).
 * 6) 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  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.
 * 7) Add the triplified revision history back to the triple store of the SMW by SH templates.
 * 8) 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).

Namespaces
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: he string prefix of the 'NS_REVISION' namespace (default 'rev')

Template names and parameters
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.


 * 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.


 * HISTORY_TRIPLE: for triple basic information (default 'SH_Triple'); Example
 * parameter 1: subject
 * parameter 2: predicate
 * parameter 3: object
 * e.g.,


 * 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.


 * 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.


 * HISTORY_MINOR: for "minor" flag of a revision (default 'SH_Minor'); Example
 * no parameter
 * e.g.


 * 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.


 * 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.


 * 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.


 * 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.

Configuration Flags

 * $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 (exprimental)

Semantic Modeling Vocabulary
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
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

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 tag::gdptag::infobox

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

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

Installation
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" svn co http://smwbp.googlecode.com/svn/trunk/mediawiki/extensions/SemanticHistory/
 * or if you have shell access, you can install using svn

OR

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:

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, 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 for their information.
 * Note: you can define your own set of templates instead.

Change Log
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.

History:
 * Sept 10, 2009 version 0.1 -first release