Template:TableMapping: Difference between revisions

From DBpedia Mappings
Jump to navigationJump to search
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{DisclaimerTableMapping}}
{|class="wikitable"
{|class="wikitable"
! style="text-align:left" colspan="2" | Table Mapping ([[Writing_Mappings/Tables|<span style="cursor:help;">help</span>]])
! style="text-align:left" colspan="2" | Table Mapping <small>([[Template:TableMapping|<span style="cursor:help;">help</span>]])</small>
|-
|-
| width="15%" | map to class
| width="15%" | map to class
| width="85%" | {{#if:{{{mapToClass|}}}|[[OntologyClass:{{{mapToClass}}}]]|<span style="color:red">please define mapToClass</span>}}
| width="85%" | {{#if:{{{mapToClass|}}}|[[OntologyClass:{{{mapToClass}}}|{{{mapToClass}}}]]|<span style="color:red">please define mapToClass</span>}}
|-
|-
| corresponding class
| corresponding class
| {{#if:{{{correspondingClass|}}}|[[OntologyClass:{{{correspondingClass}}}]]}}
| {{#if:{{{correspondingClass|}}}|[[OntologyClass:{{{correspondingClass}}}|{{{correspondingClass}}}]]}}
|-
|-
| corresponding property
| corresponding property
| {{#if:{{{correspondingProperty|}}}|[[OntologyProperty:{{{correspondingProperty}}}]]}}
| {{#if:{{{correspondingProperty|}}}|[[OntologyProperty:{{{correspondingProperty}}}|{{{correspondingProperty}}}]]}}
|-
|-
| keywords
| keywords
Line 17: Line 19:
| {{#if:{{{header|}}}|{{{header}}}}}
| {{#if:{{{header|}}}|{{{header}}}}}
|}
|}
<blockquote><h2>Mappings</h2>
{{#if:{{{mappings|}}}|{{{mappings}}}}}
</blockquote></includeonly>
<noinclude>Table mappings should be added to the ''Mapping'' namespace, using the ''Table'' prefix.
If a table mapping is defined, all rows of the table are mapped to instances of an ontology class, all of its columns are be mapped to ontology properties.
A table mapping applies to a table if a set of keywords occurs in the table header.


<h2>Mappings</h2>
=== Usage ===
{{#if:{{{mappings|}}}|{{{mappings}}}}}
 
<pre>
{{TableMapping
| mapToClass =
| correspondingClass =
| correspondingProperty =
| header                =
| keywords =
| mappings              =
}}
</pre>
 
=== Meanings ===
* '''mapToClass''': Table rows are mapped to ontology classes. The template parameter mapToClass allows one DBpedia ontology class as a value.
* '''correspondingClass''', '''correspondingProperty''': If an instance of type correspondingClass is found in the same section as the table, it will be connected to the instances extracted from the table rows by correspondingProperty.
* '''keywords''': Keywords define mandatory table column headers or parts of them. Keywords can be separated by semicolons meaning they have to occur in different column headers. Alternatives of keywords can be separated by colons.
* '''header''': Lists all mapped table column headers, separated by semicolons. Each column definition can contain alternative definitions, separated by colons. If the column is defined by several keywords, the keywords have to be separated by & in the order of their appearance.
* '''mappings''': Mappings map table columns to ontology properties, they have to be defined by using the same templates as in mappings on [[Template:TemplateMapping]]. A separate mapping for each alternative column header definition has to be specified.
 
=== Example ===
 
All rows of a table shall be mapped to instances of an ontology class, all of its columns shall be mapped to ontology properties.
 
The rows of tables with the columns Engine Name, Type, Engine code, and Top speed are mapped to instances of the ontology class Automobile Engine, while the columns are mapped to the corresponding ontology properties. If an infobox that is mapped to the ontology class Automobile is in the same section as the table, the instances generated for the table rows are connected to the instance generated from the infobox by the ontology property MeanOfTransportation/engine.
 
<pre>
{{TableMapping
| mapToClass            = AutomobileEngine
| correspondingClass    = Automobile
| correspondingProperty = MeanOfTransportation/engine
| keywords              = engine; speed
| header                = speed; code; name, engine ; type
| mappings              =
{{PropertyMapping | templateProperty = engine | ontologyProperty = AutomobileEngine/name }}
{{PropertyMapping | templateProperty = type | ontologyProperty = AutomobileEngine/type }}
{{PropertyMapping | templateProperty = code | ontologyProperty = AutomobileEngine/code }}
{{PropertyMapping | templateProperty = speed | ontologyProperty = AutomobileEngine/speed | unit = kilometerPerHour }}
}}
</pre>
 
TODO: improve the description of commas and semicolons and ampersands used in TableMapping. Apparently it takes '''two''' PhDs to understand it.
 
Unfortunately this powerful feature is not used much: just 1 mapping as of Feb 2015:
* [[Mapping_en:Table/Automobile]]
 
</noinclude>

Latest revision as of 12:09, 25 February 2015

Table mappings should be added to the Mapping namespace, using the Table prefix.

If a table mapping is defined, all rows of the table are mapped to instances of an ontology class, all of its columns are be mapped to ontology properties. A table mapping applies to a table if a set of keywords occurs in the table header.

Usage

{{TableMapping
| mapToClass 		=
| correspondingClass	=
| correspondingProperty =
| header                =
| keywords 		=
| mappings              =
}}

Meanings

  • mapToClass: Table rows are mapped to ontology classes. The template parameter mapToClass allows one DBpedia ontology class as a value.
  • correspondingClass, correspondingProperty: If an instance of type correspondingClass is found in the same section as the table, it will be connected to the instances extracted from the table rows by correspondingProperty.
  • keywords: Keywords define mandatory table column headers or parts of them. Keywords can be separated by semicolons meaning they have to occur in different column headers. Alternatives of keywords can be separated by colons.
  • header: Lists all mapped table column headers, separated by semicolons. Each column definition can contain alternative definitions, separated by colons. If the column is defined by several keywords, the keywords have to be separated by & in the order of their appearance.
  • mappings: Mappings map table columns to ontology properties, they have to be defined by using the same templates as in mappings on Template:TemplateMapping. A separate mapping for each alternative column header definition has to be specified.

Example

All rows of a table shall be mapped to instances of an ontology class, all of its columns shall be mapped to ontology properties.

The rows of tables with the columns Engine Name, Type, Engine code, and Top speed are mapped to instances of the ontology class Automobile Engine, while the columns are mapped to the corresponding ontology properties. If an infobox that is mapped to the ontology class Automobile is in the same section as the table, the instances generated for the table rows are connected to the instance generated from the infobox by the ontology property MeanOfTransportation/engine.

{{TableMapping 
| mapToClass            = AutomobileEngine
| correspondingClass    = Automobile
| correspondingProperty = MeanOfTransportation/engine
| keywords              = engine; speed
| header                = speed; code; name, engine ; type
| mappings              = 
{{PropertyMapping | templateProperty = engine | ontologyProperty = AutomobileEngine/name }}
{{PropertyMapping | templateProperty = type | ontologyProperty = AutomobileEngine/type }}
{{PropertyMapping | templateProperty = code | ontologyProperty = AutomobileEngine/code }}
{{PropertyMapping | templateProperty = speed | ontologyProperty = AutomobileEngine/speed | unit = kilometerPerHour }}
}}

TODO: improve the description of commas and semicolons and ampersands used in TableMapping. Apparently it takes two PhDs to understand it.

Unfortunately this powerful feature is not used much: just 1 mapping as of Feb 2015: