Wikifunctions:Type proposals/Semantic 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 sections "Required global mappings", "Converting to code", and "Read function" below. 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 semantic units, very broadly construed, containing other semantic units as members.
These units can represent any number of semantically meaningful entities (§2.2), such as
- concepts (examples!) (whether nominal, such as album (Q482994), or adjectival, such as shallow (Q138866260), or adverbial, such as immediately (Q6004788));
- dependent phrases (whether subordinating, such as "although the dog ran away", or attributive (examples!), such as concrete brick wall);
- independent clauses (whether verbal, such as "he saw me", or nonverbal (examples!), such as "the boat is mine");
- full-on sentences (whether by joining two clauses together that apply simultaneously or through simply stating the simple existence of a concept);
- containers for those (perhaps a context in which things referred to in the text need to be specified, or where particular aspects of the text's framing need to apply); or
- signals for any of them (perhaps to mark an identifier on a semantic unit, or to mark something to be emphasized or raised to be a sentence's topic).
All the semantic unit needs is a type designation (named 'Constructor type' in the Structure below) for the rendering process to handle it properly.
For more on this particular construct (named 'Constructor' in my own work), see
- the second paragraph of Section 2.2, all of Section 2.3, and section 4.1.1, of Using Wikidata lexemes and items to generate text from abstract representations (Q130478475); as well as
- the implementation of this construct in Ninai (and adjacent files within that folder); and
- descriptions of semantic unit definitions in Ninai, such as the nonverbal constructions (and adjacent files within that folder).
Uses and motivations
- This is one of two fundamental data structures (the other being syntactic units, plus a few less fundamental but still important others) that will become necessary for abstract content to truly be abstract.
- The distinction between 'semantic units' and 'syntactic units' is directly inspired by established linguistic theories that separate layers of language processing, namely semantics and syntax; semantics is more clearly focused on organizing meaning, while syntax is clearly more focused on organizing words. Content authors should only organize meanings; rendering functions should only organize words.
- Rather than assembling factual information directly using function calls, these units can be composed and manipulated and then rendered according to functions that can be defined per language (see "Required global mappings" below).
- The rendering functions for individual semantic unit types can be set up to provide necessary fallback values for particular semantic features in situations where the content or any context doesn't suggest those features to reflect in the output.
- The terms linked from the six types of possible semantic units above are general, language-independent linguistic semantic notions; while this proposal does not inherently prescribe their use, they have been chosen in the example pages above based on analyses of constructs both within and across languages, with those analyses given as references on those items, so from the get-go notions distinguished in more typologically diverse languages will already be handle-able with those items.
- For example, rather than broadly defining a "noun complement" or "adjective complement" (which refer to syntactic categories in their names!), the attributive indication that something is also something else might be called a coordination relation (Q126200060) (as defined by e.g. Binominal Lexemes in Cross-Linguistic Perspective (Q126124086)).
- For example, rather than calling a semantic unit "although" or "but" (both of which have their nuances, the latter having multiple varied meanings, and in either case tying them to particular English words) or even "concession" (still a somewhat broad term), the link between a sentence and a statement such as "although the dog ran away" might be called a expectation-raiser relation (Q131451405) (as defined by e.g. The Penn Discourse Treebank 2.0 Annotation Manual (Q131451287)).
- For example, rather than calling a semantic unit "there is" (particularly since the equivalents of this phrase in other languages have more meanings than the one simply stating the existence of something), a simple declaration of that existence might be called a hyparctic construction (Q124317561) (as defined by e.g. Nonverbal clause constructions (Q124316703)).
- Many of the instance methods listed in the Ninai implementation of this construct would need to be defined as functions here for this to work.
- This corresponds with the notion of a 'Constructor' described in lots of prior writings about Abstract Wikipedia, such as from the original Abstract Wikipedia paper. (To help make this just a little less mysterious for this mostly non-linguistic audience, however, I've named this type proposal 'semantic unit'.)
Structure
The structure is intentionally very simple, to prevent an excess of Wikifunctions types for different types of semantic units, and to keep the core steps for processing nested semantic units as streamlined as possible.
- Constructor type: The type of semantic unit that the object represents.
- (Because all Wikifunctions types must go through a proposal process—much like this one!—there is necessarily an indeterminate delay between when one can be conceived of and when one can be used in abstract content. Any modifications to Wikifunctions types likely will also need to go through that process. By simplifying the semantic unit structure as much as possible, the need to propose a type for any new or modified semantic concept is bypassed, such that, among those able to modify the mappings listed under "Required global mappings" below, anyone can define their own semantic units and use them immediately.)
- Core arguments: Mapping of names of core arguments to actual semantic unit arguments.
- This basically holds a list of expected input parameters for a semantic unit when it is used; when written in the syntax listed under "Read function" below, the first argument is treated as the first core argument, the second the second, and so on.
- Here the argument names do not have to be Wikidata item IDs, though it is recommended for language-neutral semantic unit definitions that they should be such IDs.
- Scope arguments: List of other semantic unit arguments provided that have not been mapped to core argument names.
- These can correspond to subordinating clauses ("when I went to the store"), relative clauses ("that went to the store"), and signals ([this unit is the topic of the sentence!], [this unit should be emphasized!])
- Most definitions of semantic units are unlikely to treat those kinds of semantic units as core arguments, given that they can often be removed from an expression without necessarily affecting sentence structure.
- Other arguments: List of arguments that are neither core nor scope arguments, primarily those that are not semantic units at all.
- If a semantic unit does not take another semantic unit as input, then the arguments it needs to process are stored here.
- (For example, concept (Q151885) takes an entity ID as an argument; since this entity ID is not itself a semantic unit, it is stored in other_arguments).
- The notions of 'core', 'scope', and 'other' are handled by argument filters defined for different Constructor types (since they filter inputs into one of those three groups).
- (The logic behind some of them in Ninai may be found on this page.)
- Note that argument filters can be parameterized themselves; it is not likely that those will proliferate, since semantic unit renderers will end up being more diverse in actual argument transformation anyways!
- If a semantic unit does not take another semantic unit as input, then the arguments it needs to process are stored here.
{
"type": "semantic unit",
"constructor_type": "Wikidata item reference",
"core_arguments": "typed map(string, semantic unit)",
"scope_arguments": "typed list(semantic unit)",
"other_arguments": "typed list(object)"
}
|
{
"Z1K1": "Zxyz",
"ZxyzK1": "Z6005",
"ZxyzK2": "Z883(Z6, Zxyz)",
"ZxyzK3": "Z881(Zxyz)",
"ZxyzK4": "Z881(Z1)",
}
|
| Excluded from structure above per comments below |
|---|
|
Required global mappings
(taken from the Ninai implementation)
- Mapping from Constructor types to argument filter functions:
- Typed map(Wikidata item reference, Function)
- Example: classificational construction (Q124316841) → (some function resembling this one)
- Mapping from Constructor types to lists of names for core arguments:
- Typed map(Wikidata item reference, Typed list(String))
- Mapping from Constructor types to any parent Constructor types:
- Typed map(Wikidata item reference, Typed list(Wikidata item reference))
- Mapping from Constructor type-language pairs to rendering functions:
- Typed map(Typed pair(Wikidata item reference, language), Function)
- Example: (classificational construction (Q124316841), Norwegian Bokmål (Z1227)) → (some function resembling this one)
Once an entry in each of those four mappings is provided for a semantic unit, rendering abstract content using that semantic unit in a target language becomes possible!
- Creating and modifying functions is something more people can do, and adding entries to mappings is rather cheap!
- If a semantic unit type's core argument list, or its parent semantic unit types, needs to be changed, just
- change the rendering function for that type to handle both 'before' and 'after' situations;
- make the core argument/parent semantic unit definition changes, then
- (if you've adjusted abstract content using that semantic unit) remove the 'before' situation handling from the rendering function!
- (no new or modified Wikifunctions types necessary!)
- (If one wanted to build an entirely parallel set of semantic unit types to the ones commonly in use at a given point, nothing stops them from adding those types, and the necessary functions for handling them, to the mappings above so that they can be processed with the same general rendering steps!)
There are a few more global mappings that could be listed here that perform other steps noted in (§5), but they are not that different from the ones above, and most only need to be filled in under special circumstances.
Example values
The content corresponding to the phrase "Thriller is an album" (assigning a class to a proper noun) consists of the following top level semantic unit:
- classificational construction (Q124316841), {core argument mapping}, [], []
The elements of core argument mapping are the following string-semantic unit pairs:
- Q164573: (concept (Q151885), {}, [], ["Q44320"])
- Q16889133: (concept (Q151885), {}, [], ["Q482994"])
More on the semantic unit types and their arguments may be found on this set of pages being compiled.
Validator
The validator ensures that the constructor_type is a valid Wikidata item reference, the identifier is a valid string, the core argument mapping and scope argument list consist of valid semantic units, and the child_identifier mapping is coherent with respect to the argument lists.
Identity
Equality between semantic units implies that the components all compare equal. (Note that unlike with syntactic units, the "identifier" value is considered as part of this check.)
Converting to code
Python
Ideally this would be directly portable from https://gitlab.com/mahir256/ninai/-/blob/main/ninai/base/constructor.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
The Ninai implementation does have a string representation, but that may not be the best for displaying in a web interface like this one.
Read function
These should in general be composed using the Lisp-like syntax described in a previous newsletter, rather than as individual units.
Slightly modifying from (§2.3):
- The specific choice to represent all semantic units as similarly structured nested function-like objects is largely inspired by the parenthesized syntax of Lisp-like programming languages, and to a lesser extent by Wikifunctions’ ‘composition’ syntax for defining functions entirely in terms of other functions.
- This is intended to make abstract content highly declarative, since the intended meaning of nested semantic units is frequently sufficiently clear on a surface reading of their constructor types and arguments.
- This choice also allows abstract content to be effectively homoiconic, since modifications to that content within the content itself become a possibility [...].
- It also ensures, from an implementation standpoint, that differences in how Constructors are handled are dealt with purely by functions at different stages in the overall rendering process.
The content given in the example above could be indicated as follows:
["Q124316841", ["Q151885", "Q44320"], ["Q151885", "Q482994"]]
Alternatives
Example
Here is a practical example of how Syntactic utits could be used to represent abstract content.
Comments
Support as proposer (not something I'd generally find necessary, but since it's part of the template for whatever reason, I don't want to confuse anyone). Mahir256 (talk) 23:36, 8 April 2026 (UTC)
- A question: why is "other_arguments" a typed list, and not a typed map? Wouldn't it be better to have the possibility to name the arguments? Dv103 (talk) 20:55, 9 April 2026 (UTC)
- @Mahir256 I have a question and a couple of suggestions:
- Why signals are stored in the Scope arguments field? Why force them to be of type Semantic unit?
- Mapping from Constructor type-language pairs to rendering functions (the last required global mapping), in practice would be better to be of type:
- Typed map (Z883) (Wikidata item reference (Z6091), Configuration of functions for given languages (Z14294))
- (since Configuration of functions for given languages (Z14294) is already widely used, and allows to better group language varieties under a single handling function, when necessary)
- The output of the display function should be a valid input of the read function; a read function should be able to input all the possible valid values, and if two values are different, the display function should output two different strings.
- A type does not necessarily need a read and display function, and it is always possible to think about them in a second moment, after the type creation.
- Dv103 (talk) 09:46, 13 April 2026 (UTC)
- @Dv103: "other_arguments" is a typed list simply because I had implemented it that way in Ninai initially; I don't think it would be 'impossible' to make it a typed map, but then there is the question of how to add extra arguments to that map that have not been specifically named (e.g. for a semantic unit that could have an indefinite number of input arguments), and I have not considered it in detail yet.
- The treatment of signals as semantic units (and thus their treatment as scope arguments) is more than anything else for uniformity in representation with the rest of the abstract content.
- This is probably true; I had only used a typed pair as a key to the rendering function map in order to eliminate an extra map lookup.
- I am generally sympathetic to this idea, and am a little disappointed that I didn't think to try implementing this in Ninai yet! Mahir256 (talk) 14:31, 13 April 2026 (UTC)
- @Mahir256: Part of my confusion was that I thought that "signals" would end up going in the "other_arguments" field, while I see that they would end up in the "scope_arguments" field.
- In practice, for example, how would you signal the topic? How would you note the number for nominal concepts?
- We'll see what we will be able to do with the execution time constraints. It's not fundamental to set in stone now this detail, since it is not directly part of the type itself.
- Dv103 (talk) 14:56, 13 April 2026 (UTC)
- @Mahir256: Part of my confusion was that I thought that "signals" would end up going in the "other_arguments" field, while I see that they would end up in the "scope_arguments" field.
- @Mahir256 A note about the Python converter: in Wikifunctions, type converters cannot create global variables/functions/classes. This means that the code won't be able to access the classes you define in the constructors (just the objects that you pass to the implementation). This means that implementations won't be able to create new instances of your class, and you can't assume they will be able to return instances of it. Dv103 (talk) 06:14, 18 May 2026 (UTC)
This proposal is an excellent starting point. The thing that does not convince me is the fact that I wouldn't see this proposal applied directly in Wikifunction as it is now, since it is very Python-y and not very Wikifunction-y, meaning that it has a structure that is optimized to be implemented in Python, but does not respect the general spirit of the other Wikifunction types. For example, I'm not convinced by the fact that it uses IDs to link the various Semantic units. Another thing that can be improved: this proposal is a very technical one, and uses a lot of thechnical jargon that can make it quite difficult to understand. Considering that both Wikifunctions and Abstract Wikipedia are collaborative projects, I think that clarity should be a priority. Dv103 (talk) 09:07, 6 April 2026 (UTC)
Neutral- @Dv103:
- The Python-iness of it all stemmed from this initially being developed in 2021 and Wikifunctions only coming into existence two years later, during which many development choices were made for operational efficiency and future system flexibility. If you read section 2.4 of the paper I wrote, I have declared the various ways that I've set up the code to make transfer to Wikifunctions implementations possible while making it feasible to develop externally; you're welcome to also ask the Abstract Wikipedia team as well if those assumptions hold.
- I'd be interested to learn which Wikifunctions types aren't being respected by this proposal; I have given a specification of both semantic and syntactic units in terms of the ZIDs of the types of their components, and do not seek to use or abuse any other types that may have been created entirely ad hoc for some unplanned language generation purpose.
- (With respect to the use of IDs, they do not 'link the various Semantic units'; they exist for content authors to refer to them when wanting to perform arbitrary transformations on parts of abstract content. This is mainly inspired by the notion of elements having IDs in HTML--an output markup language being used for the Abstract Wikipedia!--so that they can be styled using CSS. Consider a scenario in which semantic unit C is contained within (possibly multiple levels down) semantic unit A. If you want to apply a transformation to C, but are only given A, it should not be the content author's responsibility to figure out where within unit A unit C is; it should be enough to state 'transform the unit with ID "C"' and to let functions handle the traversal.)
- You do raise a point about jargon; the language I have used is intentionally general so as to prevent as much hardcoding of linguistic concepts within the type as possible. While I can understand this proposal being a little unclear to the wholly uninitiated user as a consequence, that need not mean functions using these types--which will of course have more tangible, specialized purposes--will also be equally unclear. Nevertheless, I will continue to revise this proposal to add more explanations for some of the choices noted above (in the event someone decides not to read the references I point to), and in any case I am slowly gathering in one place statements I have expressed and ideas I have implemented in a subpage of my Wikidata user page. Mahir256 (talk) 15:49, 7 April 2026 (UTC)
- For the fourth point, my comment was just a suggestion to reword this proposal (since it can be quite difficult to read this proposal while consulting entire external documentations).
- For the other points, I am not saying that this proposal technically breaks Wikifunctions; I am just saying that it goes against the (for now) unwritten rules on how usually Wikifunctions types are designed, and it can clash on how in practice Wikifunctions work. For example, the use of IDs requires either that:
- Function creating the objects also generate the unique IDs: it can be quite cumbersome to implement through the use of Wikifunctions' purely functional and deterministic functions.
- IDs are manually created by users: this means that contributors need to manually execute a technical operation, while Wikifunctions should ideally tend towards having a high level interface. This again has not been encoded in a written guideline yet (afaik), but is a principle that has guided the development of Wikifunctions.
- The final message is that this proposal needs a bit of rewording and eventually a rethink in order to make it more intuitive. Dv103 (talk) 21:03, 7 April 2026 (UTC)
- @Dv103: The main structural point I will concede is that identifier choice may be problematic when randomness is not a possibility on Wikifunctions, and have removed it from the structure. (identifier (Q1773882) is already a type of semantic unit in Ninai, so as long as that semantic unit can be accessed from other semantic units, I can deal with it not being a direct member.)
- I have also made some revisions above in the interests of clarity, with bolding/italicizing/underlining of important parts for the reader without time to spare for some reason (and added daggers (†) in places that correspond with points within my comment of 23:35, 8 April 2026 (UTC) on your proposal); if there is something above that still doesn't seem clear without looking at an external reference, please let me know and I will try to adjust it.
- This being said, I question whether 'intuition' should be the absolute first priority for abstract content planning when 1) what is being stored is information intended to be as language-neutral as possible and 2) most people have come into this project more inclined--dare I say clouded?--by the structure of the language that they themselves speak. (Indeed, the current Abstract Wikipedia is running into problems because of a lack of cross-linguistic awareness from a mostly English-speaking userbase projecting their mostly English-speaking biases into abstract content structure development, running into problems with making even their own language work--and that's not counting other editors who don't speak English also raising issues with handling their own languages; what room have they to try fixing things in an environment so tethered by the principles of just one language?) I have at least considered greatly typologically diverse languages for years now—since 2021 when I started coding the system, if not since 2015 when I started my linguistics minor at university—and in my own work have successfully rendered at least simple sentences with predicates and modifiers in many of them, so I remain confidently optimistic in saying that the effort of getting users to think about representing information in language in a 'zoomed out' way (hat tip to @عُثمان: for using this phrase in another group) will permit the greater benefits of a simplified structure for representing (parts of) meaning to be reaped. Mahir256 (talk) 23:34, 7 April 2026 (UTC)
- I'd disagree about your remark about intuition: consider that most of the languages of the world are minority languages, with a very limited set of fluent speakers. With a small set of speakers, the quantity of people both linguistically literate and that know how to program that are interested in Abstract Wikipedia can become very limited. For this reason, I think that one of the biggest effort for Abstract Wikipedia to succede in its purposes needs to be put into making contribution as accessible as possible.
- That said, I agree on the need of defining concepts in a language-neutral way. I finally found your list of non-verbal predicates, and I'm already in love with it. The problem with how this page is structured now, is that is full of unexplained technical jargon, that can overwhelm the uninitiated. Instead of bolding/italicizing/underlining, a glossary can be of great help. Just consider that most Wikifunctions contributors (me included) have no formal training in linguistics, so this page should be understood without any previous linguistic studies knowledge. (Also, Python code too can be difficult to read, without the previous knowledge on how the rest of the program works).
- As for the actual type itself, I agree with the fundamental philosophy (like the separation of semantic and syntax processing, and all the points in the section "Uses and motivations"), but I still believe that the actual implementation is more idiomatic to Python (with a procedural and partially object-oriented paradigm) and it does not fit too well with Wikifunctions (with a functional paradigm). In particular, it seems to me that it is trying to define a meta-type in order to bypass the type proposal procedure, thus negating all the advantage of the type oriented approach that Wikifunctions is based on. Dv103 (talk) 19:46, 9 April 2026 (UTC)
- Now
Support. For me, the ideal would be to create an official list of encapsulating constructor functions that are actually called from Abstract Wikipedia that mimic Wikifunctions:Type proposals/Abstract sentence, since this type is still unintuitive to directly work with. Dv103 (talk) 20:38, 9 April 2026 (UTC)
Oppose, per Dv103, their proposal is much better fit to Wikifunctions and much more intuitive. Feeglgeef (talk) 13:58, 7 April 2026 (UTC)
Neutral I think both proposals have merit and flaws, but I suspect Mahir and Dv understand this better than I do, so I'll let them discuss it amongst themselves and come to a conclusion later. Feeglgeef (talk) 15:19, 9 April 2026 (UTC)
Support since I had been wondering about creating something like this for a while now.
See: action property (as past ptcp v) done by item n (Z33437), which I could never finish due to the inability to easily create sentences with configurable dependent clauses. —UndueMarmot (talk) 14:51, 28 April 2026 (UTC)
Support Would be extremely important toward allowing external software to use Wikifunctions's NLG tools. An example of such a tool: abstract:Abstract Wikipedia:Project chat#AceWiki: Abstract Wikipedia before Abstract Wikipedia? JJPMaster (she/they) 15:22, 28 April 2026 (UTC)