WikibaseLexeme
MediaWiki WikibaseLexeme extension
|
WikibaseLexeme provides a Lua Scribunto interface that implements functions to access data from the Wikibase repository, if the Wikibase Client configuration enables allowDataTransclusion
and $wgLexemeEnableDataTransclusion
. Lua modules and wiki templates can invoke these functions.
Changes to the WikibaseLexeme Lua interface are subject to the Stable Interface Policy.
Most aspects of the data are accessed as methods on a loaded entity. For Forms and Senses, you can either load the Form or Sense directly by its ID from mw.wikibase.getEntity()
, or load the surrounding Lexeme and then get the Form or Sense from it via entity:getForms()
or entity:getSenses()
.
Accessing data of Lexemes is expensive. Loading entities doesn't count as expensive if the same entity is loaded twice during a module run. However, due to restrictions in the caching, if more than 14 other entities are loaded inbetween, the entity must be fetched again, which then counts as expensive.
mw.wikibase.lexeme
has some general Lua functionality for working with Wikibase Lexeme data.
mw.wikibase.lexeme.splitLexemeId( id )
Split a Lexeme, Sense or Form ID into the Lexeme ID part and (if present) Sense or Form ID part. Returns two strings for Sense or Form IDs, one string for Lexeme IDs and nil otherwise.
An example call might look like this:
mw.wikibase.lexeme.entity.lexeme
has methods for accessing data of a loaded Lexeme entity. It is typically not used directly – mw.wikibase.getEntity( lexemeId )
returns a table on which you can call the following methods, as well as the methods from mw.wikibase.entity.
entity:getLemmas()
Gets the lemma(s) of this Lexeme, as a list of tables where each table has the lemma text as the first element and the lemma language as the second.
An example call might look like this:
entity:getLemma()
entity:getLemma( languageCode )
Gets the lemma of this Lexeme in the given language, or in the content language if no language is given. Returns the lemma and its language as two strings if the lexeme has a lemma in this language, or nil otherwise. (Language fallbacks are not applied.)
An example call might look like this:
entity:getLanguage()
Gets the Item ID of the language of this Lexeme.
An example call might look like this:
entity:getLexicalCategory()
Gets the Item ID of the lexical category of this Lexeme.
An example call might look like this:
entity:getForms()
Get the Forms of this Lexeme, as a list of Form entities.
An example call might look like this:
entity:getSenses()
Get the Senses of this Lexeme, as a list of Sense entities.
An example call might look like this:
mw.wikibase.lexeme.entity.form
has methods for accessing data of a loaded Form entity. It is typically not used directly – mw.wikibase.getEntity( formId )
returns a table on which you can call the following methods, as well as the methods from mw.wikibase.entity, while lexeme:getForms() returns a list of such tables.
entity:getRepresentations()
Gets the representation(s) of this Form, as a list of tables where each table has the representation text as the first element and the representation language as the second.
An example call might look like this:
entity:getRepresentation()
entity:getRepresentation( languageCode )
Gets the representation of this Form in the given language, or in the content language if no language is given. Returns the representation and its language as two strings if the Form has a representation in this language, or nil otherwise. (Language fallbacks are not applied.)
An example call might look like this:
entity:getGrammaticalFeatures()
Gets the grammatical features of this Form as a list of item IDs.
An example call might look like this:
entity:hasGrammaticalFeature( itemId )
Tests whether this Form has the given grammatical feature or not.
An example call might look like this:
mw.wikibase.lexeme.entity.sense
has methods for accessing data of a loaded Sense entity. It is typically not used directly – mw.wikibase.getEntity( senseId )
returns a table on which you can call the following methods, as well as the methods from mw.wikibase.entity, while lexeme:getSenses() returns a list of such tables.
entity:getGlosses()
Gets the gloss(es) of this Sense, as a list of tables where each table has the gloss text as the first element and the gloss language as the second.
An example call might look like this:
entity:getGloss()
entity:getGloss( languageCode )
Gets the gloss of this Sense in the given language, or in the content language if no language is given. Returns the gloss and its language as two strings if the Sense has a gloss in this language, or nil otherwise. (Language fallbacks are not applied.)
An example call might look like this: