Wikifunctions:Type proposals/Syntactic unit
This is one of a few type proposals based on the Ninai/Udiron project, and thus should be considered alongside others similarly marked--some of which will be listed on the talk page of this proposal.
This proposal and others related to it are contingent on certain functionalities being present on Abstract Wikipedia/Wikifunctions, as listed under the section "Converting to code" below and related sections listed at the semantic unit proposal. Please do not hesitate to ask for clarifications about those sections! The author of this proposal is not inherently better than you, so there is no need to simply defer to his reasoning (à la "he knows what he's doing, so I'll just trust it")!
Summary
This type holds a syntactic unit that holds a base word/stem of some kind, with links to any dependents (as construed in w:en:dependency grammars).
For more on this particular construct (named 'Catena' in my own work), see the first paragraph of Section 2.2, and the first part of section 4.2.1, of Using Wikidata lexemes and items to generate text from abstract representations (Q130478475), as well as the implementation of this construct in Udiron.
Uses
- This is one of two fundamental data structures (and a few less fundamental but still important others) that will become necessary for abstract content to truly be abstract. Rather than process lists/sets of strings in assembling a sentence, these units can be manipulated and then rendered according to functions that can be defined per language.
- Many of the instance methods listed in the Udiron implementation linked above would need to be defined as functions here for this to work.
- This is intended to correspond with the notion of a 'catena' in dependency grammar, and more specifically to a unit used in Universal Dependencies (with a mapping to Wikidata here). (To help make this just a little less mysterious for this mostly non-linguistic audience, however, I've named this type proposal 'syntactic unit'.)
Structure
- lexeme: The lexeme which this syntactic unit represents.
- See the note under 'sense' below.
- language: The language to be applied when this syntactic unit is rendered.
- Note that languages in Ninai/Udiron are pairs of language item and language code; this requires that https://phabricator.wikimedia.org/T344170 be resolved.
- sense: The specific meaning of the lexeme which this syntactic unit represents.
- The lexeme and the sense are both included separately because details present at both levels will be needed downstream; as but mere examples, the grammatical gender of a lexeme does not reside on its senses, and if a particular grammatical feature is required when using a particular sense then that feature won't be marked on the lexeme level.
- This and 'lexeme' are not references simply because this unit does not have to represent something that is on wikidata.org; if a custom lexeme/sense were created by some other function, that should be usable here as well.
- inflections: The inflections to be applied in rendering this syntactic unit.
- This was inspired by the lists of grammatical features on Wikidata lexeme forms, though the values present in this list do not have to be actual such features on a form of the lexeme.
- config: Specific settings for rendering this syntactic unit may be applied here, potentially altering every aspect of the rendering process.
- The current implementation of such a configuration object (introduced because it is not clear whether the Python notion of 'keyword arguments' will be replicated in Wikifunctions) is found on this page.
- This object could be a dedicated configuration type, or it could be a typed map from strings to objects as given in the example below.
- left_dependents: The dependents of this syntactic unit that are logically preceding this one, each with some relationship to this unit.
- right_dependents: The dependents of this syntactic unit that are logically following this one, each with some relationship to this unit.
- For example, in a phrase like "the little old lady who lived in a shoe", the root of this phrase is "lady" (since that phrase at its core denotes a lady).
- Since "the", "little", and "old" precede "lady" when spoken, those words are considered left dependents (not a single functional unit, since those words are but a determiner and two adjectives).
- Since "who lived in a shoe" follows "lady" when spoken, those words (forming a single functional unit—a relative clause) are considered a single right dependent.
- That right dependent has its own structure: its root is "live", its left dependent is "who", and its right dependent is "in a shoe".
- That right dependent has a root "shoe" and two left dependents "in" and "a".
- Udiron currently groups these into a tuple of lists 'dependents'.
- id: A unique identifier for the syntactic unit.
- This was introduced in Udiron (and maintained simply by having a counter that is incremented each time a new syntactic unit is created) in order to deal with the consequences of all objects being immutable in Wikifunctions; if this did not exist, then any time any of the other fields of this syntactic unit was modified, its internal identifier and that of other equally immutable objects that would also need to be modified (such as other syntactic units that have this syntactic unit as a dependent) and comparisons between objects before and after a modification would become considerably more complicated and difficult to track.
Example values
The English phrase "he saw me" (without punctuation!) would consist of three syntactic units whose fields are defined below:
- L485, Z1002, L485-S1, (nominative case (Q131105)), {}, [], [], "theseentitiesneedsomesortofidscheme"
- L185, Z1002, L185-S1, (simple past (Q1392475), first person (Q21714344), singular (Q110786)), {}, [(bullet point above, subject (Q164573))], [(bullet point below, direct object (Q2990574))], "comeupwithanidschemeforthesethings"
- L487, Z1002, L487-S1, (oblique case (Q1233197)), {}, [], [], "someidschemethatneedstobecomeupwith"
{
"type": "syntactic unit",
"lexeme": "Wikidata lexeme",
"language": "language",
"sense": "Wikidata lexeme sense",
"inflections": "typed list(Wikidata item reference)",
"config": "typed map(string, object)",
"left_dependents": "typed list(typed pair(syntactic unit, Wikidata item reference))",
"right_dependents": "typed list(typed pair(syntactic unit, Wikidata item reference))",
"id": "string",
}
|
{
"Z1K1": "Zxyz",
"ZxyzK1": "Z6005",
"ZxyzK2": "Z60",
"ZxyzK3": "Z6006",
"ZxyzK4": "Z881(Z6091)",
"ZxyzK5": "Z883(Z60, Z1)",
"ZxyzK6": "Z881(Z882(syntactic unit, Z6091))",
"ZxyzK7": "Z881(Z882(syntactic unit, Z6091))",
"ZxyzK8": "Z6",
}
|
Validator
The validator ensures that the lexeme, language, and sense are all valid realizations of those types, all inflections in the inflection set are Wikidata item IDs, and the configuration and dependents lists are well-formed according to their type definitions.
Identity
Equality between syntactic units implies that the components all compare equal, per https://gitlab.com/mahir256/udiron/-/blob/main/udiron/base/catena.py?ref_type=heads#L126 . (Note that the "id" value is not considered as part of this check.)
Converting to code
Python
Ideally this would be directly portable from https://gitlab.com/mahir256/udiron/-/blob/main/udiron/base/catena.py , since it has been designed to make such a transfer easier, although due to lack of confirmation from the Abstract Wikipedia team of the points of section 2.4 of Using Wikidata lexemes and items to generate text from abstract representations (Q130478475) this degree of easiness has not been made certain.
Display function
Perhaps something similar to the 'abbr' function at https://gitlab.com/mahir256/udiron/-/blob/main/udiron/base/catena.py?ref_type=heads#L365 could be used.
Read function
No one should be inputting these as strings; they should be created exclusively by other functions that seek to generate language and perform syntactic manipulations.
Comments
Support. A question: what is the difference between left and righ dependencies? Dv103 (talk) 19:23, 12 April 2026 (UTC)
- @Mahir256 Dv103 (talk) 19:23, 12 April 2026 (UTC)
- @Dv103: I added a hopefully more illustrative example above. Mahir256 (talk) 21:47, 12 April 2026 (UTC)
- Thanks. Dv103 (talk) 05:31, 13 April 2026 (UTC)
- @Mahir256 Another question: how do you encode syntactic units without a lexeme? (Like a person's name, the title of a book...) Dv103 (talk) 12:00, 14 April 2026 (UTC)
- @Dv103: I sort of allude to this in the notes under the 'lexeme' and 'sense' members: "if a custom lexeme/sense were created by some other function, that should be usable here as well". As such proper names would need to be wrapped by functions in 'pseudo-lexemes' before they could be included in any syntactic structure. (An example of a function that assembles a lexeme for downstream use in the syntactic tree is one that assembles a person's name from the 'given name' and 'surname' items linked to it.) Mahir256 (talk) 15:29, 14 April 2026 (UTC)
- @Mahir256 Another question: why put an entire lexeme sense, instead of a lexeme sense reference? The lexeme already contains the sense, so it would be duplicate information.
- Even for "on-the-fly lexemes", the ID fields need to be filled, so we just could just insert the sense in the lexeme, assign it an ID, and then just reference it in the "sense" key of this type.
- I'm asking this because on Wikifunctions, moving around duplicate information means that there is an additional cost in the convertion of the values every time an implementation is called. Dv103 (talk) 15:59, 16 May 2026 (UTC)
- @Dv103: The main reason for this is when a calque needs to be constructed from another lexeme, or when the parts of a compound lexeme need to be moved to discontinuous places (requiring that a lexeme be split based on its combines lexemes (P5238) statements), some features noted on the original lexeme's senses may be needed. (Some examples I have in mind include has semantic argument (P9971) values when calquing a verb, handling separable verbs in Germanic languages, or the inflection of idioms with fixed complements.) Mahir256 (talk) 16:16, 16 May 2026 (UTC)
- Makes sense. Dv103 (talk) 16:34, 16 May 2026 (UTC)
- @Dv103: The main reason for this is when a calque needs to be constructed from another lexeme, or when the parts of a compound lexeme need to be moved to discontinuous places (requiring that a lexeme be split based on its combines lexemes (P5238) statements), some features noted on the original lexeme's senses may be needed. (Some examples I have in mind include has semantic argument (P9971) values when calquing a verb, handling separable verbs in Germanic languages, or the inflection of idioms with fixed complements.) Mahir256 (talk) 16:16, 16 May 2026 (UTC)
- @Dv103: I sort of allude to this in the notes under the 'lexeme' and 'sense' members: "if a custom lexeme/sense were created by some other function, that should be usable here as well". As such proper names would need to be wrapped by functions in 'pseudo-lexemes' before they could be included in any syntactic structure. (An example of a function that assembles a lexeme for downstream use in the syntactic tree is one that assembles a person's name from the 'given name' and 'surname' items linked to it.) Mahir256 (talk) 15:29, 14 April 2026 (UTC)