Jump to content

Wikifunctions:Type proposals/Syntactic unit

From Wikifunctions

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.
  • 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:

{
  "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