Word Selector

This module provides a mechanism to extract words from a database based on various criteria such as event, key, type, and name through the WordSelector class.

class loglan_core.addons.word_selector.WordSelector(model=<class 'loglan_core.word.BaseWord'>, is_sqlite=False, case_sensitive=False, disable_model_check=False)[source]

Bases: BaseSelector

Class to extract words from a database based on various criteria.

Extends the SQLAlchemy Select class to provide additional functionality.

__init__(model=<class 'loglan_core.word.BaseWord'>, is_sqlite=False, case_sensitive=False, disable_model_check=False)[source]

Initializes the WordSelector object with the provided parameters.

Parameters:
  • model (Type[BaseWord]) – The class to be used as the base key. Must be a subclass of BaseWord.

  • is_sqlite (bool) – If SQLite is being used. Defaults to False.

  • case_sensitive (bool) – If the queries should be case-sensitive.

  • disable_model_check (bool) – If the model check is disabled during initialization.

Raises:

ValueError – If the provided model is not a subclass of BaseWord.

by_event(event_id=None)[source]

Applies a filter to select words associated with a specific event.

Parameters:

event_id (int | None) – The id of the event to filter by. Defaults to None.

Returns:

A query with the filter applied.

Return type:

Self

by_key(key, language=None)[source]

Applies a filter to select words by a specific key.

Parameters:
  • key (BaseKey | str) – The key to filter by.

  • string. (It can either be an instance of BaseKey or a)

  • language (str | None) – The language of the key. Defaults to None. Defaults to False.

Returns:

A query with the filter applied.

Return type:

Self

by_name(name)[source]

Applies a filter to select words by a specific name.

Parameters:
  • name (str) – The name to filter by.

  • False. (Defaults to)

Returns:

A query with the filter applied.

Return type:

Self

by_type(type_=None, type_x=None, group=None)[source]

Applies a filter to select words by a specific type.

Parameters:
  • type (BaseType | str | None) – The type to filter by.

  • BaseType (It can either be an instance of) – E.g. “2-Cpx”, “C-Prim”, “LW”

  • string (a) – E.g. “2-Cpx”, “C-Prim”, “LW”

  • None. (or) – E.g. “2-Cpx”, “C-Prim”, “LW”

  • type_x (str | None) – The extended type to filter by. Defaults to None. E.g. “Predicate”, “Name”, “Affix”

  • group (str | None) – The group to filter by. Defaults to None. E.g. “Cpx”, “Prim”, “Little”

Returns:

A query with the filter applied.

Return type:

Self

get_affixes_of(word_id)[source]

Selects all affixes that are derived from the given word.

Parameters:

word_id (int) – The id of the word to filter by.

Returns:

A query with the filter applied.

Return type:

Self

get_complexes_of(word_id)[source]

Selects all complexes that are derived from the given word.

Parameters:

word_id (int) – The id of the word to filter by.

Returns:

A query with the filter applied.

Return type:

Self

get_derivatives_of(word_id)[source]

Selects all words that are derived from the given word.

Parameters:

word_id (int) – The id of the word to filter by.

Returns:

A query with the filter applied.

Return type:

Self