Template:TemplateMapping: Difference between revisions

From DBpedia Mappings
Jump to navigationJump to search
(Created page with '{|class="wikitable" | map to class | [[OntologyClass:{{{mapToClass}}}]] |- | corresponding class | [[OntologyClass:{{{correspondingClass}}}]] |- | corresponding property | [[Onto...')
 
No edit summary
 
(38 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{|class="wikitable"
<includeonly>{{#ifeq:{{{header|}}}|0||{{DisclaimerMapping}}}}<!-- show disclaimer only if header != 0 -->
| map to class
 
| [[OntologyClass:{{{mapToClass}}}]]
<table class="wikitable">
|-
<tr><th style="text-align:left" colspan="2"> Template Mapping <small>([[Template:TemplateMapping|<span style="cursor:help;">help</span>]])</small>
| corresponding class
</th></tr>
| [[OntologyClass:{{{correspondingClass}}}]]
<tr>
|-
<td width="150px">map to class</td>
| corresponding property
<td width="400px">{{#if:{{{mapToClass|}}}|[[OntologyClass:{{{mapToClass}}}|{{{mapToClass}}}]]|<span style="color:red">please define mapToClass</span>}}</td>
| [[OntologyProperty:{{{correspondingProperty}}}]]
</tr>
|-
{{#if:{{{correspondingClass|}}} | <tr>
! colspan="2"|mappings
<td>corresponding class</td>
{{{mappings}}}
<td>[[OntologyClass:{{{correspondingClass}}}|{{{correspondingClass}}}]]</td>
|}
</tr> [[Category:Template Mappings with correspondingClass]] }}
{{#if:{{{correspondingProperty|}}} | <tr>
<td>corresponding property</td>
<td>[[OntologyProperty:{{{correspondingProperty}}}|{{{correspondingProperty}}}]]</td>
</tr> [[Category:Template Mappings with correspondingProperty]] }}
</table>
{{#if:{{{mappings|}}}|
<h2>Mappings</h2>
{{{mappings}}}
}}</includeonly>
<noinclude>'''<nowiki>{{TemplateMapping}}</nowiki>''' maps templates to ontology classes.
 
=== Usage ===
 
<pre>
{{TemplateMapping
| header                =
| mapToClass            =
| correspondingClass    =
| correspondingProperty =
| mappings              =
}}
</pre>
 
=== Meanings ===
 
* '''header''': If value '0' is given, don't print the header. Useful for conditional mappings.
* '''mapToClass''': Templates are mapped to ontology classes. The template parameter mapToClass allows one DBpedia ontology class as a value.
* '''correspondingClass''', '''correspondingProperty''': In the case that several templates are used on the same page (for instance Automobile and Automobile Generation), the instance resulting from the second and subsequent templates (eg Automobile Generation) can be connected to the instance of the first template (Automobile) using a corresponding property. Thus, if an instance of type correspondingClass is found on the same page, it will be connected to the instances of the mapped template by correspondingProperty. see [[:Category:Template Mappings with correspondingClass]] or [[:Category:Template Mappings with correspondingProperty]],
* '''mappings''': Mappings map template properties to ontology properties, they have to be defined by using PropertyMapping or IntermediateNodeMapping. Custom, user-defined, mappings like the GeocoordinatesMapping can also be defined.
 
=== Example1: One Template ===
 
The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows:
<pre>
{{TemplateMapping
| mapToClass = Automobile
}}
</pre>
 
=== Example2: Multiple Different Templates ===
If a Wikipedia page contains multiple infobox templates, all relevant templates are processed.
 
E.g. the templates Infobox Automobile and Infobox Automobile engine often occur on the same wiki page.
<pre>
{{ Infobox Automobile
| name = Volkswagen Golf
...
}}
 
{{ Infobox Automobile engine
| name = Volkswagen air cooled engine
...
}}
</pre>
 
The first template infobox on a page defines the type of this page, while further infobox templates are extracted as instances with their own types and URIs.
 
The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows:
<pre>
{{TemplateMapping
| mapToClass = Automobile
}}
</pre>
 
The mapping for the template Infobox Automobile engine to the ontology class AutomobileEngine can be defined as follows.
The correspondence of the main class (Automobile) to the secondary class (AutomobileEngine) is preserved by defining a correspondingClass and correspondingProperty on the  AutomobileEngine instance:
<pre>
{{TemplateMapping
| mapToClass            = AutomobileEngine
| correspondingClass    = Automobile
| correspondingProperty = Automobile/engine
}}
</pre>
 
=== Example3: Multiple of the Same Template ===
Consider the Wikipedia page [https://en.wikipedia.org/w/index.php?title=Volkswagen_Golf&action=edit Volkswagen Golf].
It contains multiple instances of the *same* template Automobile.
The first describes a generic car, and the rest are specific generations (variantOf) it: Mk1 to Mk7
<pre>
{{Infobox automobile
| name = Volkswagen Golf
| production = 1974–present
}}
{{Infobox automobile
| name = Volkswagen Golf Mk1 (17)
| production = 1974–1983
}}
...
{{Infobox automobile
| name = Volkswagen Golf Mk7 (5G)
| production = January 2012–present
}}
</pre>
 
The mapping goes like this:
<pre>
{{TemplateMapping
|mapToClass = Automobile
|correspondingClass = Automobile
|correspondingProperty = variantOf
|mappings =
{{PropertyMapping | templateProperty = name | ontologyProperty = foaf:name }}
{{DateIntervalMapping | templateProperty = production
| startDateOntologyProperty = productionStartDate
| endDateOntologyProperty = productionEndDate}}
}}
</pre>
This is quite close to the previous Example, but creates secondary nodes having the *same* class as the primary node.
The secondary node URLs are made from the "name" property.
 
The mapped [http://dbpedia.org/resource/Volkswagen_Golf dbr:Volkswagen_Golf] data is like this:
<pre>
dbr:Volkswagen_Golf a dbo:Automobile;
  foaf:name "Volkswagen Golf";
  dbo:productionStartYear "1974-01-01".
 
dbr:Volkswagen_Golf__Mk1_17__1 a dbo:Automobile;
  dbo:variantOf dbr:Volkswagen_Golf;
  foaf:name "Volkswagen Golf Mk1 (17)";
  dbo:productionStartYear "1974-01-01";
  dbo:productionEndYear "1983-01-01".
 
...
 
dbr:Volkswagen_Golf__Mk7_5G__1 a dbo:Automobile;
  dbo:variantOf dbr:Volkswagen_Golf;
  foaf:name "Volkswagen Golf Mk7 (5G)";
  dbo:productionStartYear "2013-01-01".
</pre>
 
If you've grokked the above Volkswagen Golf mapping, it's time to relax with some [[Volkswagen Golf Jokes]].
 
</noinclude>

Latest revision as of 14:32, 8 June 2016

{{TemplateMapping}} maps templates to ontology classes.

Usage

{{TemplateMapping
| header                =
| mapToClass            =
| correspondingClass    =
| correspondingProperty =
| mappings              =
}}

Meanings

  • header: If value '0' is given, don't print the header. Useful for conditional mappings.
  • mapToClass: Templates are mapped to ontology classes. The template parameter mapToClass allows one DBpedia ontology class as a value.
  • correspondingClass, correspondingProperty: In the case that several templates are used on the same page (for instance Automobile and Automobile Generation), the instance resulting from the second and subsequent templates (eg Automobile Generation) can be connected to the instance of the first template (Automobile) using a corresponding property. Thus, if an instance of type correspondingClass is found on the same page, it will be connected to the instances of the mapped template by correspondingProperty. see Category:Template Mappings with correspondingClass or Category:Template Mappings with correspondingProperty,
  • mappings: Mappings map template properties to ontology properties, they have to be defined by using PropertyMapping or IntermediateNodeMapping. Custom, user-defined, mappings like the GeocoordinatesMapping can also be defined.

Example1: One Template

The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows:

{{TemplateMapping
| mapToClass = Automobile
}}

Example2: Multiple Different Templates

If a Wikipedia page contains multiple infobox templates, all relevant templates are processed.

E.g. the templates Infobox Automobile and Infobox Automobile engine often occur on the same wiki page.

{{ Infobox Automobile
| name = Volkswagen Golf
...
}}

{{ Infobox Automobile engine
| name = Volkswagen air cooled engine
...
}}

The first template infobox on a page defines the type of this page, while further infobox templates are extracted as instances with their own types and URIs.

The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows:

{{TemplateMapping
| mapToClass = Automobile
}}

The mapping for the template Infobox Automobile engine to the ontology class AutomobileEngine can be defined as follows. The correspondence of the main class (Automobile) to the secondary class (AutomobileEngine) is preserved by defining a correspondingClass and correspondingProperty on the AutomobileEngine instance:

{{TemplateMapping
| mapToClass            = AutomobileEngine
| correspondingClass    = Automobile
| correspondingProperty = Automobile/engine
}}

Example3: Multiple of the Same Template

Consider the Wikipedia page Volkswagen Golf. It contains multiple instances of the *same* template Automobile. The first describes a generic car, and the rest are specific generations (variantOf) it: Mk1 to Mk7

{{Infobox automobile
| name = Volkswagen Golf
| production = 1974–present
}}
{{Infobox automobile
| name = Volkswagen Golf Mk1 (17)
| production = 1974–1983
}}
...
{{Infobox automobile
| name = Volkswagen Golf Mk7 (5G)
| production = January 2012–present
}}

The mapping goes like this:

{{TemplateMapping
|mapToClass = Automobile
|correspondingClass = Automobile
|correspondingProperty = variantOf
|mappings =
	{{PropertyMapping | templateProperty = name | ontologyProperty = foaf:name }}
	{{DateIntervalMapping | templateProperty = production
		| startDateOntologyProperty = productionStartDate
		| endDateOntologyProperty = productionEndDate}}
}}

This is quite close to the previous Example, but creates secondary nodes having the *same* class as the primary node. The secondary node URLs are made from the "name" property.

The mapped dbr:Volkswagen_Golf data is like this:

dbr:Volkswagen_Golf a dbo:Automobile;
  foaf:name "Volkswagen Golf";
  dbo:productionStartYear "1974-01-01".

dbr:Volkswagen_Golf__Mk1_17__1 a dbo:Automobile;
  dbo:variantOf dbr:Volkswagen_Golf;
  foaf:name "Volkswagen Golf Mk1 (17)";
  dbo:productionStartYear "1974-01-01";
  dbo:productionEndYear "1983-01-01".

...

dbr:Volkswagen_Golf__Mk7_5G__1 a dbo:Automobile;
  dbo:variantOf dbr:Volkswagen_Golf;
  foaf:name "Volkswagen Golf Mk7 (5G)";
  dbo:productionStartYear "2013-01-01".

If you've grokked the above Volkswagen Golf mapping, it's time to relax with some Volkswagen Golf Jokes.