Template:TemplateMapping: Difference between revisions
(* '''header''': If value '0' is given, don't print the header. Useful for conditional mappings.) |
No edit summary |
||
Line 42: | Line 42: | ||
* '''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 | * '''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. | ||
* '''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. | ||
=== | === Example1: One Template === | ||
The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows: | The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows: | ||
Line 56: | Line 54: | ||
</pre> | </pre> | ||
=== | === Example2: Multiple Different Templates === | ||
If a Wikipedia page contains multiple infobox templates, all relevant 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. | E.g. the templates Infobox Automobile and Infobox Automobile engine often occur on the same wiki page. | ||
Line 72: | Line 70: | ||
</pre> | </pre> | ||
The first template infobox on a page defines the type of this page, while further infobox templates | 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: | The mapping for the template Infobox Automobile to the ontology class Automobile can be defined as follows: | ||
Line 82: | Line 79: | ||
</pre> | </pre> | ||
The mapping for the template Infobox Automobile engine to the ontology class AutomobileEngine can be defined as follows: | 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> | <pre> | ||
{{TemplateMapping | {{TemplateMapping | ||
Line 90: | Line 88: | ||
}} | }} | ||
</pre> | </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> | </noinclude> |
Revision as of 03:09, 25 February 2015
{{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.
- 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.