定制 professional-wiki/semantic-wikibase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

professional-wiki/semantic-wikibase

Composer 安装命令:

composer require professional-wiki/semantic-wikibase

包简介

MediaWiki extension that makes Wikibase data available in Semantic MediaWiki

README 文档

README

MediaWiki extension that makes Wikibase data available in Semantic MediaWiki.

Semantic Wikibase was created by Wikibase developers at Professional Wiki with help from Frans AL van der Horst.

Demo

Platform requirements

Installation

First install MediaWiki, Semantic MediaWiki and Wikibase Repository.

The recommended way to install Semantic Wikibase is using Composer with MediaWiki's built-in support for Composer.

On the commandline, go to your wikis root directory. Then run these two commands:

COMPOSER=composer.local.json composer require --no-update professional-wiki/semantic-wikibase:*
composer update professional-wiki/semantic-wikibase --no-dev -o

Then enable the extension by adding the following to the bottom of your wikis LocalSettings.php file:

wfLoadExtension( 'SemanticWikibase' );

You can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser.

As a final step you need to configure the property namespaces. See the configuration section.

Translated data

Data part of Wikibase Items and properties gets translated to Semantic MediaWiki property value pairs.

Labels, descriptions, IDs, etc

Translated data in the form Wikibase datamodel element => SMW property name (SMW property type)

  • EntityId => Wikibase ID (Text)
  • Labels => Wikibase label (Monolingual text)
  • Descriptions => Wikibase description (Monolingual text)
  • Aliases => Wikibase alias (Monolingual text)

Statements

When a statement is translated, only the value of the "main snak" is stored in SMW.

The SMW property name is the ID of the Wikibase property, for instance P42. The label of the Wikibase property gets added as alias. This means both [[P42::+]] and [[Capital city::+]] are valid in SMW queries.

Deprecated statements are never translated. Normal statements are not translated if there are preferred statements. The SMW property type is based on the Wikibase property type. Only statements with a supported property type are translated.

Supported property types

Wikibase name (en) SMW name (en) Wikibase id SMW id
Commons media file Text commonsMedia _txt
External identifier External identifier external-id _eid
Geographic coordinates Geographic coordinates globe-coordinate _geo
Item Page wikibase-item _wpg
Monolingual text Monolingual text monolingualtext _mlt_rec
Point in time Date time _dat
Property Page wikibase-property _wpg
Quantity Subobject (Page + Record) quantity _wpg + _rec
String Text string _txt
URL URL url _uri

Currently not supported types:

  • Entity Schema (entity-schema)
  • Geographic shape (geo-shape)
  • Tabular Data (tabular-data)

Configuration

You can configure Semantic Wikibase via LocalSettings.php.

Property namespaces

This is the only required configuration for setting up Semantic Wikibase.

Wikibase and Semantic MediaWiki both add a Property namespace called "Property". This results in a conflict which can be resolved by renaming either the Wikibase property namespace or the Semantic MediaWiki property namespace.

Renaming the Wikibase property namespace:

$wgExtraNamespaces[WB_NS_PROPERTY] = 'WikibaseProperty';
$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'WikibaseProperty_talk';

Renaming the SMW property namespace:

$wgExtensionFunctions[] = function() {
    $GLOBALS['wgExtraNamespaces'][SMW_NS_PROPERTY] = 'SemanticProperty';
    $GLOBALS['wgExtraNamespaces'][SMW_NS_PROPERTY_TALK] = 'SemanticProperty_talk';
};

You can choose what to rename these namespaces to. They do not need to be WikibaseProperty and/or SemanticProperty. As long as they are not the same, Semantic Wikibase will work.

You will likely need to set these extra permissions to avoid getting errors when creating new items or properties:

$wgGroupPermissions['user']['item-create'] = true;
$wgGroupPermissions['user']['property-create'] = true;

Property label language

The language used for translation of property labels defaults to the wiki language ($wgLanguageCode).

This means that if your wiki language is English, and you have a property P1 with Dutch label "lokatie" and English label "location", the name of the property in Semantic MediaWiki will be "location".

You can specify a language different from your wiki language should be used. This is done with the $wgSemanticWikibaseLanguage setting. With the below example, the label for P1 would be "lokatie":

$wgSemanticWikibaseLanguage = 'nl';

Disabling translation for an entity type / namespace

$smwgNamespacesWithSemanticLinks[WB_NS_ITEM] = false;
$smwgNamespacesWithSemanticLinks[WB_NS_PROPERTY] = false;

Enhancement ideas

Data translation:

  • Ability to whitelist or blacklist entities from being translated
  • Ability to whitelist or blacklist statements from being translated
  • Translation of qualifiers, references, statement rank and other non-main-snak data
  • Support for Entities other than Items and Properties
  • Translation of Item sitelinks

Properties:

  • Detection and possibly prevention of property name conflicts between Wikibase and SMW
  • (Multilingual) descriptions of Wikibase properties on SMW property pages
  • Grouping of Wikibase properties on Special:Browse

Professional.Wiki provides commercial MediaWiki development, Wikibase development, and managed wiki hosting.

Release notes

Version 0.1

Released on September 3, 2020

professional-wiki/semantic-wikibase 适用场景与选型建议

professional-wiki/semantic-wikibase 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 368 次下载、GitHub Stars 达 18, 最近一次更新时间为 2020 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wiki」 「Semantic Web」 「mediawiki」 「wikibase」 「wikidata」 「SMW」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 professional-wiki/semantic-wikibase 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 professional-wiki/semantic-wikibase 我们能提供哪些服务?
定制开发 / 二次开发

基于 professional-wiki/semantic-wikibase 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 368
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 5
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2020-07-10