Template:TemplateMapping: Difference between revisions
AnjaJentzsch (talk | contribs) No edit summary |
No edit summary |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<includeonly>{{ | <includeonly>{{#ifeq:{{{header|}}}|0||{{DisclaimerMapping}}}}<!-- show disclaimer only if header != 0 --> | ||
<table class="wikitable"> | <table class="wikitable"> | ||
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]] }} | ||
}} | {{#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]] }} | ||
}} | |||
</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 30: | Line 27: | ||
<pre> | <pre> | ||
{{TemplateMapping | {{TemplateMapping | ||
| header = | |||
| mapToClass = | | mapToClass = | ||
| correspondingClass = | | correspondingClass = | ||
Line 39: | Line 37: | ||
=== Meanings === | === 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. | * '''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. 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. | * '''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 54: | Line 51: | ||
</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 70: | Line 67: | ||
</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 80: | Line 76: | ||
</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 88: | Line 85: | ||
}} | }} | ||
</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> |
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.