Semantic Result Formats: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
m (Text replacement - "<pageby nominor="false" comments="false"/>" to "<!-- <pageby nominor="false" comments="false"/> -->")
 
(30 intermediate revisions by the same user not shown)
Line 2: Line 2:
|name=Semantic Result Formats
|name=Semantic Result Formats
|about=This is '''not''' an official page. In addition, it is just a stub. Lots of missing information....
|about=This is '''not''' an official page. In addition, it is just a stub. Lots of missing information....
|logo=
|screenshot=
|developers=Jeroen De Dauw, Frank Dengler, Steren Giannini, James Hong Kong, Fabian Howahl, Yaron Koren, Markus Krötzsch, David Loomer, Joel Natividad, Denny Vrandecic, Nathan Yergler, others
|developers=Jeroen De Dauw, Frank Dengler, Steren Giannini, James Hong Kong, Fabian Howahl, Yaron Koren, Markus Krötzsch, David Loomer, Joel Natividad, Denny Vrandecic, Nathan Yergler, others
|author_location=Gent, Belgium
|author_location=Gent, Belgium
Line 9: Line 11:
|dependencies=Semantic MediaWiki
|dependencies=Semantic MediaWiki
|related=Semantic Forms, Semantic Forms Inputs, Semantic Maps, Semantic MediaWiki
|related=Semantic Forms, Semantic Forms Inputs, Semantic Maps, Semantic MediaWiki
|related_text=
|discussion=
|languages=
|status=stable
|status=stable
|released=2010/12/10
|released=2010/12/10
|last_released=2012/12/02
|last_released=2014/04/04
|last_version=1.8.0
|last_version=1.9.1 alpha (9482833)
|programming language=PHP
|programming language=PHP
|alternative=
|website=http://www.semantic-mediawiki.org/wiki/Semantic_Result_Formats
|website=http://www.semantic-mediawiki.org/wiki/Semantic_Result_Formats
|publication=
|support_website=http://www.semantic-mediawiki.org/wiki/Semantic_Result_Formats
|support_website=http://www.semantic-mediawiki.org/wiki/Semantic_Result_Formats
|last_edit=2013/06/26
|example_website=
|last_edit=2014/05/02
}}
}}
 
<!-- <pageby nominor="false" comments="false"/> -->
<pageby nominor="false" comments="false"/>


== Introduction ==
== Introduction ==
Line 25: Line 32:
'''Semantic Result Formats''' (SRF) is a MediaWiki extension, used in conjunction with the [[Semantic MediaWiki]] extension, that bundles a number of further result formats for SMW's inline queries. The individual formats can be added to the installation independently. ([http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats Mediawiki.org extension page], June 12 2013).
'''Semantic Result Formats''' (SRF) is a MediaWiki extension, used in conjunction with the [[Semantic MediaWiki]] extension, that bundles a number of further result formats for SMW's inline queries. The individual formats can be added to the installation independently. ([http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats Mediawiki.org extension page], June 12 2013).


In order to understand result formats, you must understand how formulate queries. The [[Semantic MediaWiki]] page includes a short introduction. Better, read [http://semantic-mediawiki.org/wiki/Help:Semantic_search the official documentation], in particular: [http://semantic-mediawiki.org/wiki/Help:Selecting_pages Selecting pages].
For installation tips, read the [[Semantic MediaWiki]] article, i.e. we suggest to use the composer dependency manager.
 
In order to understand result formats, you must understand how to formulate queries. The [[Semantic MediaWiki]] page includes a short introduction. Better, read [http://semantic-mediawiki.org/wiki/Help:Semantic_search the official documentation], in particular: [http://semantic-mediawiki.org/wiki/Help:Selecting_pages Selecting pages]. In a nutshell, you should know that queries return lists of pages or lists of pages with lists of property values.
 
Examples in this page use "real" data, i.e. all the properties/values defined in the pages of the [[:category:MediaWiki extension|MediaWiki extension category]]. By the way, in this wiki, most property values are defined through templates using [[Semantic Forms]].


=== Ordinary SMW result formats ===
=== Ordinary SMW result formats ===
Line 54: Line 65:
=== The table format ===
=== The table format ===


Below is a simple example of a table with two columns: Names of matched pages and value of the ''Is developed by'' properties found.
Below is a simple example of a table with three columns: Names of matched pages (i.e. all pages in the category) and values of the ''Is developed by'' and ''Is related to'' properties found in these pages.


This code:
This code:
Line 60: Line 71:
{{#ask: [[Category:MediaWiki extension]]
{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| ?Is developed by
| ?Is related to
| limit=3
}}
}}
</source>
</source>
Line 65: Line 78:
{{#ask: [[Category:MediaWiki extension]]
{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| ?Is developed by
| ?Is related to
| limit=3
}}
}}


Line 132: Line 147:
| format=CSV
| format=CSV
}}
}}
=== Using templates ===
[http://semantic-mediawiki.org/wiki/Help:Template_format Template format] can be used to taylor output, for example:
* Changing the order in which output is displayed, or omitting or duplicating output;
* Displaying images depending on query results;
* Creating links for property values;
* Using CSS styles to vary font-size, alignment, background-color, etc. by column in tables.


== Examples of Semantic Result Formats ==
== Examples of Semantic Result Formats ==
Line 137: Line 160:
I.e. (some of) the ones we use here ...
I.e. (some of) the ones we use here ...


Extensions to SMW can add other result formats. All (or most) of these can be obtained with this extension. However, you will have to pay attention to the configuration parameters, i.e. by default, not all Semantic Result Formats are available if you just install and load this extension.
Extensions to SMW can add other result formats. All (or most) of these display formats can be obtained with this extension. However, you will have to pay attention to the configuration parameters, i.e. by default, not all Semantic Result Formats are available if you just install and load this extension. Some JavaScript libraries have to be enabled.
 
Also, for many types of graphics, you will have to use to the <code>distribution=yes</code> parameter.


Notice that the #smwdoc parser function allows for automatic parameter documentation generation for all result formats. E.g. if you are tired of looking up documentation at smenatic-mediawiki.org, you could insert something like <nowiki>{{#smwdoc:table}}</nowiki> in a wiki,  page like we did here (look at the source of this page)
Notice that the #smwdoc parser function allows for automatic parameter documentation generation for all result formats. E.g. if you are tired of looking up documentation at smenatic-mediawiki.org, you could insert something like <nowiki>{{#smwdoc:table}}</nowiki> in a wiki,  page like we did here (look at the source of this page)
Line 143: Line 168:
=== Simple lists ===
=== Simple lists ===


There are three variants: outline, ol and ul
Outline format
{{#smwdoc:outline}}
{{#smwdoc:outline}}
ol format
{{#smwdoc:ol}}


This code
This code
Line 157: Line 187:
| ?Is developed by
| ?Is developed by
| format=outline
| format=outline
}}
This code
<source lang="perl">
{{#ask: [[Category:Software information]]
| ?Is developed by
| format=ol
}}
</source>
produces this:
{{#ask: [[Category:Software information]]
| ?Is developed by
| format=ol
}}
}}


Line 178: Line 222:
| ?Is developed by
| ?Is developed by
| format=tagcloud
| format=tagcloud
}}
----
The following:
<source lang="perl">
{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| format=tagcloud
| widget=wordcloud
}}
</source>
produces:
{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| format=tagcloud
| widget=wordcloud
}}
}}


Line 248: Line 307:


=== JqPlotChart ===
=== JqPlotChart ===
The ''Jpplotchart'' result format allows to create five different types of charts: '''bar, line, donut, bubble and scatter'''. Each of these requires a certain data model. Data sets can grouped depending of its source.


Read [http://semantic-mediawiki.org/wiki/Help:Jqplotseries_format Help:Jqplotseries format]
Read [http://semantic-mediawiki.org/wiki/Help:Jqplotseries_format Help:Jqplotseries format]
This extension has many parameters. Some only make sense with certain types of charts.


{{#smwdoc:jqplotchart}}
{{#smwdoc:jqplotchart}}


=== Donuts ===
The following example doesn't use numerical data values, but counts occurences using the parameter ''distribution=yes''-
 
==== Donuts ====


<source lang="bibtex">
<source lang="bibtex">
Line 281: Line 346:
}}
}}


=== Bar chart ===
==== Bar chart ====


<source lang="bibtex">
<source lang="bibtex">
Line 308: Line 373:




To display more than one property, it's probably best to group (else you get all the data in the same ring)....
To display more than one property in a chart, it's probably best to group (else you get all the data in the same ring or bar). However, you need numerical data for that (I believe ...)
 
=== Using templates ===
 
'''Achievement badges'''
 
The following code was used to dislay achievement badges for the [[:fr:Bases psychopédagogiques des technologies éducatives|Bases psychopédagogiques des technologies éducatives]] in the french sister site.
 
Query example that could be inserted in a user page:
<source lang="bibtex"  enclose="div">
{{#ask: [[REPORTING:+]] [[catégorie_principale::catégorie:Bases psychopédagogiques des technologies éducatives]] [[a intention de produire::vrai]] [[A taux_d'achèvement::100]] [[Agent::user:{{PAGENAME}}]]
|? agent
|? page wiki
|? A taux_d'achèvement
|? Promotion
| distribution=yes
| mainlabel=-
| format=template
| template=badge screencast completed
| userparam=show_page
| default=Vous n'avez pas encore gagné de badge(s) d'achèvement.
}}
</source>
 
Code for the [http://edutechwiki.unige.ch/fr/Mod%C3%A8le:Badge_screencast_completed badge screencast completed] template
<source lang="bibtex" enclose="div">
<includeonly>
<div class="badge">
[[image:badge_screencast_completed.png|128px]]
<div class="appear">
'''Badge d'achèvement'''<br/>
Carte conceptuelle et infographie
«{{{2|}}}» complétées
par {{{1|}}} - {{{3|}}} %
 
Délivré par [[user:Daniel K. Schneider|DKS]], EduTechWiki(fr), [http://tecfa.unige.ch TECFA], [http://www.unige.ch UNIGE], cours [[Bases psychopédagogiques des technologies éducatives|Bases]], promotion {{{4|}}}</div>
{{#ifeq:{{{userparam}}}|show_user|<span style="font-size:smaller">{{{1}}}</span>|}}{{#ifeq:{{{userparam}}}|show_page|<span style="font-size:smaller">{{{2}}}</span>|}}</div>
</includeonly>
 
</source>
 
'''Tables with pictures'''
 
* [[template: table with image]] used by [[Template:Data_mining_and_learning_analytics_tools_query]], used to produce the [[List of data mining and learning analytics tools]]
 
<source lang="bibtex" enclose="div">
{{#ask: [[Category:data mining and learning analytics tools]] [[Analysis orientation::General analysis]]
| ?Has logo #-
| ?Has name = Name
| ?Has last revision number=
| ?Was last released on#iso
| ?License type = License
| ?Data tool type = Tool type
| ?Data manipulation type =
| ?Has website=
| ?Last edition=
| mainlabel=General purpose analysis
| format=template
| template= Table with image
| introtemplate= Table with image/intro
| outrotemplate= CS Table with img/outro
| limit=3
|}}
</source>
 
produces:
{{#ask: [[Category:data mining and learning analytics tools]] [[Analysis orientation::General analysis]]
| ?Has logo #-
| ?Has name = Name
| ?Has last revision number=
| ?Was last released on#iso
| ?License type = License
| ?Data tool type = Tool type
| ?Data manipulation type =
| ?Has website=
| ?Last edition=
| mainlabel=General purpose analysis
|format=template
| template= Table with image
| introtemplate= Table with image/intro
| outrotemplate= CS Table with img/outro
| limit=3
|}}
 
== Tips ==
 
=== Getting it to work with MW 1.24 ===
 
# Install like for 1.22+ as explained in the [http://semantic-mediawiki.org/wiki/Semantic_Result_Formats#Installation official doc]. Make sure to install recent GraphViz and Image Map extensions.
# Fix a JQuery problem: As explained in the [https://github.com/wikimedia/mediawiki-core/blob/master/RELEASE-NOTES-1.24#L48 release notes for MW 1.24], jQuery was upgraded from 1.8.3 to 1.11.1. This will break the jqplot library. To fix the problem, do the two following:
* Add <code>$wgIncludejQueryMigrate = true;</code> to LocalSettings.php
 
=== Doesn't seem to take all data ===
 
By default an inline query made with #ask only returns 50 results. This number can be misleading. If you do a query that aggregates pages (using distribution, sum, count, etc.), "limit" concerns the number of the pages you will retrieve before passing their data to a result format. Limit does not specify the number of pages (or other elements) that are on display !
 
This behavior can be changed by setting [https://www.semantic-mediawiki.org/wiki/Help:Configuration#smwgQDefaultLimit smwgQDefaultLimit] to higher value in LocalSettings.php
 
Alternatively, use <code>limit=''</code> in the query. In the example below, we will see '''one''' chart element for each page, but there is a huge multiple of pages found. If limit is too low, results will simply be wrong !
 
<source lang="bibtex">
{{#ask: [[REPORTING:+]] [[agent::+]] [[catégorie_principale::catégorie:Bases psychopédagogiques des technologies éducatives]]
|?agent
|mainlabel=-
|distribution=yes
|format=d3chart
|charttype=treemap
|height=800
|width=100%
|headers=show
|link=all
|min=1
|limit=500
|charttitle= N pages annotées
|datalabels=chart
</source>


== Links ==
== Links ==


* [http://www.semantic-mediawiki.org/wiki/Help:Result_formats List of Result formats] (Official manual pages)
'''Official'''
* [http://www.semantic-mediawiki.org/wiki/Help:Result_formats List of Result formats]  
 
'''Tutorials'''
 
* [http://tiagoferreira.nome.pt/blog/archives/264 SMW’s Semantic Result Formats – Jqplotchart/Jqplotseries format – A guide] by Tiago Ferreira. It includes live example that you can see in a [http://tiagoferreira.nome.pt/wiki/index.php?title=Main_Page demo wiki]

Latest revision as of 17:58, 22 August 2016

Category:MediaWiki extension
Semantic Result Formats
Extension name Semantic Result Formats
About this article / disclaimer This is not an official page. In addition, it is just a stub. Lots of missing information....
Logo [[Image:|135px]]
Screenshot [[Image:|135px]]
Location of the main author Gent, Belgium
Coordinates of the main authors 51.053829, 3.725012
Developers Jeroen De Dauw, Frank Dengler, Steren Giannini, James Hong Kong, Fabian Howahl, Yaron Koren, Markus Krötzsch, David Loomer, Joel Natividad, Denny Vrandecic, Nathan Yergler, others
Licences GPL
Description Semantic Result Formats (SRF) is a MediaWiki extension, used in conjunction with the Semantic MediaWiki extension, that bundles a number of further result formats for SMW's inline queries. The individual formats can be added to the installation independently...
Mediawiki requirements Any recent version
Dependencies Semantic MediaWiki
Related extensions (documented here) Semantic Forms, Semantic Forms Inputs, Semantic Maps, Semantic MediaWiki
Related extensions
Discussion
Language support
Status stable
First release date 2010/12/10
Last release date (as of 2014/05/02!) 2014/04/04
Last version number 1.9.1 alpha (9482833)
Programming language PHP
Alternatives
Website home page
Publications
Support websites web site
Example websites
Last edited 2014/05/02


Introduction

Semantic Result Formats (SRF) is a MediaWiki extension, used in conjunction with the Semantic MediaWiki extension, that bundles a number of further result formats for SMW's inline queries. The individual formats can be added to the installation independently. (Mediawiki.org extension page, June 12 2013).

For installation tips, read the Semantic MediaWiki article, i.e. we suggest to use the composer dependency manager.

In order to understand result formats, you must understand how to formulate queries. The Semantic MediaWiki page includes a short introduction. Better, read the official documentation, in particular: Selecting pages. In a nutshell, you should know that queries return lists of pages or lists of pages with lists of property values.

Examples in this page use "real" data, i.e. all the properties/values defined in the pages of the MediaWiki extension category. By the way, in this wiki, most property values are defined through templates using Semantic Forms.

Ordinary SMW result formats

By default, SMW already includes a series of result formats as documented here.

Of particular interest for creating wiki pages are:

  • The table format. The default format for queries that include at least one property to display. See an example below.
  • The list format. The default format for queries that do not include properties to display. See an example below.
  • The ul and ol extend the list format to numbered and bulleted lists with additional output shown in parenthesis
  • The template format. Allows to use templates for custom formatting

In addition, there is a whole range of formats meant for download. For example

  • The CSV format could be useful for exporting a query result for further analysis

All or (most?) formats share the same base parameters:

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
source ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Alternative query source
limit ⧼validator-type-integer⧽ 50 The maximum number of results to return
offset ⧼validator-type-integer⧽ 0 The offset of the first result
link ⧼validator-type-string⧽ all Show values as links
sort ⧼validator-type-string-list⧽ ⧼validator-describe-empty⧽ Property to sort the query by
order ⧼validator-type-string-list⧽ ⧼validator-describe-empty⧽ Order of the query sort
headers ⧼validator-type-string⧽ show Display the headers/property names
mainlabel ⧼validator-type-string⧽ no The label to give to the main page name
intro ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The text to display before the query results, if there are any
outro ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The text to display after the query results, if there are any
searchlabel ⧼validator-type-string⧽ ... further results Text for continuing the search
default ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The text to display if there are no query results

The most important parameter could be mainlabel. Use

mainlabel=-

to suppress printing the first result column which is the wiki page that includes a matching query

 mainlabel=Some sort of title

to add a title to the first column.

Supressing the first column is something that also applies to charts produced by Semantic Result Formats extensions ! Do not forget !

The table format

Below is a simple example of a table with three columns: Names of matched pages (i.e. all pages in the category) and values of the Is developed by and Is related to properties found in these pages.

This code:

{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| ?Is related to
| limit=3
}}

... will produce this table:

 Is developed byIs related to
Maps (MediaWiki extension)Jeroen De Dauw
others
Mediawiki collection extension installationPediaPress.com
Siebrand Mazeland
Marcin Cieślak
Page FormsYaron Koren
Stephan Gambke
others
... further results

The table format can take additional parameters.

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
class ⧼validator-type-string⧽ sortable wikitable smwtable An additional CSS class to set for the table
transpose ⧼validator-type-boolean⧽ no Display table headers vertically and results horizontally
sep ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The separator between results
prefix ⧼validator-type-string⧽ none Control display of namespace in printouts

Now, semantic Result Formats adds other visualization types. Most of these are based on various JavaScript libraries, such as D3. Read on ....

List format

The list format takes the following extra parameters:

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-aliases⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
propsep - ⧼validator-type-string⧽ , The separator between the properties of a result entry
valuesep - ⧼validator-type-string⧽ , The separator between the values for a property of a result
template - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template with which to display the printouts
named args namedargs ⧼validator-type-boolean⧽ no Name the arguments passed to the template
userparam - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ A value passed into each template call, if a template is used
class - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ An additional CSS class to set for the list
introtemplate - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display before the query results, if there are any
outrotemplate - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display after the query results, if there are any
sep - ⧼validator-type-string⧽ , The separator between results
prefix - ⧼validator-type-string⧽ none Control display of namespace in printouts

The following query gets all pages in the MediaWiki extension and displays both the hit (i.e. the page) and the value of Is developed by property:

list of names: {{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| format=list
}}

... will produce this list of names: Maps (MediaWiki extension) (Is developed by: Jeroen De Dauw, others), Mediawiki collection extension installation (Is developed by: PediaPress.com, Siebrand Mazeland, Marcin Cieślak), Page Forms (Is developed by: Yaron Koren, Stephan Gambke, others), Semantic Drilldown (Is developed by: Yaron Koren, David Loomer), Semantic Forms Inputs (Is developed by: Stephan Gambke, Yaron Koren, Jeroen De Dauw, Sanyam Goyal, Yury Katkov, others), Semantic Maps (Is developed by: Jeroen De Dauw, others), Semantic MediaWiki (Is developed by: Markus Krötzsch, Denny Vrandecic, Jeroen De Dauw, others), Semantic Result Formats (Is developed by: Jeroen De Dauw, Frank Dengler, Steren Giannini, James Hong Kong, Fabian Howahl, Yaron Koren, Markus Krötzsch, David Loomer, Joel Natividad, Denny Vrandecic, Nathan Yergler, others), VisualEditor You can see that we have to require list format, else we would have gotten a table

The following query gets all pages in the MediaWiki extension that include a Is developed by property. It will only display the (useless) Is developed by values.

list of names: {{#ask: [[Is developed by::+]][[Category:MediaWiki extension]]
|?Is developed by
|mainlabel=-
}}

... will produce this list of names: Is developed by: Jeroen De Dauw, others, Is developed by: PediaPress.com, Siebrand Mazeland, Marcin Cieślak, Is developed by: Yaron Koren, Stephan Gambke, others, Is developed by: Yaron Koren, David Loomer, Is developed by: Stephan Gambke, Yaron Koren, Jeroen De Dauw, Sanyam Goyal, Yury Katkov, others, Is developed by: Jeroen De Dauw, others, Is developed by: Markus Krötzsch, Denny Vrandecic, Jeroen De Dauw, others, Is developed by: Jeroen De Dauw, Frank Dengler, Steren Giannini, James Hong Kong, Fabian Howahl, Yaron Koren, Markus Krötzsch, David Loomer, Joel Natividad, Denny Vrandecic, Nathan Yergler, others

List format on steroids

For custom formatting, use templates. Read the official Template format documentation.

The CSV format

In addition to the base parameters, the CSV format takes the following:

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
sep ⧼validator-type-string⧽ , Specifies a column separator
valuesep ⧼validator-type-string⧽ , Specifies a value separator
showsep ⧼validator-type-boolean⧽ no Show separator in top of CSV file ("sep=<value>")
filename ⧼validator-type-string⧽ result.csv The name for the output file
merge ⧼validator-type-boolean⧽ no Merge rows and column values with an identical subject identifier (aka first column)
bom ⧼validator-type-boolean⧽ no Add a BOM (character to signal endianness) at the top of the output file

The following produces a downloadable CSV file using the default comma (,) separator:

Download: {{#ask: [[Category:MediaWiki extension]]
| ?Depends on
| ?Is developed by
| ?Has status
| ?Is related to
| format=CSV
}}

Download: CSV

Using templates

Template format can be used to taylor output, for example:

  • Changing the order in which output is displayed, or omitting or duplicating output;
  • Displaying images depending on query results;
  • Creating links for property values;
  • Using CSS styles to vary font-size, alignment, background-color, etc. by column in tables.

Examples of Semantic Result Formats

I.e. (some of) the ones we use here ...

Extensions to SMW can add other result formats. All (or most) of these display formats can be obtained with this extension. However, you will have to pay attention to the configuration parameters, i.e. by default, not all Semantic Result Formats are available if you just install and load this extension. Some JavaScript libraries have to be enabled.

Also, for many types of graphics, you will have to use to the distribution=yes parameter.

Notice that the #smwdoc parser function allows for automatic parameter documentation generation for all result formats. E.g. if you are tired of looking up documentation at smenatic-mediawiki.org, you could insert something like {{#smwdoc:table}} in a wiki, page like we did here (look at the source of this page)

Simple lists

There are three variants: outline, ol and ul

Outline format

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
outlineproperties ⧼validator-type-string-list⧽ ⧼validator-describe-empty⧽ The list of properties to be displayed as outline headers, separated by commas
template ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template with which to display the printouts
introtemplate ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display before the query results, if there are any
outrotemplate ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display after the query results, if there are any
userparam ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ A value passed into each template call, if a template is used
named args ⧼validator-type-boolean⧽ yes Name the arguments passed to the template

ol format

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-aliases⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
propsep - ⧼validator-type-string⧽ , The separator between the properties of a result entry
valuesep - ⧼validator-type-string⧽ , The separator between the values for a property of a result
template - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template with which to display the printouts
named args namedargs ⧼validator-type-boolean⧽ no Name the arguments passed to the template
userparam - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ A value passed into each template call, if a template is used
class - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ An additional CSS class to set for the list
introtemplate - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display before the query results, if there are any
outrotemplate - ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template to display after the query results, if there are any
prefix - ⧼validator-type-string⧽ none Control display of namespace in printouts

This code

{{#ask: [[Category:Software information]]
| ?Is developed by
| format=outline
}}

produces this:


This code

{{#ask: [[Category:Software information]]
| ?Is developed by
| format=ol
}}

produces this:

  1. Mediawiki (Is developed by: MediaWiki foundation and MediaWiki volunteers)
  2. Some software (Is developed by: Many)

Tagcloud

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
template ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The name of a template with which to display the printouts
userparam ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ A value passed into each template call, if a template is used
excludetags ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Exclude tags (delimiter: ";")
includesubject ⧼validator-type-boolean⧽ no ⧼srf-paramdesc-includesubject⧽
tagorder ⧼validator-type-string⧽ alphabetical The order of the tags
increase ⧼validator-type-string⧽ log How to increase the size of tags
widget ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Available widget
class ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ An additional CSS class to set for the list
font ⧼validator-type-string⧽ impact ⧼srf-paramdesc-font⧽
height ⧼validator-type-integer⧽ 400 Height
width ⧼validator-type-integer⧽ 400 Width
mincount ⧼validator-type-integer⧽ 1 The minimum amount of times a value needs to occur to be listed
minsize ⧼validator-type-integer⧽ 77 The size of the smallest tags in percent
maxsize ⧼validator-type-integer⧽ 242 The size of the biggest tags in percent
maxtags ⧼validator-type-integer⧽ 1000 The maximum amount of tags in the cloud

The following:

{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| format=tagcloud
}}

produces:


David Loomer Denny Vrandecic Fabian Howahl Frank Dengler James Hong Kong Jeroen De Dauw Joel Natividad Marcin Cieślak Markus Krötzsch Nathan Yergler others PediaPress.com Sanyam Goyal Siebrand Mazeland Stephan Gambke Steren Giannini Yaron Koren Yury Katkov

The following:

{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
| format=tagcloud
| widget=wordcloud
}}

produces:

  • David Loomer
  • Denny Vrandecic
  • Fabian Howahl
  • Frank Dengler
  • James Hong Kong
  • Jeroen De Dauw
  • Joel Natividad
  • Marcin Cieślak
  • Markus Krötzsch
  • Nathan Yergler
  • others
  • PediaPress.com
  • Sanyam Goyal
  • Siebrand Mazeland
  • Stephan Gambke
  • Steren Giannini
  • Yaron Koren
  • Yury Katkov

D3 Bubble chart

Official documentation:

List of parameters:

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
distribution ⧼validator-type-boolean⧽ no Instead of displaying all values, count their occurrences, and show these.
distributionsort ⧼validator-type-string⧽ none Sort the value distribution by occurrence count.
distributionlimit ⧼validator-type-integer⧽ no Limit the value distribution to the count of only some values.
aggregation ⧼validator-type-string⧽ subject Specify to what the aggregation should relate to
min ⧼validator-type-integer⧽ no The minimum value to show on the Y-axis
charttype ⧼validator-type-string⧽ treemap Available chart type
height ⧼validator-type-integer⧽ 400 Specify the height (in pixels) of a chart or graph
width ⧼validator-type-string⧽ 100% Specify the width (in pixels or percent) of a chart or graph
charttitle ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The title of the chart
charttext ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Descriptive chart text
class ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Specify an additional cascading style sheet class
datalabels ⧼validator-type-string⧽ none Chart/graph data labels
colorscheme ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Select a color scheme
chartcolor ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Assign individual chart colors
{{#ask: [[Category:MediaWiki extension]]
| ?Is developed by
|format=d3chart
|distribution=yes
|mainlabel=-
|charttype=bubble
|headers=show
|link=all
|charttitle= SMW developers
|datalabels=chart
}}

Notice the use of the following parameters:

  • distribution=yes will count occurences
  • mainlabel=- will exclude the count of the pages themselves

We roughly get the same information as in the word cloud.

The result of not using mainlabel=- is below:

{{#ask: [[Category:MediaWiki extension]][[Is developed by::+]]
| ?Is developed by
|format=d3chart
|distribution=yes
|charttype=bubble
|headers=show
|link=all
|charttitle= SMW developers
|datalabels=chart
}}

Useless resulting chart:

JqPlotChart

The Jpplotchart result format allows to create five different types of charts: bar, line, donut, bubble and scatter. Each of these requires a certain data model. Data sets can grouped depending of its source.

Read Help:Jqplotseries format

This extension has many parameters. Some only make sense with certain types of charts.

⧼validator-describe-header-parameter⧽ ⧼validator-describe-header-type⧽ ⧼validator-describe-header-default⧽ ⧼validator-describe-header-description⧽
distribution ⧼validator-type-boolean⧽ no Instead of displaying all values, count their occurrences, and show these.
distributionsort ⧼validator-type-string⧽ none Sort the value distribution by occurrence count.
distributionlimit ⧼validator-type-integer⧽ no Limit the value distribution to the count of only some values.
aggregation ⧼validator-type-string⧽ subject Specify to what the aggregation should relate to
min ⧼validator-type-integer⧽ no The minimum value to show on the Y-axis
direction ⧼validator-type-string⧽ vertical Specify the direction of a chart or graph
charttitle ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The title of the chart
charttext ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Descriptive chart text
numbersaxislabel ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The label for the numbers axis
labelaxislabel ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ The label for the label axis
height ⧼validator-type-integer⧽ 400 Specify the height (in pixels) of a chart or graph
width ⧼validator-type-string⧽ 100% Specify the width (in pixels or percent) of a chart or graph
smoothlines ⧼validator-type-boolean⧽ no Apply a smoothing algorithm on line charts
valueformat ⧼validator-type-string⧽ %d Specify formatting rule for values
ticklabels ⧼validator-type-boolean⧽ yes Enable display of tick labels
highlighter ⧼validator-type-boolean⧽ no Display a data point highlighter
theme ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Select a grid theme
filling ⧼validator-type-boolean⧽ yes Individual filling option
chartlegend ⧼validator-type-string⧽ none Chart legend position
datalabels ⧼validator-type-string⧽ none Chart/graph data labels
colorscheme ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Select a color scheme
chartcolor ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Assign individual chart colors
class ⧼validator-type-string⧽ ⧼validator-describe-empty⧽ Specify an additional cascading style sheet class
charttype ⧼validator-type-string⧽ bar Available chart type

The following example doesn't use numerical data values, but counts occurences using the parameter distribution=yes-

Donuts

{{#ask:[[Category:MediaWiki extension]][[Is related to::+]]
|?Is related to
|mainlabel=-
|format=jqplotchart
|charttype=donut
|chartlegend=e
|charttitle= Related extensions (%)
|distribution=yes
|width=33%
|datalabels=percent
}}

Bar chart

{{#ask:[[Category:MediaWiki extension]][[Is related to::+]]
|?Is related to
|mainlabel=-
|format=jqplotchart
|charttype=bar
|charttitle= Related extensions
|distribution=yes
|width=33%
|datalabels=percent
}}


To display more than one property in a chart, it's probably best to group (else you get all the data in the same ring or bar). However, you need numerical data for that (I believe ...)

Using templates

Achievement badges

The following code was used to dislay achievement badges for the Bases psychopédagogiques des technologies éducatives in the french sister site.

Query example that could be inserted in a user page:

{{#ask: [[REPORTING:+]] [[catégorie_principale::catégorie:Bases psychopédagogiques des technologies éducatives]] [[a intention de produire::vrai]] [[A taux_d'achèvement::100]] [[Agent::user:{{PAGENAME}}]]
|? agent
|? page wiki
|? A taux_d'achèvement
|? Promotion
| distribution=yes
| mainlabel=-
| format=template
| template=badge screencast completed
| userparam=show_page
| default=Vous n'avez pas encore gagné de badge(s) d'achèvement.
}}

Code for the badge screencast completed template

<includeonly>
<div class="badge">
[[image:badge_screencast_completed.png|128px]]
<div class="appear">
'''Badge d'achèvement'''<br/>
Carte conceptuelle et infographie
«{{{2|}}}» complétées
par {{{1|}}} - {{{3|}}} %

Délivré par [[user:Daniel K. Schneider|DKS]], EduTechWiki(fr), [http://tecfa.unige.ch TECFA], [http://www.unige.ch UNIGE], cours [[Bases psychopédagogiques des technologies éducatives|Bases]], promotion {{{4|}}}</div>
{{#ifeq:{{{userparam}}}|show_user|<span style="font-size:smaller">{{{1}}}</span>|}}{{#ifeq:{{{userparam}}}|show_page|<span style="font-size:smaller">{{{2}}}</span>|}}</div>
</includeonly>

Tables with pictures

{{#ask: [[Category:data mining and learning analytics tools]] [[Analysis orientation::General analysis]]
| ?Has logo #-
| ?Has name = Name
| ?Has last revision number=
| ?Was last released on#iso
| ?License type = License
| ?Data tool type = Tool type
| ?Data manipulation type = 
| ?Has website=
| ?Last edition=
| mainlabel=General purpose analysis
| format=template
| template= Table with image
| introtemplate= Table with image/intro
| outrotemplate= CS Table with img/outro
| limit=3
|}}

produces:

DM and LA tools license Tool type Data manipulation Access Page edition
No image.png
Free&Closed source Data analysis http://www.laurenceanthony.net/software.html#antconc 14 November 2014
Mahout-logo-brudman.png
Free&Open source Framework/Library/API Data analysis http://mahout.apache.org/ 2 October 2014
OpenNLP.png
Apache OpenNLP 1.5.3 (2013-04-13)
Free&Open source Framework/Library/API Data extraction, Data transformation, Data analysis http://opennlp.apache.org/index.html 21 March 2014

... further results

Tips

Getting it to work with MW 1.24

  1. Install like for 1.22+ as explained in the official doc. Make sure to install recent GraphViz and Image Map extensions.
  2. Fix a JQuery problem: As explained in the release notes for MW 1.24, jQuery was upgraded from 1.8.3 to 1.11.1. This will break the jqplot library. To fix the problem, do the two following:
  • Add $wgIncludejQueryMigrate = true; to LocalSettings.php

Doesn't seem to take all data

By default an inline query made with #ask only returns 50 results. This number can be misleading. If you do a query that aggregates pages (using distribution, sum, count, etc.), "limit" concerns the number of the pages you will retrieve before passing their data to a result format. Limit does not specify the number of pages (or other elements) that are on display !

This behavior can be changed by setting smwgQDefaultLimit to higher value in LocalSettings.php

Alternatively, use limit= in the query. In the example below, we will see one chart element for each page, but there is a huge multiple of pages found. If limit is too low, results will simply be wrong !

{{#ask: [[REPORTING:+]] [[agent::+]] [[catégorie_principale::catégorie:Bases psychopédagogiques des technologies éducatives]] 
|?agent
|mainlabel=-
|distribution=yes
|format=d3chart
|charttype=treemap
|height=800
|width=100%
|headers=show
|link=all
|min=1
|limit=500
|charttitle= N pages annotées
|datalabels=chart

Links

Official

Tutorials