Template:ConditionalMapping: Difference between revisions

From Mediawiki1
Jump to navigationJump to search
No edit summary
No edit summary
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<includeonly>== ConditionalMapping ==
<includeonly>{{DisclaimerMapping}}
 
<h3>Conditions</h3>
{{{cases}}}
{{{cases}}}


=== Default Mappings ===
<h3>Default Mappings</h3>
{{{defaultMappings}}}
<blockquote>{{{defaultMappings}}}</blockquote>
</includeonly>
</includeonly>
<noinclude>'''<nowiki>{{ConditionalMapping}}</nowiki>''' maps templates to ontology classes. In comparison to a [[Template:TemplateMapping|TemplateMapping]] the mapping can be defined depending on template properties and their values.
=== Usage ===
<pre>
{{ConditionalMapping
| cases          =
| defaultMappings =
}}
</pre>
=== 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 [[Template:Condition|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 ===
<pre>
{{ConditionalMapping
| cases =
  {{Condition
  ...
  }}
  ...
  {{Condition
  | operator = otherwise
  ...
  }}
| defaultMappings =
  {{PropertyMapping
  ...
  }}
  ...
}}
</pre>
=== Example of Mapping Gender ===
On [http://bg.wikipedia.org 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 [http://mappings.dbpedia.org/index.php?title=Special%3ASearch&search=наставка&go=Go 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:
<pre>
{{ 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 }}
  ...
}}
</pre>
We can test the extraction on two presidents:
* [http://mappings.dbpedia.org/server/extraction/bg/extract?title=Барак+Обама&revid=&format=turtle-triples&extractors=custom Barack Obama], male
* [http://mappings.dbpedia.org/server/extraction/bg/extract?title=Дилма+Русев&revid=&format=turtle-triples&extractors=custom Dilma Rousseff], female. (She is of Bulgarian descent but has lost her suffix "a" since she never lived in Bulgaria)
</noinclude>

Latest revision as of 18:57, 22 December 2014

{{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)