Word

This module contains a basic Word Model.

class loglan_core.word.BaseWord(id_old, name, type_id, event_start_id, event_end_id=None, tid_old=None, origin=None, origin_x=None, match=None, rank=None, year=None, notes=None)[source]

Bases: BaseModel

BaseWord model representing a word in the database.

This class encapsulates the attributes and relationships associated with a word in the linguistic database. It serves as a foundational model for managing word data, including its origins, types, associated authors, definitions, and relationships with other words.

The BaseWord class supports various attributes that provide detailed information about each word, including its name, origin, matching criteria, and associated events. It also establishes relationships with authors and definitions, allowing for efficient querying and management of linguistic data.

Key Features:
  • Supports unique identification of words with an internal ID.

  • Allows for detailed information about the word’s origin and matching criteria.

  • Facilitates relationships with authors, definitions,

and other words (derivatives and parents). - Provides hybrid properties for easy access to specific types of derivatives (affixes and complexes).

Examples

To create a new word instance:

word_example = BaseWord(
    origin='3/3E word | 3/7S palabra | 2/5F parole',
    event_start_id=1,
    id=7418,
    id_old=7291,
    match='34%',
    name='purda',
    origin='3/3E word | 3/7S palabra | 2/5F parole',
    rank='1.0',
    type_id=9,
    year=datetime.date(1975, 1, 1)
)
id

Word’s internal ID number.

Type:

int

name

The name of the word.

Type:

str_064

origin

The origin of the word.

Type:

str_128 | None

origin_x

Additional origin information.

Type:

str_064 | None

match

Matching criteria for the word.

Type:

str_008 | None

rank

Rank of the word.

Type:

str_008 | None

year

Year associated with the word.

Type:

datetime.date | None

notes

Additional notes about the word.

Type:

dict[str, str] | None

id_old

Legacy ID for compatibility with older databases.

Type:

int

tid_old

Legacy TID for compatibility.

Type:

int | None

type_id

Foreign key referencing the type of the word.

Type:

int

event_start_id

Foreign key referencing the start event.

Type:

int

event_end_id

Foreign key referencing the end event.

Type:

int | None

authors

List of authors associated with the word.

Type:

list[BaseAuthor]

definitions

List of definitions for the word.

Type:

list[BaseDefinition]

derivatives

List of words derived from this word.

Type:

list[BaseWord]

parents

List of parent words of this word.

Type:

list[BaseWord]

__str__()[source]

Returns a string representation of the BaseWord instance.

Returns:

A string representation of the BaseWord instance.

Return type:

str

property affixes: list[BaseWord]

List of djifoa derived from the word. Alias for djifoa, for backwards compatibility.

authors: Mapped[list[BaseAuthor]]

List of authors associated with the word.

This attribute establishes a many-to-many relationship with the BaseAuthor model, allowing for the retrieval of all authors who have contributed to the word. It is populated based on the association table t_connect_authors.

  • Type: list[BaseAuthor]

  • Nullable: True

property complexes: list[BaseWord]

List of complexes derived from the word.

This property filters the derivatives to return only those that are classified as complexes.

Returns:

A list of complexes that are derived from the word.

Return type:

list[BaseWord]

created: Mapped[datetime]

A class attribute mapped to a column in the database table. It represents the timestamp when a row is created. The default value is the current timestamp, and it can’t be null.

Type:

datetime

definitions: Mapped[list[BaseDefinition]]

List of definitions for the word.

This attribute establishes a one-to-many relationship with the BaseDefinition model, allowing for the retrieval of all definitions associated with the word. It is populated based on the relationship defined in the BaseDefinition model.

  • Type: list[BaseDefinition]

  • Nullable: True

derivatives: Mapped[list[BaseWord]]

List of words derived from this word.

This attribute establishes a many-to-many relationship with other BaseWord instances, allowing for the retrieval of all words that are derived from the current word. It is populated based on the association table t_connect_words.

  • Type: list[BaseWord]

  • Nullable: True

property djifoa: list[BaseWord]

List of djifoa (deprecated name ‘affixes’) derived from the word.

This property filters the derivatives to return only those that are classified as djifoa.

Returns:

A list of djifoa that are derived from the word.

Return type:

list[BaseWord]

event_end: Mapped[BaseEvent | None]

Relationship to the BaseEvent model for the end event.

This attribute establishes a relationship with the BaseEvent model, allowing access to the event during which the word was deprecated. It is automatically populated based on the event_end_id.

  • Type: BaseEvent | None

  • Nullable: True

event_end_id: Mapped[int | None]

Foreign key referencing the end event.

This attribute links the word to the event during which it was deprecated or no longer in use. It is optional and can be set to None if there is no end event.

  • Type: int | None

  • Nullable: True

event_start: Mapped[BaseEvent]

Relationship to the BaseEvent model for the start event.

This attribute establishes a relationship with the BaseEvent model, allowing access to the event during which the word first appeared. It is automatically populated based on the event_start_id.

  • Type: BaseEvent

  • Nullable: False

event_start_id: Mapped[int]

Foreign key referencing the start event.

This attribute links the word to the event during which it was first recorded or used. It is required and cannot be null.

  • Type: int

  • Nullable: False

id: Mapped[int]

Word’s internal ID number.

This attribute serves as the primary key for the word in the database. It is an integer that uniquely identifies each word entry.

  • Type: int

  • Nullable: False

id_old: Mapped[int]

Legacy ID for compatibility with older databases.

This attribute is used to maintain compatibility with previous versions of the database. It is required and cannot be null.

  • Type: int

  • Nullable: False

match: Mapped[str_008 | None]

Matching criteria for the word.

This attribute defines any specific criteria used to match the word in queries or searches. It is optional and can be set to None if no matching criteria are defined.

  • Type: str_008 | None

  • Max Length: 8 characters

  • Nullable: True

name: Mapped[str_064]

The name of the word.

This attribute holds the actual word as a string. It is required and must be unique within the database.

  • Type: str_064

  • Max Length: 64 characters

  • Nullable: False

notes: Mapped[dict[str, str] | None]

Additional notes about the word.

This attribute allows for the storage of any extra information or comments regarding the word, encoded as a JSON dictionary. It is optional and can be set to None if no notes are provided.

  • Type: dict[str, str] | None

  • Nullable: True

origin: Mapped[str_128 | None]

The origin of the word.

This attribute provides information about the etymology or source of the word. It is optional and can be set to None if the origin is not known.

  • Type: str_128 | None

  • Max Length: 128 characters

  • Nullable: True

origin_x: Mapped[str_064 | None]

Additional origin information.

This attribute allows for any supplementary details regarding the word’s origin. It is optional and can be set to None if no additional information is available.

  • Type: str_064 | None

  • Max Length: 64 characters

  • Nullable: True

parents: Mapped[list[BaseWord]]

List of parent words of this word.

This attribute establishes a many-to-many relationship with other BaseWord instances, allowing for the retrieval of all parent words from which the current word is derived. It is populated based on the association table t_connect_words.

  • Type: list[BaseWord]

  • Nullable: True

rank: Mapped[str_008 | None]

Rank of the word.

This attribute indicates the importance or classification of the word within a specific context. It is optional and can be set to None if no rank is assigned.

  • Type: str_008 | None

  • Max Length: 8 characters

  • Nullable: True

tid_old: Mapped[int | None]

Legacy TID for compatibility.

This attribute serves as a legacy identifier for compatibility with older database systems. It is optional and can be set to None.

  • Type: int | None

  • Nullable: True

type: Mapped[BaseType]

Relationship to the BaseType model.

This attribute establishes a relationship with the BaseType model, allowing access to the type associated with the word. It is populated based on the type_id foreign key, which links to the primary key of the BaseType table.

  • Type: BaseType

  • Nullable: False

  • Back Population: This relationship is bidirectional, allowing access to all words associated with a given type through the words attribute in the BaseType model.

  • Loading Strategy: The relationship uses a “joined” loading strategy, which means that the related BaseType instance is loaded in the same query as the BaseWord instance for efficiency.

type_id: Mapped[int]

Foreign key referencing the type of the word.

This attribute links the word to its type in the database, establishing a relationship with the BaseType model. It is required and cannot be null.

  • Type: int

  • Nullable: False

updated: Mapped[datetime | None]

A class attribute mapped to a column in the database table. It represents the timestamp when a row is last updated. Whenever the row is updated, this timestamp is automatically set to the current time. It can be null if the row has never been updated.

Type:

datetime

year: Mapped[datetime.date | None]

Year associated with the word.

This attribute represents the year that is relevant to the word, such as the year it was coined or first recorded. It is optional and can be set to None if the year is not specified.

  • Type: datetime.date | None

  • Nullable: True