Template:ConditionalMapping: Difference between revisions

From Mediawiki1
Jump to navigationJump to search
No edit summary
No edit summary
 
Line 47: Line 47:


=== Example of Mapping Gender ===
=== 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.
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 the 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:
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
   ConditionalMapping
Line 80: Line 80:
We can test the extraction on two presidents:
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 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 she has lost her suffix "a" because she never lived in Bulgaria)
* [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>
</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)