Extension:WikibaseLexeme/Lua

WikibaseLexeme provides a Lua Scribunto interface that implements functions to access data from the Wikibase repository, if the Wikibase Client configuration enables  and. Lua modules and wiki templates can invoke these functions.

This is not a stable interface yet, though we hope to declare it stable soon.

Aspects of the data can be accessed either directly or by loading the whole entity. The following table summarizes the most common functions:


 * 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 general Lua functionality for working with Wikibase Lexeme data.

mw.wikibase.lexeme.getLemmas
Gets the lemma(s) of the Lexeme with this ID, as a list of tables where each table has the lemma text as the first element and the lemma language as the second. Returns nil if there is no such Lexeme or the ID is invalid.

An example call might look like this:

mw.wikibase.lexeme.getLanguage
Gets the Item ID of the language of the Lexeme with this ID. Returns nil if there is no such Lexeme or the ID is invalid.

An example call might look like this:

mw.wikibase.lexeme.getLexicalCategory
Gets the Item ID of the lexical category of the Lexeme with this ID. Returns nil if there is no such Lexeme or the ID is invalid.

An example call might look like this:

mw.wikibase.lexeme.splitLexemeId
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 –  returns a table on which you can call the following methods, as well as the methods from mw.wikibase.entity.

mw.wikibase.lexeme.entity.lexeme:getLemmas
Gets the lemma(s) of the Lexeme with this ID, as a list of tables where each table has the lemma text as the first element and the lemma language as the second. Returns nil if there is no such Lexeme or the ID is invalid.

An example call might look like this:

mw.wikibase.lexeme.entity.lexeme:getLanguage
Gets the Item ID of the language of this Lexeme.

An example call might look like this:

mw.wikibase.lexeme.entity.lexeme:getLexicalCategory
Gets the Item ID of the lexical category of this Lexeme.

An example call might look like this:

mw.wikibase.lexeme.entity.lexeme:getForms
Get the Forms of this Lexeme, as a list of Form entities.

An example call might look like this:

mw.wikibase.lexeme.entity.lexeme: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 – 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.

mw.wikibase.lexeme.entity.form: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:

mw.wikibase.lexeme.entity.form:getGrammaticalFeatures
Gets the grammatical features of this Form as a list of item IDs.

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

mw.wikibase.lexeme.entity.sense: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: