Template:TemplateMapping

From DBpedia Mappings
Jump to navigationJump to search

{{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.