Wikifunctions:Support for Wikidata content
![]() | Abstract Wikipedia team staff primarily maintain this page's content. |
General overviews |
---|
User-facing features |
Back-end specifics |
Starting in early October, 2024, Wikifunctions has been adding support for retrieving and using Wikidata content, with a primary focus on lexicographic content (Lexemes, Lexeme forms, and Lexeme senses). Since instances of these three lexicographic types can refer to Items and can contain Statements, and Statements require Properties and Statement ranks, Wikifunctions is also adding support for these other types, but in the near term this support will be limited to what’s needed for effectively using the lexicographic types.
Documentation of the lexicographic types can be found at Wikidata:Lexicographical data/Documentation.
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 or planned support currently includes:
- Built-in types corresponding to the 5 entity types, Statement, and Statement rank.
- 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
- 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) as the “Wikidata types”, and the built-in types of (2) 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, 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.
This work is ongoing; the set of capabilities is not complete yet. This page describes each of the above areas of support, and also gives status regarding which specific elements are currently available, which are currently under development, and which are expected to be developed in future.
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
Instances of these types are never made persistent on Wikifunctions (except for the instances of Wikidata statement rank). They are constructed on the fly, when needed, using content retrieved directly from Wikidata. Instances of the entity types (all the above types except Wikidata statement and Wikidata statement rank) 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.
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
- claims, 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 Wikidata: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
Wikidata statements appear inside of Wikidata items, properties, lexemes, lexeme forms, and lexeme senses. Each Statement retrieved from Wikidata contains four parts: an entity ID, a Property ID, a value, and a rank. Statements having these types of values are ingested (transformed into instances of Wikidata statement):
- String
- Lexeme ID
- Lexeme form ID
- Lexeme sense ID
- Item ID
- Monolingual text
In the context of an enclosing statement, entity IDs are ingested into the appropriate Wikidata reference type.
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, 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:
- Fetch Wikidata lexeme
- Fetch Wikidata lexeme form
- Fetch Wikidata lexeme sense
- Fetch Wikidata property
- Fetch Wikidata item
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 one function based on these search capabilities. (A second is planned, and expected to be deployed by the end of March, 2025.)
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.
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"
},
"claims": [
{
"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"
}
]
},
"claims": [
...
]
}
],
"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"
}
],
"claims": [
/* (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": [
]
},
...
]
}
|