Wikifunctions:Working with Wikidata content
| Abstract Wikipedia team staff primarily maintain this page's content. |
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in Support for Wikidata content. It describes a series of function calls that a user can step through on Wikifunctions.org, with figures and explanations.
Getting acquainted with Wikidata content on Wikifunctions


Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at Wikidata:Lexicographical data/Documentation.
Fetching a lexeme form from Wikidata
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, Fetch Wikidata lexeme form, and examine the content that it returns. We are going to fetch the lexeme form for the German adjective schöner, which is the singular masculine form of schön (beautiful).
Calling the function
- Visit Fetch Wikidata lexeme form in your browser.
- Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme form reference, and returns a Wikidata lexeme form.
- Locate the lexeme form selector for entering the input value (shown in Figure 1, below). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
- Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
- When you see the choice schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective (as shown in Figure 2, below), click on it. Your selection should then appear as in Figure 3 (below).
- Click on the chevron (which looks like ‘>’).
- Notice that it reveals a simple structure, a Wikidata lexeme form reference, as shown in Figure 4 (below), with just the type and the Wikidata ID
L6758-F4. This is the ID of the lexeme form that’s been selected.
- Notice that it reveals a simple structure, a Wikidata lexeme form reference, as shown in Figure 4 (below), with just the type and the Wikidata ID
- Click Run function.
- Using the ID
L6758-F4,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of Wikidata lexeme form.
- Using the ID
- The result should appear as shown in Figure 5 (below). This shows the compact view for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word schöner (which also provides a link to the Wikidata page from which this item has been fetched).
- Try clicking on the chevron to the left of schöner. You will see that it reveals an expanded view of the content (as shown in Figure 6, right). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: type, identity, lexeme, representations, grammatical features, and claims. (Figure F omits the details of the claims part.) Here we are concerned with the lexeme, representations, and grammatical features (which will be relevant to the examples below.).
- The lexeme, shown in its collapsed view as schön, simply indicates the lexeme that this lexeme form belongs to.
- The representations (of which there is usually just one) are the actual word-forms recorded by the lexeme form; schöner in this case.
- The grammatical features are characteristics of this particular lexeme form, such as singular and masculine.
- By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of lexeme is represented as a Wikidata lexeme reference, and each value in the grammatical features list is represented as a Wikidata item reference.
- Fig. 1. Lexeme form selector
- Fig. 2. Lexeme form selector with 2 choices showing
- Fig. 3. Lexeme form selector with "schöner" selected
- Fig. 4. Lexeme form reference
- Fig. 5. Compact view of a lexeme form
Figure 7, right, an animated GIF, shows all the above steps enacted on a mobile device screen.
Generating phrases with agreement



As explained in the Status update for 2024-10-25, agreement means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun Hut (hat) is masculine, so an adjective that modifies it must take the masculine form, such as schöner (beautiful). Katze (cat) is feminine, so the same adjective would take the form schöne.
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
- a function that returns the gender of a given noun, and
- a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
Getting the value of a statement in a lexeme
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
Applicability: in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
Calling the function
- Visit grammatical gender from Lexeme in your browser.
- Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
- Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
- Locate the lexeme selector for entering the input value (shown in Figure 8). In the box with the Wikidata icon, type in the 3 letters “hut”.
- Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
- When you see the choice for Hut; German, noun (the second choice shown in Figure 9), click on it. Your selection should then appear as in Figure 10, below.
- Click Run function.
- The result should appear as shown in Figure 11. This shows the compact view for the Wikidata item reference for the concept masculine. The compact view includes just the Wikidata icon and the word masculine.
- Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
- Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
- Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
- Click on the rightmost chevron.
- Notice that it reveals a simple structure (the Wikidata item reference for masculine) shown in Figure 12, containing the type and the Wikidata item ID
Q499327.
- Notice that it reveals a simple structure (the Wikidata item reference for masculine) shown in Figure 12, containing the type and the Wikidata item ID
- Fig. 10. Lexeme selector with "Hut" selected
- Fig. 11. Compact view of a Wikidata item reference
- Fig. 12. Expanded view of a Wikidata item reference
Figure 13, right, an animated GIF, shows all the above steps enacted on a mobile device screen.
Getting a word form with given grammatical features



Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (representation) having one or more given grammatical features. For example, the lexeme for schön (beautiful) has a lexeme form with grammatical features singular and masculine, and that lexeme form contains the representation schöner.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, Fetching a lexeme form from Wikidata.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
Applicability: Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct lexeme form (or its representation) in various language generation tasks.
Calling the function
- Visit first matching representation string from lexeme in your browser.
- Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
- Locate the input selectors (shown in Figure 14).
- In the lexeme selector, where it prompts with Select Wikidata lexeme, type in “schon”.
- When you see the choice for schön; German, adjective (the third choice shown in Figure 15), click on it. Your selection should then appear as in Figure 16, below.
- Enter the grammatical feature singular as follows:
- Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
- Type in “singular”, where it says Select Wikidata item, and choose singular; grammatical number. This is the Wikidata item reference for the linguistic concept singular.
- Using the ‘+’ icon again, type in “masculine” and choose the feature masculine; grammatical gender (because we want the adjective to agree with the masculine noun Hut). Your input selections should now appear as in Figure 17.
- Try clicking on the chevron to the left of Item 2. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
- Click Run function.
- The result (the string schöner) should appear as shown in Figure 18.
- Fig. 16. "schon" selected in the first input selector
- Fig. 17. Selections ready for the function call
- Fig. 18. Function call result, a string
Figure 19, right, an animated GIF, shows all the above steps enacted on a mobile device screen.
Generating a phrase with agreement
Here we show how to compose a call to German indef noun phrase from noun and adjective, an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
- Determine if the noun has masculine or feminine gender
- Extract the correctly gendered, singular form of the adjective from the adjective lexeme
- Choose the correct form of the indefinite article
- Extract the singular form of the noun from the noun lexeme
- Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
Applicability: This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
Caveat: Unfortunately, at present Wikifunctions is experiencing some performance issues, and the success of this function-call is intermittent; sometimes there is a timeout error. We are working to resolve these issues.
Calling the function


- Visit German indef noun phrase from noun and adjective in your browser.
- Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
- Locate the input selectors (shown in Figure 20). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
- In the noun selector, type in “hut” and select the choice for Hut; German, noun (as was shown in Figure 9).
- In the adjective selector, type in “schone” and select the choice for schön; German, adjective (as was shown in Figure 15).
- Try clicking on the chevron to the left of adjective. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 21).
- The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When Run function is clicked, the result of this call will be used as the second input to German indef noun phrase from noun and adjective.
- Click Run function.
- If the run completes normally, the result will be the string ein schöner Hut. If there's a timeout condition, however, you will see the word void, and an error indication in the Details dialog.
If you want to get an idea of how German indef noun phrase from noun and adjective has been implemented, visit the implementation at agree adjective with noun. In the Contents box, under the word composition, you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.

