Semantic Result Formats: Difference between revisions
Line 71: | Line 71: | ||
Now, semantic Result Formats adds other visualization types. Most of these are based on various JavaScript libraries, such as D3. Read on .... | Now, semantic Result Formats adds other visualization types. Most of these are based on various JavaScript libraries, such as D3. Read on .... | ||
=== List format === | |||
This code: | |||
<source lang="perl"> | |||
List of names: {{#ask: [[Category:Software information]] | |||
| ?Is developed by | |||
| mainlabel=- | |||
}} | |||
</source> | |||
... will produce this table: | |||
List of names: {{#ask: [[Category:Software information]] | |||
| ?Is developed by | |||
| mainlabel=- | |||
}} | |||
=== The CSV format === | === The CSV format === |
Revision as of 21:03, 27 November 2013
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 | |
Screenshot | |
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 2013/06/26!) | 2012/12/02 |
Last version number | 1.8.0 |
Programming language | PHP |
Alternatives | |
Website | home page |
Publications | |
Support websites | web site |
Example websites | |
Last edited | 2013/06/26 |
<pageby nominor="false" comments="false"/>
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).
In order to understand result formats, you must understand how formulate queries. The Semantic MediaWiki page includes a short introduction. Better, read the official documentation, in particular: Selecting pages.
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 two columns: Names of matched pages and value of the Is developed by properties found.
This code:
{{#ask: [[Category:Software information]]
| ?Is developed by
}}
... will produce this table:
Is developed by | |
---|---|
Mediawiki | MediaWiki foundation and MediaWiki volunteers |
Some software | Many |
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
This code:
List of names: {{#ask: [[Category:Software information]]
| ?Is developed by
| mainlabel=-
}}
... will produce this table: List of names: Is developed by: MediaWiki foundation and MediaWiki volunteers, Is developed by: Many
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
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 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.
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
⧼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 |
This code
{{#ask: [[Category:Software information]]
| ?Is developed by
| format=outline
}}
produces this:
- Mediawiki (Is developed by MediaWiki foundation and MediaWiki volunteers)
- 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:
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:
Links
- List of Result formats (Official manual pages)