扩展:WikibaseMediaInfo

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:WikibaseMediaInfo and the translation is 10% complete.

Other languages:
English • ‎dansk • ‎español • ‎français • ‎italiano • ‎العربية • ‎مصرى • ‎中文 • ‎日本語
MediaWiki扩展手册
OOjs UI icon advanced.svg
WikibaseMediaInfo
发布状态: 测试
MediaInfo Entity Page.png
描述 Wikibase extension to manage structured metadata of media files
作者 维基数据团队
最新版本 持续更新
MediaWiki master
PHP 5.5.9+
数据更新
许可协议 GNU General Public License 2.0 or later
下载
readme
翻译WikibaseMediaInfo扩展
检查使用和版本矩阵。
问题 开放的工作 · 报告错误

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

The extension hooks into the File Page. It stores supplemental metadata (captions and depicts statements) about the file in a MediaInfo Entity. The user can view, create, edit, and delete this data.

Requirements


Installation

  • Ensure CirrusSearch, Wikibase (client and repo) and WikibaseCirrusSearch are set up properly.
  • 下载文件,并将其放置在您extensions/文件夹中的WikibaseMediaInfo目录内。
  • 只有從git安裝才运行Composer来安装PHP依赖,通过发行composer install --no-dev至扩展目录。 (参见T173141了解潜在问题。)
  • 将下列代码放置在您的LocalSettings.php的底部:
    wfLoadExtension( 'WikibaseMediaInfo' );
    
  • 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。
  • Add configuration.

MediaInfo UI

MediaInfo entities are shown on, and can be edited from, their associated File page and while uploading a file via UploadWizard.

There are separate sections in the UI for editing captions and statements.

An editing interface for is always shown for default properties (defaults are defined in config). On live commons depicts is the only default property - users are encouraged to say what is depicted by an image. Statements with other properties can be added by the user at will.

Glossary

MediaInfo Entity

A Wikibase entity that contains structured data about media files. It is stored in a slot on a File page and consists of

  • an ID in the form Mxxx, where xxx is the id of the associated wiki page
  • any number of captions (one per language)
  • any number of statements

(Note: if there is no caption or statement data then the entity is not stored in the database - in this case it is known as a ‘virtual entity’)

Caption

A short piece of text describing a media file, plus its language. Used to provide a short description of the file (the same as ‘labels’ in wikibase).

Statement

A single fact about a media file consisting of a key-value pair such as Licence=CC-By-SA or Depicts=Dog.

Keys are always a property. Values can be any wikibase datatype, but for now only item values are supported by the UI.

Note that normally in wikibase what we are describing as a 'statement' here is known as a 'claim', and that a wikibase 'statement' means a claim PLUS a documentary reference. Because we don't typically have documentary references for descriptions of files, 'statement' and 'claim' are used interchangeably in MediaInfo.

Property

A property is a property of a file that can have a value - for example ‘depicts’ (what an image is a picture of), ‘resolution’, ‘created by’, ‘license’. Each property has a unique id in wikibase in the form Pxxx such as P123.

Item

An item is a concept, topic, or object with an id - for example on Wikidata the CC0 licence is Q6938433, physics is Q413 and the planet Earth is Q2. Each item has a unique id in wikibase in the form Qxxx such as Q123.

Qualifier

A qualifier is a secondary statement that modifies the primary statement. 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)’.

Search

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’.

Searching for claims/statements

Searching for claims/statements happens via WikibaseCirrusSearch keywords, for details see: Help:WikibaseCirrusSearch

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 opening_text field
  • Claims are stored in the format propertyID=value as array elements in the statement_keywords field using the wikibase property ID (and item id, if value is an item) - e.g. ‘depicts house cat’ is stored as P180=Q146
  • Claims with qualifiers are stored in the statement_keywords field along with their qualifiers in the format propertyID=value[qualifierPropertyID=qualifierValue]. 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 P180=Q12418[P518=Q13217555]
  • 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 P180=Q12418 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 statement_quantity field in the format propertyID=value|quantity, eg. ‘depicts human, quantity 1’ is stored as P180=Q5|1.

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 ($wgWBRepoSettings['searchIndexPropertiesExclude']) AND either its property ID is in a configurable list of property IDs that should be indexed ($wgWBRepoSettings['searchIndexProperties']) ORits property type is in a configurable list of property types that should be indexed ($wgWBRepoSettings['searchIndexTypes'])

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 ($wgWBRepoSettings['searchIndexQualifierPropertiesForQuantity']).

Configuration

Extension configuration variables are sets of key-value pairs. They are documented in more detail in WikibaseMediaInfo/extension.json. All config variables are added toLocalSettings.php.

The following config options are available for this extension:

Config (in LocalSettings.php)

  • $wgMediaInfoProperties Default wikibase properties that will always be shown, allowing users to add/edit/delete values for them, on the File page/UploadWizard, regardless or not they already have a value. On live commons this is the 'depicts' property, as we want to encourage users to fill in values for this in particular. Value is an array of key-value pairs connecting a label name to an existing wikibase database id.
   ['depicts' => 'P180']
  • $wgMediaInfoHelpUrls Urls for pages where a user can learn more about particular wikibase properties - if there is a help url for a particular property then there will be a "learn more" link for that property that leads to the url from the config.
   ['P180' => 'https://www.wikidata.org/wiki/Property:P180']
  • $wgMediaInfoEnableOtherStatements Set to true to allow users to add statements with properties that are not specified in $wgMediaInfoProperties via the UI on File page/UploadWizard. ATM only properties whose values are wikibase items are supported, properties with data-type 'string', 'geo-coordinate', 'quantity' etc will be supported at some stage in the future.
  • $wgDepictsQualifierProperties If $wgMediaInfoEnableOtherStatements is false then properties for qualifiers for statements are limited to those properties defined in this variable. Value is an array of key-value pairs connecting a label name to an existing wikibase database id. If $wgMediaInfoEnableOtherStatements is true then this config variable is ignored.
   ['features' =>  'P2',     
     'color' =>  'P3',    
     'wears' =>  'P4',    
     'part' =>  'P5',    
     'inscription' =>  'P6',    
     'symbolizes' =>  'P7',     
     'position' =>  'P8',     
     'quantity' =>  'P9',];

Other Config

  • $wgUploadWizardConfig['wikibase']['enabled'] Enables MediaInfo data on UploadWizard when set to true.

Development

More information about the development and testing approaches being used in this extension's development can be found here.

Tests

PHPUnit tests are located in tests/phpunit. You can run tests not requiring the MediaWiki framework (located in tests/phpunit/composer) by running composer test. This command also runs code style checks using PHPCS.

Tests relying on the MediaWiki framework (located in tests/phpunit/mediawiki) must by run using MediaWiki core’s phpunit.php endpoint.

Javascript tests are located in tests/node-qunit. You can run tests from a terminal with npm run test:unit. Node version 6.x should be used.


See also