Wikifunctions:Support for Wikidata content
| Abstract Wikipedia team staff primarily maintain this page's content. |
| General overviews |
|---|
| User-facing features |
| Back-end specifics |
Wikifunctions provides support for retrieving and using Wikidata content, including encyclopedic content contained primarily in Items and lexicographic content contained in Lexemes, Lexeme forms, and Lexeme senses. Since instances of these four content types can contain Statements, Wikifunctions also includes support for Statements and their components, including Properties, Statement ranks, Qualifiers, and (coming soon) References.
Documentation of Wikidata's lexicographic types can be found at d:Lexicographical data/Documentation, and documentation of the other Wikidata types can be found at Wikibase/DataModel.
Terminology note: On Wikidata, Item, Property, Lexeme, Lexeme form, and Lexeme sense are all types of entities, so we refer to these as the entity types.
Implemented support currently includes:
- Built-in types corresponding to the 5 entity types, Statement, and Statement rank
- A built-in type "Reference", which corresponds to Wikidata's ReferenceRecord type
- A built-in type "Claim" [ glossary ], which corresponds to Wikidata's type snak (Q86719099) [ glossary ], and is used in Wikifunctions' representation of qualifiers and references inside statements
- Built-in reference types corresponding to the 5 entity types
- Built-in fetch functions, for each of the entity types, which retrieve content from Wikidata and transform it into instances of the built-in types
- Built-in search functions, which provide methods for finding lexemes by their relations to other entities
- User interface components for selecting Wikidata content to be fetched, and for displaying the fetched content.
Terminology notes:
- We refer to the built-in types of (1) -- (3) as the “Wikidata types”, and the built-in types of (4) as the “Wikidata reference types”, but note that all of these are types on Wikifunctions for working with content from Wikidata. When we mention one of these types below, it will be underlined, and it will also be a link if it’s currently defined on Wikifunctions (e.g., Wikidata lexeme).
- To help keep things clear, when we mention a type in italics (such as Lexeme or Item) we are talking about a type that exists on Wikidata. For example, we will talk about the Wikidata lexeme type that’s been created on Wikifunctions, which corresponds to the Lexeme type on Wikidata.
- The reference types mentioned in (4) are not related to the "Reference" type mentioned in (2). (4) provides a way to refer to Wikidata entities using their identifiers, whereas (2) captures the sources that substantiate particular content.
This page describes each of the above areas of support. Everything described here is deployed and available, except as noted in a few places.
Wikidata types
The following types have been defined, with their structure corresponding closely to the structure of the corresponding types on wikidata:
- Wikidata lexeme
- Wikidata lexeme form
- Wikidata lexeme sense
- Wikidata statement
- Wikidata property
- Wikidata item
- Wikidata statement rank
- Wikidata reference
- Wikidata claim, which corresponds to Wikidata's Snak type
- Wikidata claim subtype, which captures the 3 types of Snaks on Wikidata
Instances of these types are never made persistent on Wikifunctions (except for the instances of Wikidata statement rank and Wikidata claim subtype). They are constructed on the fly, when needed, using content retrieved directly from Wikidata. Instances of the entity types carry within them the identifier of the Wikidata entity from which they were obtained.
Wikidata statement rank is an enumeration type which has only the 3 fixed instances preferred, normal, and deprecated.
Wikidata claim subtype is an enumeration type which has only the 3 fixed instances value, some value, and no value.
Additional background, motivation, and examples of the Wikidata types may be found on the types proposal discussion page (but please be aware that page is no longer active and isn't necessarily up-to-date in all details).
Example
An instance of Wikidata lexeme has these 7 parts:
- identity, with a value of type Wikidata lexeme reference
- lemmas, with a value of type Multilingual text
- language, with a value of type Natural language
- lexical category, with a value of type Wikidata item reference
- statements, whose value is a list of Wikidata statement
- senses, whose value is a list of Wikidata lexeme sense
- forms, whose value is a list of Wikidata lexeme form
Note, then, that each such instance contains instances of three other Wikidata types (Wikidata statement, Wikidata lexeme sense, and Wikidata lexeme form), and also two Wikidata reference types (which are discussed in the next section). Multilingual text and Natural language are multipurpose Wikifunctions’ types, not created specifically for handling Wikidata content.
The identity part stores the Wikidata identifier associated with the lexeme, and serves as a self-reference. For information about the content of each of the other parts, please see d:Lexicographical data/Documentation.
A specific instance, which has been fetched from L3435 on Wikidata, is shown in the appendix.
Status of Wikidata types
All these types are defined and available for use; there are no outstanding tasks directly related to them. They all have built-in equality functions. Each of the five entity types has a built-in fetch function, as described below, by which its instances can be directly fetched (retrieved from Wikidata and instantiated on Wikifunctions).
Notes about Wikidata statements
Statements appear inside of Wikidata items, properties, lexemes, lexeme forms, and lexeme senses. Each Wikidata statement imported from Wikidata contains seven parts:
- a subject (an entity reference, discussed below)
- a predicate (a property reference, discussed below)
- a value
- a rank (an instance of Wikidata statement rank)
- a list of qualifiers (each represented as a Wikidata claim)
- a list of Wikidata reference
- an instance of Wikidata claim subtype.
The value, (3), may be of several different Wikifunctions types, including:
- String
- Monolingual text
- Wikidata quantity
- Wikidata geo-coordinate
- Wikidata time
- one of the Wikidata reference types, discussed below.
Because Statements in Wikidata do not have public identifiers, in Wikifunctions Wikidata statement does not have a reference type or a fetch function. (These are described in more detail below.)
Wikidata reference types
The following reference types provide the means to refer to Wikidata entities without including the details of their content. Instances of these reference types contain only the Wikidata ID of an entity, as a Z6/String.
- Wikidata lexeme reference
- Wikidata lexeme form reference
- Wikidata lexeme sense reference
- Wikidata property reference
- Wikidata item reference
Example: a Wikidata item reference to the item Q1084 (which represents the concept noun on Wikidata) looks like the following. The right column shows the formal ZObject representation (in canonical form); the left column, for readability, shows the same content with English labels for each of the ZObject's elements. Wikifunctions’ ZObject representation is presented in Wikifunctions:Function model; we do not explain the details of the representation here.
{
"type": "Wikidata item reference",
"Wikidata item id": "Q1084"
}
|
{
"Z1K1": "Z6091",
"Z6091K1": "Q1084"
}
|
Example uses:
- Wikidata reference types are used with Wikidata fetch functions (see below).
- When entity IDs and Property IDs appear inside of Wikidata lexemes, Wikidata lexeme forms, Wikidata lexeme senses, or Wikidata statements, they appear as instances of the appropriate Wikidata reference types. For example, to indicate that Lexeme L3435 (“umbrella”) has lexical category noun (which has entity ID Q1084), the Wikidata lexeme for L3435 contains the Wikidata item reference shown above, in the Example.
Status of Wikidata reference types
Ready for use. No outstanding tasks directly related to these types.
Wikidata fetch functions
A fetch function is a built-in Wikifunctions function that takes an instance of one of the Wikidata reference types as its input argument. As noted above, each such instance contains the ID of a Wikidata entity. Given that, it retrieves the content of that entity from Wikidata and transforms it into an instance of the corresponding Wikidata type.
Example: If Fetch Wikidata lexeme is called with this instance of Wikidata lexeme reference:
{
"type": "Wikidata lexeme reference",
"Wikidata lexeme id": "L3435"
}
|
{
"Z1K1": "Z6095",
"Z6095K1": "L3435"
}
|
it will return the instance of Wikidata lexeme that is introduced in the Example subsection of the Wikidata types section above, and shown in greater detail in the Appendix.
Status of Wikidata fetch functions
A fetch function exists for each of the entity types on Wikifunctions:
To enable calling the fetch functions from the user interface, Wikifunctions provides selector components, which make it possible to select an entity to be fetched. There will eventually be a selector corresponding to each of the entity types (and thus, to each of the fetch functions). The next section provides more information about selector components.
Wikidata search functions
In addition to fetching content from Wikidata, it's also possible to search Wikidata content in various ways, using its APIs. Wikifunctions currently provides two built-in functions based on these search capabilities.
Function: Find lexemes for an item
- Argument types: Wikidata item reference, Wikidata property reference, Natural language
- Return value type: List of Wikidata lexeme reference
Wikidata captures useful relationships between lexeme senses (which represent the meanings of a lexeme) and items. These include:
- item for this sense, most often connecting a noun to a thing or a class of things in Wikidata
- predicate for, connecting a verb to an action or event
- demonym of, connecting a noun or adjective to a location, describing the people and things that live or are from that place.
Example 1. The three senses of the lexeme L18379/rose refer to the color, the flower, and the biological taxon. Each of these 3 senses is related to a different item, by means of a statement, in Wikidata, such as this (for the first sense):
- statement subject: L18379-S1/rose sense 1
- statement property: P5137/item for this sense
- statement value: Q533047/rose
Find lexemes for an item searches for lexemes that are related to a given item by a given property. (Even though the relationships exist between a lexeme sense and an item, Wikidata's API, and this function, return references to the lexeme(s) that contain the sense(s).)
Example 2: Calling Find lexemes for an item with Q533047/rose (the color), P5137/item for this sense, and Z1002/English returns a list containing the lexeme reference for L18379/rose. Calling the function with Q102231/rose (the flower) or with Q34687/Rosa (the biological taxon) as the first argument also returns the lexeme L18379/rose, because that lexeme is related (via its 3 senses) to all 3 of those items.
Example 3: Calling Find lexemes for an item with Q55/Netherlands, P6271/demonym of, and Z1002/English returns a list containing the Wikidata lexeme reference for L34519/Dutch.
For an example in which Find lexemes for an item is used in generating a natural language phrase, please see the Function of the Week section in Wikifunctions:Status updates/2025-02-26.
Function: Find lexemes for a Wikidata lexeme sense
- Argument types: Wikidata lexeme sense reference, Wikidata property reference, Natural language
- Return value type: List of Wikidata lexeme reference
Wikidata also captures useful relationships between lexemes senses and other lexeme senses, such as the relationships expressed using the property pertainym of, which links an adjective sense to a related noun sense (e.g. lunar → moon), or an adverb sense to a related adjective sense (e.g. slowly → slow). Find lexemes for a Wikidata lexeme sense searches for lexemes that are related to a given lexeme sense by a given property, such as pertainym of. (Even though the relationships exist between pairs of lexeme senses, Wikidata's API, and this function, return references to the lexeme(s) that contain the target sense(s).)
User interface
Selectors

Selectors make it possible, in Wikifunctions' user interface, to select an entity to be used. For example, when the user types a partial keyword in Wikifunctions' lexeme selector, the selector will query Wikidata for lexemes that match that partial keyword. (The search matches the partial keyword against the lemmas of all the lexemes on Wikidata.) It shows up to 10 of the current matches, and allows the user to pick one of them. It updates the matches list as more typing is done.
Example: Figure 1 shows the appearance of a lexeme selector, after typing in the 5 characters "goose". At this point the user is presented with 4 matching lexemes to choose from. For an example in which this lexeme selector is used in preparing a function call, please see the Function of the Week section in Wikifunctions:Status updates/2024-10-17. Note that the presence of a Wikidata selector is indicated by the Wikidata icon (with vertical bars in red, green, and blue).
Once a choice has been made by the user, the selector will generate the appropriate internal representation of the selected item, depending on context:
- an instance of the appropriate Wikidata reference type, if that's all that's needed, or
- a call to the appropriate fetch function, with an instance of the reference type as the argument passed to that call.
Selectors are primarily used when providing the arguments for a function call in the UI, and the called function provides the relevant context. If the user is specifying a value for an argument having a Wikidata reference type as its type, the selector will provide (1). In this case, no fetch is performed. If the argument in question has a Wikidata type as its type, the selector will provide (2), which will internally fetch the entire object and make it available to the called function.
Display elements

Wikifunctions also provides a simplified, compact view of Wikidata entities. This view is displayed in read pages and when viewing the output of a function call. This compact view displays the Wikidata icon followed by a word-form associated with the Wikidata entity (e.g., a lemma from a lexeme, representation from a lexeme form, or label from an entity), in the user's language if available. The word-form is linked to the Wikidata page from which the entity has been fetched.
Example: Figure 2 shows the compact view, below the word Result, of the Wikidata lexeme form for umbrellas (which is called the representation of the form). This is the initial appearance of the result of running a function that returns a lexeme form.

If there's a need to explore the entity and its details, it can be expanded using the right chevron button (which looks like '>') preceding the element. The expanded view allows the user to understand what kind of representation is being used for this entity. The representation might employ a Wikidata reference type, a function call to the appropriate Wikidata fetch function, or the entire entity instance returned by that function call. In any case, the user will be able to expand, explore and navigate through its content.
Example: Figure 3 shows the expanded view of the lexeme form for umbrellas, which results from clicking the chevron in Figure 2.
Here we see the presentation of the entire instance of Wikidata lexeme form.
Each of the form's nested components with a chevron (e.g., identity, lexeme, etc.), can be expanded for further exploration.
Status of UI components for Wikidata entity types
- Wikidata lexeme
- Display and selector: available
- Wikidata lexeme form
- Display and selector: available
- Wikidata lexeme sense
- Display and selector: date of release not yet determined
- Wikidata item
- Display and selector: available
- Wikidata property
- Display and selector: available
Limitations of UI components for Wikidata entity types
Visual discrimination. Currently the Wikifunctions UI is lacking in visual discrimination between the various Wikidata entity types:
- The selectors for the other entity types look very similar to that for Wikidata lexemes, shown in Figure 1. There is no explicit indication of which type is being selected.
- Workarounds: Usually one knows from context which type of thing is being selected. In addition, the content of the selection choices (in the drop-down list) varies depending on which type of thing is being selected. For example, in a lexeme selector each choice shows its lemma, language, and part of speech (as shown in Figure 1), whereas in a lexeme form selector each choice shows its word-form and grammatical features, along with information that identifies its containing lexeme.
- The compact views for the other entity types look the same as that for Wikidata lexemes, shown in Figure 2. (That is, they only show the Wikidata icon and a single word form.)
- Workaround: If it's not obvious from context, one can click the chevron to get the expanded view of the entity, which explicitly states its type, as shown in Figure 3.
Missing compact views. Because the display elements for Wikidata lexeme sense and Wikidata statement have not yet been fully deployed, the presentation of elements of these types can be rather space-consuming, and can detract from the readability of larger entities that contain them. This is especially true when a lexeme, lexeme form, or lexeme sense contains a sizable list of statements.
Mismatch in status. Even though the fetch function is available for Wikidata lexeme sense, the selector for that type is not yet available.
Appendix: an instance of Wikidata lexeme
This example is introduced in the Example subsection of the Wikidata types section. It shows a specific instance of Wikidata lexeme, which has been fetched from L3435 on Wikidata.
The right column shows the formal ZObject representation (in canonical form); the left column, for readability, shows the same content with English labels for each of the ZObject's elements. Wikifunctions’ ZObject representation is presented in Wikifunctions:Function model; we do not explain the details of the representation here.
The example has been shortened by omitting some content, as indicated by ellipses. For readability, it also omits the element type indication that normally appears in the first position of each list in canonical form.
{
"type": "Wikidata lexeme",
"identity": {
"type": "Wikidata lexeme reference",
"Wikidata lexeme id": "L3435"
},
"lemmas": {
"type": "Multilingual text",
"texts": [
{
"type": "Monolingual text",
"language": "English",
"text": "umbrella"
}
]
},
"language": "English",
"lexical category": {
"type": "Wikidata item reference",
/* Wikidata item for "noun": */
"Wikidata item id": "Q1084"
},
"statements": [
{
"type": "Wikidata statement",
"subject": {
"type": "Wikidata lexeme reference",
"Wikidata lexeme id": "L3435"
},
"predicate": {
"type": "Wikidata property reference",
/* Oxford English Dictionary ID */
"Wikidata property id": "P5275"
},
"value": "208852",
...
},
...
],
"senses": [
{
"type": "Wikidata lexeme sense",
"identity": {
"type": "Wikidata lexeme sense reference",
"Wikidata lexeme sense id": "L3435-S1"
},
"glosses": {
"type": "Multilingual text",
"texts": [
{
"type": "Monolingual text",
"language": "Spanish",
"text": "utensilio empleado para cubrirse de la lluvia"
}
]
},
"statements": [
...
]
}
],
"forms": [
{
"type": "Wikidata lexeme form",
"identity": {
"type": "Wikidata lexeme form reference",
"Wikidata lexeme form id": "L3435-F1"
},
"lexeme": {
"type": "Wikidata lexeme reference",
"Wikidata lexeme id": "L3435"
},
"representations": {
"type": "Multilingual text",
"texts": [
{
"type": "Monolingual text",
"language": "English",
"text": "umbrella"
}
]
},
"grammatical features": [
{
"type": "Wikidata item reference",
/* Wikidata item for "singular": */
"Wikidata item id": "Q110786"
}
],
"statements": [
/* (empty list) */
]
},
...
]
}
|
{
"Z1K1": "Z6005",
"Z6005K1": {
"Z1K1": "Z6095",
"Z6095K1": "L3435"
},
"Z6005K2": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "umbrella"
}
]
},
"Z6005K3": "Z1002",
"Z6005K4": {
"Z1K1": "Z6091",
"Z6091K1": "Q1084"
},
"Z6005K5": [
{
"Z1K1": "Z6003",
"Z6003K1": {
"Z1K1": "Z6095",
"Z6095K1": "L3435"
},
"Z6003K2": {
"Z1K1": "Z6092",
"Z6092K1": "P5275"
},
"Z6003K3": "208852",
...
},
...
],
"Z6005K6": [
{
"Z1K1": "Z6006",
"Z6006K1": {
"Z1K1": "Z6096",
"Z6096K1": "L3435-S1"
},
"Z6006K2": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1003",
"Z11K2": "utensilio empleado para cubrirse de la lluvia"
}
]
},
"Z6006K3": [
...
]
}
],
"Z6005K7": [
{
"Z1K1": "Z6004",
"Z6004K1": {
"Z1K1": "Z6094",
"Z6094K1": "L3435-F1"
},
"Z6004K2": {
"Z1K1": "Z6095",
"Z6095K1": "L3435"
},
"Z6004K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "umbrella"
}
]
},
"Z6004K4": [
{
"Z1K1": "Z6091",
"Z6091K1": "Q110786"
}
],
"Z6004K5": [
]
},
...
]
}
|