professional-wiki / semantic-wikibase
MediaWiki extension that makes Wikibase data available in Semantic MediaWiki
Fund package maintenance!
JeroenDeDauw
Installs: 336
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 7
Forks: 4
Open Issues: 3
Type:mediawiki-extension
Requires
- php: >=7.4
- composer/installers: ^1.0.1
Requires (Dev)
- phpstan/phpstan: dev-master
- vimeo/psalm: dev-master
This package is auto-updated.
Last update: 2024-12-10 15:58:25 UTC
README
MediaWiki extension that makes Wikibase data available in Semantic MediaWiki.
Semantic Wikibase was created by Professional.Wiki with help from Frans AL van der Horst.
Demo
Platform requirements
- PHP 7.4 or later
- MediaWiki 1.35.x
- Semantic MediaWiki 3.2.x
- Wikibase Repository branch: REL1_35
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
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