Difference between revisions of "Wikispooks:Semantic Templates"

From Wikispooks
Jump to navigation Jump to search
(fix links)
m (Text replacement - "WikiSpooks" to "Wikispooks")
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{HelpSection|image=SMW.png}}
+
{{HelpSection|image=SMW.png}}Although semantic properties can be added inline in text, this is cumbersome and unsystematic so should be used only for testing purposes. All the {{SMW}} data on Wikispooks pages is input through [[Wikispooks:templates]].
Although semantic properties can be added inline in text, this is cumbersome and unsystematic so should be used only for testing purposes. All the {{SMW}} data on Wikispooks pages is input through templates.  
 
  
 
==Object Orientation==
 
==Object Orientation==
The templates are structured around a set of objects. Each object its own set of semantic properties and accompanying template to mark process them. Some are displayed to the user, some are not. As of January 2014, the objects as currently defined, in order of completion are:
+
{{FA|Wikispooks:Semantic Objects}}
# [[Template:Document|Document]]s - The first object defined on Wikispooks, with a [[Template:DocProv|functional Template]] and [[Form:Document|form]]
+
The templates are structured around a set of objects. Each object its own set of semantic properties and accompanying template to mark process them. Some are displayed to the user, some are not. As of March 2016, the objects as currently defined are: [[Template:Document|Document]], [[Template:Website|Website]], [[Template:Property|Property]], [[Template:Person|Person]], [[Template:Group|Group]], [[Template:Event|Event]],[[Template:Place|Place]], [[Template:Employment|Employment]], [[Template:Publication|Publication]], [[Template:Timeline|Timeline]], [[Template:Year|Year]]
# [[Template:Website|Website]]s - Fairly simple, but fully functional template, no form as yet
 
# [[Template:Property|Properties]] - See [[:Category:Properties]] for the full set, a short and sweet template, currently no form
 
# [[Template:Event|Event]]s - Less functional, less consistent, no form
 
# [[Template:Person|Person]]s - Even less functional, even less consistent, no form
 
# [[Template:Group|Group]]s - Template currently just in planning, no form
 
  
 
==Syntax==
 
==Syntax==
 
A 'semantic template' is just a template which uses semantic mediawiki, whether for reading or writing properties. The basic parser directives you'll need are:  
 
A 'semantic template' is just a template which uses semantic mediawiki, whether for reading or writing properties. The basic parser directives you'll need are:  
* [http://semantic-mediawiki.org/index.php/Help:Inline_queries#Parser_function_.23ask #ask:] and [http://semantic-mediawiki.org/index.php/Help:Inline_queries#Parser_function_.23show #show]: For querying properties
+
* [http://semantic-mediawiki.org/index.php/Help:Inline_queries#Parser_function_.23ask #ask:] & [http://semantic-mediawiki.org/index.php/Help:Inline_queries#Parser_function_.23show #show]: ''For querying properties''
* #set: For setting properties
+
* #set: ''For setting properties''
* [http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymap #arraymap:]' and '[http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymaptemplate #arraymaptemplate:]  
+
* [http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymap #arraymap:] & [http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymaptemplate #arraymaptemplate:] ''For handling (usually comma-separated) lists''
 
A helpful summary of syntax is the quick reference guide, available [http://postable.net/smwqr/smw-quick-reference.pdf here].
 
A helpful summary of syntax is the quick reference guide, available [http://postable.net/smwqr/smw-quick-reference.pdf here].
  
 
===Multiple Values for Fields===
 
===Multiple Values for Fields===
Some parameters can take multiple values (e.g. an article can have more than one author). The previous approach to this was to have a set of numbered parameters, e.g {{t|Author}}, {{t|Author2}}, {{t|Author3}} etc. This is cumbersome and was implemented in a hurry. A better approach is under development which inputs the data as separate items in a list, either comma-separated or slash(/)-separated. Some templates list both possibilities. ''If you are inputting data and have a choice, avoid the older, numbered parameters, using the list parameters instead. If you are coding, check out the '[http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymap #arraymap:]' and '[http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymaptemplate #arraymaptemplate:]' parser instructions and code accordingly.
+
Some parameters can take multiple values (e.g. an article can have more than one author) and at least 3 approaches to this are tried and tested. Which method(s) would work best for Wikispooks is an open question.
  
===Dates===
+
====Numbered Fields====
''Dates should be input as a single field'', although some legacy code has separate fields for years, months & days. There are issues regarding data input and missing data items, but SMW is pretty good with date processing and a single field is the preferred option.
+
The first approach used on Wikispooks was to have a set of numbered parameters, e.g {{t|Author}}, {{t|Author2}}, {{t|Author3}} etc. This was straightforward but did not make full use of the facilities provided by SMW software and made for long, ugly templates. This method was deemed inferior to comma separated lists, and was gradually replaced, being finally eliminated in December 2015.
 +
 
 +
====Lists====
 +
The current preferred approach stores the data as separate items in a comma-separated list. ''This means that ',' should not be used in page titles''. These lists are easily processed with the '[http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymap #arraymap:]' and '[http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Semantic_Forms_and_templates#arraymaptemplate #arraymaptemplate:]' parser instructions.
 +
 
 +
Note that the processing of two properties ([[Property:Has keyProperties|Has keyProperties]] and [[Property:Has keyPropertyHeaders|Has keyPropertyHeaders]]) is too complex to be done with either #arraymap: or #arraymaptemplate: (since it is not done independently) so #titleparts: is needed instead, which requires use of slash(/)-separated lists.
 +
 
 +
====Multiple Templates====
 +
Another approach is the use of multiple templates. This is used on Wikispooks in the |{{t|employment}} section of the [[person]] object. It may be seen in action at [http://discoursedb.org/w/index.php?title=Form:Author DiscourseDB], a site run by Yaron Koren, the key developer of {{SMW}}. It appears better supported as regards form input (try adding multiple Wikipedia items on the DiscourseDB site, for example) but could lead to verbose page source if widely applied to the objects developed at Wikispooks.
 +
 
 +
==Semantic Output Templates==
 +
SMW has a ''{{t|template}}'' format, which allows use of a custom template to format results. Since this is more work, it is applied usually only on high traffic and/or specialist pages where the standard output formats fall short. As a consequence, these templates are usually quite specific, not general use. For general convenience, semantic web output templates should be placed in [[:Category:Semantic Output Templates]] and named as a subpage "output" of the template for which they were developed.
  
 
==See Also==
 
==See Also==
 
* http://semantic-mediawiki.org/wiki/Help:Semantic_templates - The SMW official (and good) documentation on semantic templates
 
* http://semantic-mediawiki.org/wiki/Help:Semantic_templates - The SMW official (and good) documentation on semantic templates
{{WikiSpooks Footer/Semantic Mediawiki}}
+
{{Wikispooks Footer/Semantic Mediawiki}}
 
[[Category:Semantic Mediawiki]]
 
[[Category:Semantic Mediawiki]]

Latest revision as of 17:13, 14 October 2018

SMW.png

Although semantic properties can be added inline in text, this is cumbersome and unsystematic so should be used only for testing purposes. All the SMW data on Wikispooks pages is input through Wikispooks:templates.

Object Orientation

Full article: Wikispooks:Semantic Objects

The templates are structured around a set of objects. Each object its own set of semantic properties and accompanying template to mark process them. Some are displayed to the user, some are not. As of March 2016, the objects as currently defined are: Document, Website, Property, Person, Group, Event,Place, Employment, Publication, Timeline, Year

Syntax

A 'semantic template' is just a template which uses semantic mediawiki, whether for reading or writing properties. The basic parser directives you'll need are:

A helpful summary of syntax is the quick reference guide, available here.

Multiple Values for Fields

Some parameters can take multiple values (e.g. an article can have more than one author) and at least 3 approaches to this are tried and tested. Which method(s) would work best for Wikispooks is an open question.

Numbered Fields

The first approach used on Wikispooks was to have a set of numbered parameters, e.g Author, Author2, Author3 etc. This was straightforward but did not make full use of the facilities provided by SMW software and made for long, ugly templates. This method was deemed inferior to comma separated lists, and was gradually replaced, being finally eliminated in December 2015.

Lists

The current preferred approach stores the data as separate items in a comma-separated list. This means that ',' should not be used in page titles. These lists are easily processed with the '#arraymap:' and '#arraymaptemplate:' parser instructions.

Note that the processing of two properties (Has keyProperties and Has keyPropertyHeaders) is too complex to be done with either #arraymap: or #arraymaptemplate: (since it is not done independently) so #titleparts: is needed instead, which requires use of slash(/)-separated lists.

Multiple Templates

Another approach is the use of multiple templates. This is used on Wikispooks in the |employment section of the person object. It may be seen in action at DiscourseDB, a site run by Yaron Koren, the key developer of SMW. It appears better supported as regards form input (try adding multiple Wikipedia items on the DiscourseDB site, for example) but could lead to verbose page source if widely applied to the objects developed at Wikispooks.

Semantic Output Templates

SMW has a template format, which allows use of a custom template to format results. Since this is more work, it is applied usually only on high traffic and/or specialist pages where the standard output formats fall short. As a consequence, these templates are usually quite specific, not general use. For general convenience, semantic web output templates should be placed in Category:Semantic Output Templates and named as a subpage "output" of the template for which they were developed.

See Also

Wikispooks logo.png Policy.png Wikispooks to do.png Tools2.png SMW.png
Semantic
Mediawiki
Help.png