扩展:WikibaseMediaInfo
Support level: Pending The support level for this extension is currently under review. The Reader Growth Team is the maintainer of last resort for the time being. |
发行状态: 稳定版 |
|
|---|---|
| 描述 | Wikibase扩展程序,用于管理媒体文件的结构化元数据 |
| 作者 | 结构化数据团队 |
| 最新版本 | 持续更新 |
| MediaWiki | master |
| 数据库更改 | 是 |
| 许可协议 | GNU通用公眾授權條款2.0或更新版本 |
| 下載 | readme |
|
|
|
|
|
|
| 翻译WikibaseMediaInfo扩展 | |
| 問題 | 开启的任务 · 报告错误 |
WikibaseMediaInfo是Wikibase的一个扩展,它添加了一个MediaInfo实体,用于处理有关多媒体文件的结构化数据。
该扩展程序会集成到文件页面中。 它将文件的补充元数据(包括说明和‘描绘’陈述)存储在MediaInfo实体中。 用户可以查看、创建、编辑和删除这些数据。
需求
- UniversalLanguageSelector(通用语言选择器)
- CirrusSearch
- Wikibase (Client and Repository)
- WikibaseCirrusSearch
安裝
- 请确保已安装并正确配置以下扩展程序:CirrusSearch、Wikibase(客户端和存储库)以及WikibaseCirrusSearch。
- 下载文件,并解压
WikibaseMediaInfo文件夹到extensions/目录中。
开发者和代码贡献人员应改从Git安装此扩展,输入:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseMediaInfo
- 只有是從Git安裝的才需运行Composer来安装PHP依赖,通过发行
composer install --no-dev至扩展的目录。 (参见T173141了解潜在问题。) - 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'WikibaseMediaInfo' );
- 請运行更新脚本,它将自动创建此扩展所必须的数据库表。
- 根据需要进行配置.
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
MediaInfo UI
MediaInfo 实体会显示在其关联的文件页面上,并且可以在该页面以及通过上传向导上传文件时进行编辑。
There are separate sections in the UI for editing captions and statements.
An editing interface is always shown for default properties (defaults are defined in config). On live Commons, depicts is the only default property — users are encouraged to describe what an image depicts. Statements with other properties can be added by the user at will.
术语表
MediaInfo实体
一个包含有关媒体文件结构化数据的Wikibase实体。 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
- 任意数量的标题(每种语言一个)
- 任意数量的陈述
标题
一段简短的文字描述媒体文件及其语言。 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.
Strictly, a wikibase 'statement' means a key-value pair (a 'claim') plus a rank (preferred, normal, or deprecated) and zero or more documentary references.
We don't typically have documentary references for descriptions of files, and all statements have a normal rank by default, so in MediaInfo, we prefer to use the term 'statement' instead of 'claim'.
Property
A property is a file's property 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 license 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.
限定符
限定词是修饰主要陈述的次要陈述。例如,一张图片的前景可能有一棵树,背景是大海,在这种情况下,它可以有两个与之相关的“描述”断言——“描述=树(适用部分=前景)”和“描述=大海(适用部分=背景)”。
搜索
以标题搜索
用户可以像搜索其他内容一样,通过MediaInfo提供的文件描述信息来搜索文件。例如,如果用户上传了一张埃菲尔铁塔的照片,并输入“Tour Eiffel”(法语)和“Eiffel Tower”(英语)作为多语言文件描述信息,那么其他用户就可以通过搜索“Eiffel Tower”或“Tour Eiffel”找到这张照片。
搜索断言/陈述
可以通过WikibaseCirrusSearch关键词搜索断言/陈述;详情请参见: Help:WikibaseCirrusSearch
搜索功能实现
文件页面保存后,以下MediaInfo数据将被写入Elasticsearch索引(所有示例均使用Wikidata属性和项目ID):
- 所有语言的标题数据都存储在
opening_text字段中。 - 断言以
propertyID=value格式存储在statement_keywords字段的数组元素中,其中使用Wikibase属性ID(如果值为数据项,则还包括项目ID)。 - ,例如:‘描绘家猫’被存储为P180=Q146 - 带有限定词的断言会连同其限定词一起存储在
statement_keywords字段中,格式为propertyID=value[qualifierPropertyID=qualifierValue]。例如,《蒙娜丽莎》这幅画(维基数据项Q12418)的背景(维基数据属性P518)描绘了天空(Q13217555)。如果我们将这些数据整理成一条Wikibase断言,它将是:“描绘天空,适用于部分背景”,其存储为P180=Q12418[P518=Q13217555]。 - 请注意,带有限定词的描述也会以不带限定词的形式存储,以提高其可查找性。因此,例如,如果有人输入了上述带有限定词的描述,那么描述“描绘天空”也会被存储,这样用户就可以仅通过搜索“描绘天空”来找到该文件,也可以通过搜索“描绘天空,适用于背景部分”来找到该文件。
- 包含限定符且限定符值为数量的断言数据存储在
statement_quantity字段中,格式为propertyID=value|quantity,例如,“描述人类,数量为1”存储为P180=Q5|1。
请注意,并非所有断言都会被存储。只有满足以下所有条件,断言才会在ElasticSearch中建立索引:
- 该断言具有实际值(即其取值既非‘无值’也非‘未知值’)且
- 我们知道如何处理其值以进行索引。未来可能会添加更多值处理器,但目前,我们要求断言的值必须是Q项ID、字符串(字母数字)或数量(数字),且
- 该断言的Wikidata属性ID不在可配置的排除ID列表中 (
$wgWBRepoSettings[ 'searchIndexPropertiesExclude' ]) 且其属性ID在应被索引的属性ID可配置列表中 ($wgWBRepoSettings[ 'searchIndexProperties' ])或 其属性类型在应被索引的属性类型可配置列表中($wgWBRepoSettings[ 'searchIndexTypes' ])
请注意,要存储断言的数量信息,断言必须满足上述所有条件,并且数量限定符的属性ID必须存在于可配置的属性ID列表($wgWBRepoSettings[ 'searchIndexQualifierPropertiesForQuantity' ])中。
MediaSearch搜索配置文件
现在,(仅)在NS_FILE命名空间中进行搜索时,结构化数据(标题和陈述)也会包含在默认搜索配置文件中。
搜索词例如“狗”也会包含那些图片说明(用户语言)中包含“狗”的文件,或者包含陈述P180=Q144(描述=狗)的文件。
The Extension: WikibaseMediaInfo/MediaSearch subpage provides a more elaborate (technical) writeup of the MediaSearch search profile.
配置
扩展配置变量是一组键值对。
They are documented in more detail in WikibaseMediaInfo/extension.json.
All config variables are added toLocalSettings.php.
此扩展程序提供以下配置选项:
Config (in LocalSettings.php)
$wgMediaInfoPropertiesDefault 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. This is the depicts (P180) property on live Commons, 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']
$wgMediaInfoHelpUrlsURLs 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']
Other Config
$wgUploadWizardConfig['wikibase']['enabled']Enables MediaInfo data on UploadWizard when set totrue.
开发
测试
PHPUnit tests are in tests/phpunit. You can run tests not requiring the MediaWiki framework (located in tests/phpunit/composer) by running composer test.
此命令还会使用PHPCS运行代码风格检查。
依赖于MediaWiki框架(位于tests/phpunit/mediawiki)的测试必须使用MediaWiki核心的composer phpunit:entrypoint端点运行。
JavaScript测试位于tests/node-qunit。
您可以通过终端运行npm run test:unit来执行测试。
应使用Node 6.x版本。
参阅
- 维基共享资源上的结构化数据项目
- 热门Wikibase扩展程序 — 精选的Wikibase关键扩展程序列表
| 此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
| 此扩展在以下wiki农场/托管网站和/或软件包中提供: |
- Extensions maintained by Reader Teams/zh
- Extensions maintained by Reader Growth/zh
- Extensions maintained by Reader Teams - Level Pending/zh
- Stable extensions/zh
- Extensions with invalid or missing type/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ArticleUndelete extensions/zh
- BeforePageDisplay extensions/zh
- CirrusSearchAddQueryFeatures extensions/zh
- CirrusSearchProfileService extensions/zh
- CirrusSearchRegisterFullTextQueryClassifiers extensions/zh
- GetEntityByLinkedTitleLookup extensions/zh
- GetEntityContentModelForTitle extensions/zh
- GetPreferences extensions/zh
- MediaWikiServices extensions/zh
- MultiContentSave extensions/zh
- ParserOutputPostCacheTransform extensions/zh
- RevisionUndeleted extensions/zh
- ScribuntoExternalLibraries extensions/zh
- SearchDataForIndex2 extensions/zh
- SidebarBeforeOutput extensions/zh
- WikibaseClientEntityTypes extensions/zh
- WikibaseRepoEntityNamespaces extensions/zh
- WikibaseRepoEntityTypes extensions/zh
- All extensions/zh
- Extensions requiring Composer with git/zh
- Extensions used on Wikimedia/zh
- Extensions included in Miraheze/zh
- Wikibase extensions/zh
