Writing Mappings/Templates: Difference between revisions
ChrisBizer (talk | contribs) |
AnjaJentzsch (talk | contribs) |
||
Line 1: | Line 1: | ||
== How to map a Wikipedia template == | == How to map a Wikipedia template == | ||
* Get the encoded template page name from Wikipedia. | * Get the encoded template page name from Wikipedia. Make sure that the template is no redirect page. | ||
** ''Example'': For the Wikipedia template [http://en.wikipedia.org/wiki/Template:Infobox_musical_artist Infobox musical artist] use <code>Infobox_musical_artist</code>. | ** ''Example'': For the Wikipedia template [http://en.wikipedia.org/wiki/Template:Infobox_musical_artist Infobox musical artist] use <code>Infobox_musical_artist</code>. | ||
* Create a wiki page in this wiki in the Mapping namespace, using the encoded Wikipedia template page name. | * Create a wiki page in this wiki in the Mapping namespace, using the encoded Wikipedia template page name. |
Revision as of 14:23, 11 March 2010
How to map a Wikipedia template
- Get the encoded template page name from Wikipedia. Make sure that the template is no redirect page.
- Example: For the Wikipedia template Infobox musical artist use
Infobox_musical_artist
.
- Example: For the Wikipedia template Infobox musical artist use
- Create a wiki page in this wiki in the Mapping namespace, using the encoded Wikipedia template page name.
- Example: For the Wikipedia template Infobox musical artist create the wiki page Mapping:Infobox_musical_artist.
- Decide on the ontology class you would like to map the template to.
- Example: Ontology classes belong to the Class namespace. A list of existing ontology classes can be found via the sidebar (Ontology Classes).
- Write a Template:TemplateMapping or Template:ConditionalMapping to map the Wikipedia template to an ontology class and save it to the created wiki page in the Mapping namespace.
The full documentation on writing mappings can be found via the DBpedia SVN Repository.
Template to Ontology Mapping Language
When mapping a Wikipedia template to an ontology class and mapping template properties to ontology properties for this template, users will have to edit the corresponding template documentation page in MediaWiki.
The following templates cover the template to ontology schema mapping:
- TemplateMapping Mapping from Wikipedia templates to ontology classes.
- PropertyMapping Mapping from Wikipedia template properties to ontology properties.
- IntermediateNodeMapping For extracting multiple values from a single property it is necessary to introduce an intermediate node. The IntermediateNodeMapping allows to express mappings from Wikipedia template properties to ontology properties on an additional node and to connect the additional node to the mapped instance.
- ConditionalMapping
- Custom mappings
- To cover specific, more complex mapping cases, the DBpedia extraction framework can be extended with custom parsers which have to implement a specific PHP interface. These parsers are invoked using custom mappings.
Template Mapping
The TemplateMapping template offers the following template parameters:
- 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 different templates are used on the same page (for instance Automobile and Automobile Generation), the instance resulting from the second grade template (Automobile Generation) can be connected to the instance of the first grade 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.
Property Mapping
The PropertyMapping template offers the following template parameters:
- ontologyProperty
- A template property to ontology property mapping should list one ontology property.
- templateProperty
- A template property to ontology property mapping should list one template property which is to be mapped.
- unit
- If a template property containing a numerical value and a unit is mapped, the unit has to be defined. If a template property has no default unit defined, e.g. its values can contain different units of the same dimension, the dimension has to be defined for usability as well as validation reasons. Possible dimensions are Length or Mass.
Intermediate Node Mapping
The IntermediateNodeMapping template offers the following template parameters:
- nodeClass, correspondingProperty
- Creates an additional node of the type nodeClass, which will be connected to the instance extracted from template by the property provided by correspondingProperty.
- mappings
- Mappings map template properties to ontology properties, they have to be defined by using PropertyMapping, IntermediateNodeMapping, or a CustomMapping.
Conditional Mapping
Custom Mappings
For specific tasks, such as extracting durations or calculating a geo-location-ID based on multiple properties, we allow the DBpedia extraction framework to be extended with custom value parsers and allow the definition of DBpedia custom mapping templates. The name of a custom mapping template has to be equal to the name of the corresponding DBpedia parser class. As examples of custom mapping, we define the DateIntervalMapping and the GeocoordinatesMapping.
The DateIntervalMapping template provides an exact mapping from start and end dates of a template property value to ontology properties. It offers the following template parameters:
- templateProperty
- startDateOntologyProperty
- endDateOntologyProperty
The GeocoordinatesMapping template offers the following template parameters:
- coordinates
- Use the coordinates parameter if the geo coordinates are covered by one template property.
- latitude
- longitude
- latitudeDirection
- latitudeDegrees
- latitudeMinutes
- latitudeSeconds
- longitudeDirection
- longitudeDegrees
- longitudeMinutes
- longitudeSeconds
- ontologyProperty
The CombineDateMapping template offers the following template parameters:
- templateProperty1
- unit1
- templateProperty2
- unit2
- templateProperty3
- unit3
- ontologyProperty
The CalculateMapping template offers the following template parameters:
- operation
- templateProperty1
- unit1
- templateProperty2
- unit2
- ontologyProperty