Template:ConditionalMapping

From DBpedia Mappings
Jump to: navigation, search

{{ConditionalMapping}} maps templates to ontology classes. In comparison to a TemplateMapping the mapping can be defined depending on template properties and their values.

Usage

{{ConditionalMapping
| cases           =
| defaultMappings =
}}

Meanings

  • cases: Cases define conditions on template properties and their values and can change the default mapping, like the ontology class the template is mapped to and the ontology properties the template properties are mapped to. The cases template property should contain a list of Condition templates.
  • defaultMappings: The default mapping defines the default template property mappings using PropertyMapping etc.. The default ontology class the template is mapped to has to be defined by an otherwise condition.

Example

{{ConditionalMapping
| cases =
  {{Condition 
  ... 
  }}

  ...

  {{Condition
  | operator = otherwise
  ...
  }}

| defaultMappings =
  {{PropertyMapping
  ... 
  }}
  ...
}}

Example of Mapping Gender

On bg.wikipedia.org, females have a field наставка="а". "Наставка" means "suffix", and you may know that many Bulgarian and Russian female surnames end in "a". Weirdly (but consistently), the same value is used for foreign female names like София Лорен. So if the field is present it's a Female, otherwise it's a Male.

Since this mapping wiki has infobox mappings but not property mappings, we have to do the same for all infoboxes using "наставка" (currently 9). Lets's do it for the mapping of President (Mapping_bg:Президент_инфо). Since templates must be nested like this:

 ConditionalMapping
   Condition
     TemplateMapping
        ConstantMapping

we end up repeating mapToClass=OfficeHolder twice, whereas defaultMappings includes all common property mappings:

{{ ConditionalMapping | cases =
  {{ Condition
    | templateProperty = наставка
    | operator = isSet
    | mapping = {{ TemplateMapping | mapToClass = OfficeHolder | mappings =
      {{ConstantMapping | ontologyProperty = gender | value = http://dbpedia.org/resource/Female}}}}}}
  {{ Condition
    | operator = otherwise
    | mapping = {{ TemplateMapping | mapToClass = OfficeHolder | mappings =
      {{ConstantMapping | ontologyProperty = gender | value = http://dbpedia.org/resource/Male}}}}}}

| defaultMappings =
  {{ PropertyMapping | templateProperty = име | ontologyProperty = foaf:name }}
  {{ PropertyMapping | templateProperty = роден-дата | ontologyProperty = birthDate }}
  ...
}}

We can test the extraction on two presidents:

  • Barack Obama, male
  • Dilma Rousseff, female. (She is of Bulgarian descent but has lost her suffix "a" since she never lived in Bulgaria)