Template:TemplateMapping: Difference between revisions

From Mediawiki1
Jump to navigationJump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
<td width="400px">{{#if:{{{mapToClass|}}}|[[OntologyClass:{{{mapToClass}}}|{{{mapToClass}}}]]|<span style="color:red">please define mapToClass</span>}}</td>
<td width="400px">{{#if:{{{mapToClass|}}}|[[OntologyClass:{{{mapToClass}}}|{{{mapToClass}}}]]|<span style="color:red">please define mapToClass</span>}}</td>
</tr>
</tr>
{{#if:{{{correspondingClass|}}}|
{{#if:{{{correspondingClass|}}} | <tr>
<tr>
<td>corresponding class</td>
<td>corresponding class</td>
<td>[[OntologyClass:{{{correspondingClass}}}|{{{correspondingClass}}}]]</td>
<td>[[OntologyClass:{{{correspondingClass}}}|{{{correspondingClass}}}]]</td>
</tr>
</tr> [[Category:Template Mappings with correspondingClass]] }}
{{#ifeq: {{lc:{{{nocat|false}}} }} | false | [[Category:Template Mappings with correspondingClass]] | <!-- Category suppressed --> }}
{{#if:{{{correspondingProperty|}}} | <tr>
}}
{{#if:{{{correspondingProperty|}}}|
<tr>
<td>corresponding property</td>
<td>corresponding property</td>
<td>[[OntologyProperty:{{{correspondingProperty}}}|{{{correspondingProperty}}}]]</td>
<td>[[OntologyProperty:{{{correspondingProperty}}}|{{{correspondingProperty}}}]]</td>
</tr>
</tr> [[Category:Template Mappings with correspondingProperty]] }}
{{#ifeq: {{lc:{{{nocat|false}}} }} | false | [[Category:Template Mappings with correspondingProperty]] | <!-- Category suppressed --> }}
}}
</table>
</table>
{{#if:{{{mappings|}}}|
{{#if:{{{mappings|}}}|
<h2>Mappings</h2>
<h2>Mappings</h2>
{{{mappings}}} }}</includeonly>
{{{mappings}}}  
}}</includeonly>
<noinclude>'''<nowiki>{{TemplateMapping}}</nowiki>''' maps templates to ontology classes.
<noinclude>'''<nowiki>{{TemplateMapping}}</nowiki>''' maps templates to ontology classes.


Line 44: Line 39:
* '''header''': If value '0' is given, don't print the header. Useful for conditional mappings.
* '''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.
* '''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.
* '''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]],  
[[:Category:Template Mappings with correspondingClass]], [[: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.
* '''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.



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.