Extension:WikibaseMediaInfo/ja

WikibaseMediaInfo is an extension to Wikibase adding a MediaInfo entity type for handling structured data for multimedia files.

The extension hooks into a file description page. It stores supplemental meta data about the file in a MediaInfo entity. The entity's data is displayed on, and is editable from, the File page.

インストール

 * In order to use this extension, Wikibase must be installed first. See the basic installation instructions if Wikibase has not been installed yet on your wiki.

Other extensions
This extension requires CirrusSearch.

MediaInfo data can be added to a file as it is being uploaded via UploadWizard by setting  to   in config.

MediaInfo entities
A MediaInfo entity is a Wikibase entity stored in a slot on a File page and consists of:


 * an ID in the form, where   is the id of the associated wiki page
 * any number of captions
 * any number of claims

A caption is a short piece of text plus its language, intended to provide a short description of the file (the same as 'labels' in wikibase).

A claim is a single fact about the file, consisting of a property and a value e.g.  or

(Note that if there is no caption or claim data then the entity is not stored in the database - in this case the entity is known as a 'virtual entity')

More about claims
The idea of a claim comes from wikibase (for a more detailed explanation see the wikibase data model). A claim consists of a property and value, plus possibly a qualifier.

Property
A property in wikibase describes the data type of a claim, and can be thought of as a category of data about a file. It has a unique id in the form  (where xxx is a number). Examples of file properties are 'depicts' (what an image is a picture of), 'resolution', 'created by', 'license'.

Items
The value in a claim will very often be a wikibase 'item', which is a concept, topic, or object represented by a unique id in the form  (where xxx is a number). For example on Wikidata the planet Earth is  and the CC0 licence is.

Qualifiers
A qualifier is a secondary claim that modifies the primary claim. For example an image might have a tree in the foreground and the sea in the background, in which case it could have 2 'depicts' claims associated with it - 'depicts=tree(applies to part=foreground)' and 'depicts=sea(applies to part=background)'.

How claims are stored
Claims are stored simply as strings, using the property ids and item ids as appropriate. Using Property and Item ids from Wikidata as an example, an image depicting a black cat could have the claim 'depicts=cat(color=black)' which would be stored as

MediaInfo UI
MediaInfo entities are shown on, and can be edited from, their associated File page. Captions and claims are shown separately, and claims are split into 'depicts' claims and 'other' claims - this is because for images a 'depicts' claim can be thought of as a special kind of topical "tag", similar to tags on WordPress or flickr.

Search by caption
Users can search for files by their MediaInfo captions just as they would search for anything else. For example if a user uploads a picture of the Eiffel Tower, and enters ‘Tour Eiffel’ (French) and ‘Eiffel Tower’ (English) as multilingual file captions, the picture is findable by another user searching for either ‘Eiffel Tower’ or ‘Tour Eiffel’.

Search by claim
Note - examples below all use Property and Item ids from Wikidata.

Searching for a single claim
To search for a claim, use the  keyword. For example, files with the statement ‘depicts Mont Blanc’ can be found by searching for. Searches for statements can also use qualifiers. For example, to search for images with Mont Blanc (Q583) in the background (Q13217555), a user could use:

Where P518 is the property ‘applies to part’, used as a qualifier

Searching across multiple claims at once
Claims can be combined using a logical OR in a single search keyword using the pipe character. For example files depicting a cat (Q146) OR a dog (Q144) can be found using

Claims can be combined using a logical AND by using 2 separate search keywords. For example, files depicting a cat AND a dog can be found using:

Searching for claims with quantity qualifiers
To search for a claim with a quantity, use the  keyword. For example, files that depict 2 humans (Q5) can be found using:

The comparison operators,  ,   and   can also be used, so a search for files depicting more than 2 humans can be found using:

Searching for a range of values
Ranges can be searched for using two  keywords at once. For example, to find files depicting between 2 and 5 humans (Q5) use:

Search implementation
When the File page is saved, the following MediaInfo data is written to the Elasticsearch index (all examples use Wikidata Property and Item ids):


 * captions data in every language is stored in the  field
 * claims are stored in the format  as array elements in the   field using the wikibase property ID (and item id, if value is an item)
 * e.g. ‘depicts house cat’ is stored as


 * claims with qualifiers are stored in the  field along with their qualifiers in the format  . For example, the Mona Lisa painting (Wikidata item Q12418) depicts a sky (Q13217555) in the background (Wikidata property P518). If we arrange this data in a Wikibase claim, it would be: ‘depicts sky, applies to part background’, which would be stored as
 * Note that claims with qualifiers are also stored without the qualifier, to increase their findability. So, for example, if someone entered the above claim-plus-qualifier, the claim  is also stored, so that someone can find the file by searching for ‘depicts sky’ alone, as well as by searching for ‘depicts sky, applies to part background’.


 * claims data with qualifiers where the qualifier value is a quantity is stored in the  field in the format , eg. ‘depicts human, quantity 1’ is stored as.

Note that not all claims are stored. A claim will be indexed in ElasticSearch only if ALL of the following conditions are true:


 * the claim has a real value (i.e. its value is not ‘no value’ or ‘unknown value’) AND
 * we know how to process its value for indexing. More value processors may be added in future, but currently we require the claim’s value to be either a Q item ID, a string (alphanumeric), or a quantity (numeric) AND
 * the claims's Wikidata property ID is NOT in a configurable list of excluded IDs AND
 * either
 * its property ID is in a configurable list of property IDs that should be indexed OR
 * its property type is in a configurable list of property types that should be indexed

Note that for a claim's quantities to be stored, the claim must meet all the criteria above AND the property ID for the quantity qualifier must be present in a configurable list of property IDs.

関連項目

 * Structured Data project on Wikimedia Commons