Jump to content

Extension:Semantic Internal Objects/de

From mediawiki.org
This page is a translated version of the page Extension:Semantic Internal Objects and the translation is 40% complete.
MediaWiki-Erweiterungen
Semantic Internal Objects
Freigabestatus: ohne Wartung
Einbindung Parser-Funktion
Beschreibung Defines a parser function, #set_internal, that is used to define "internal objects" or "n-ary relations" within Semantic MediaWiki
Autor(en) Yaron Koren <yaron57@gmail.com>
Letzte Version 0.8.2 (Juni 2016)
MediaWiki 1.17+
DatenbankÀnderungen Nein
Lizenz GNU General Public License 2.0 oder neuer
Herunterladen See here
Übersetze die Semantic Internal Objects-Erweiterung, wenn sie auf translatewiki.net verfĂŒgbar ist

Semantic Internal Objects is an extension to MediaWiki that works in conjunction with Semantic MediaWiki. It provides two parser functions, '#set_internal' and '#set_internal_recurring_event', both of which are used to define "internal objects" within the Semantic MediaWiki system. These are compound types of information, sometimes known as 'n-ary relations', that involve more than one data value associated together. Semantic Internal Objects lets you define a two-dimensional table of information on a single page, with a call to #set_internal being used to store each row.

A simple example is in a cooking recipe: a recipe may call for 1 cup of flour, and the values "1", "cup" and "flour" must be encoded together - by themselves, the values are not meaningful (the third value has meaning, though not all of the meaning it could have).

Such compound information can also be stored via SMW itself. How and whether you should, though, depends on which version of SMW you're using:

  • For versions 1.5-1.7 of SMW, you definitely need Semantic Internal Objects to store this sort of data.
  • For SMW 1.8, you can use the #subobject call from SMW instead of SIO's #set_internal. However, if you want to store recurring events, SIO's #set_internal_recurring_event is superior in some ways to SMW's #set_recurring_event.
  • For SMW 1.9 and higher, the SMW function #set_recurring_event uses subobjects, which means that there is no longer any advantage, in terms of the data structure, to using the Semantic Internal Objects extension. However, the syntax of SIO's parser functions may still be preferable to that of SMW's corresponding functions.

Herunterladen

You can download the Semantic Internal Objects code directly via Git from the Wikimedia source code repository. From a command line, call the following:

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SemanticInternalObjects.git

The code can be viewed online, with the full history for each file, here.

Installation

To install this extension, create a 'SemanticInternalObjects' directory (either by extracting a compressed file or downloading via Git), and place this directory within the main MediaWiki 'extensions' directory. Then, in the file 'LocalSettings.php', somewhere below the inclusion of Semantic MediaWiki (both the main 'include_once' line and the 'enableSemantics' line), add the following line:

include_once "$IP/extensions/SemanticInternalObjects/SemanticInternalObjects.php" ;

Verwendung

The syntax of #set_internal is as follows:

{{#set_internal:object_to_page_property
|property1=value1
|property2=value2
...
}}

It is very important to note that the first argument is a property pointing from the object, to the page, and not the other way around! This is a bit counter-intuitive, but it makes meaningful querying possible. (To follow the recipe example above, the value of object_to_page_property could be "Part of recipe", but not "Has ingredient".)

A sample call to #set_internal would be:

{{#set_internal:Part of recipe
|Has quantity=1
|Has unit=cup
|Has ingredient=flour
}}

This call would be placed in a page for a recipe, and it would define an object that had an automatically-generated name; the name generated depends on which version of SMW is used. For SMW 1.7 and lower, internal objects in a page called "Carrot cake" would have names like "Carrot cake#001", "Carrot cake#002" etc. For SMW 1.8 and higher, such internal objects would each have the name "Carrot cake#" plus a string of random numbers and letters.

Every one of these properties, including the first one ("Part of recipe" in the example) needs to be defined on its own property page - and the first needs to be of type "Page".

It should be noted that #set_internal does not display anything to the screen; display of the values has to be handled separately (this can be done easily if the function is called from a template).

Querying internal objects

Internal objects, once stored, can be queried as if they were wiki pages. So the following query would show a table of all the recipes that contain more than 1/2 a cup of flour, and the number of cups they contain:

{{#ask:[[Part of recipe::+]][[Has ingredient::flour]][[Has unit::cup]][[Has quantity::>.5]]
|mainlabel=-
|? Part of recipe
|? Has quantity
}}

Note the "mainlabel=-" parameter in the query: that hides the names of the internal objects from users, since those names are confusing and basically meaningless.

Lists of values

You can have #set_internal store a list of values for a property, instead of just one. To do that, you just need to append "#list" to the property name, and separate the values by commas. For instance, to record, in a page called "United States", the names of all presidents and their vice-presidents, you could have calls like:

{{#set_internal:Is president of
|Has name=Ulysses S. Grant
|Has vice president#list=Schuyler Colfax, Henry Wilson
}}

Creating recurring events

The #set_recurring_event function in Semantic MediaWiki lets you set a series of date values for a single page, representing a recurring event. For SMW 1.9 and higher, this call works perfectly well. However, for earlier versions of Semantic MediaWiki, #set_recurring_event is sometimes not an ideal solution, because individual instances of the event can't be easily separated from one another. Instead, you can call #set_internal_recurring_event, which has a syntax that's a cross between #set_internal and #set_recurring_event, and defines a separate internal object for each instance of the event, with a different date for each. This allows for precise querying and display of only those event instances that fall within a certain date range.

The (abridged) syntax for #set_internal_recurring_event is:

{{#set_internal_recurring_event:object_to_page_property
...all parameters allowed by #set_recurring_event...
}}

Here is an example of such a call, on a page that defines a recurring event:

{{#set_internal_recurring_event:Is instance of
|property=Has date
|start=January 4, 2016
|end=June 8, 2017
|unit=week
|period=1
}}

You could then display a table of all the events that happened in a certain week, along with their date, with the following call:

{{#ask:[[Has date::>February 1, 2016]][[Has date::<February 7, 2016]]
|mainlabel=-
|?Is instance of
|?Has date
}}

Bugs and feature requests

You can use the Semantic MediaWiki mailing list, semediawiki-user, for questions, suggestions or bug reports about Semantic Internal Objects. If possible, please add "[SIO]" at the beginning of the subject line, to clarify the subject matter.

You can also send specific code patches to Yaron Koren, at yaron57 -at- gmail.com.

Autoren

Semantic Internal Objects was written by Yaron Koren, reachable at yaron57 -at- gmail.com. Important contributions were made by Jamey Wood and MWJames.

Semantic Internal Objects was initially funded by STAR Software (Shanghai) Co., Ltd., a member of the STAR Group.

Version history

Semantic Internal Objects is currently at version 0.8.2. See the entire version history.