Module loglan_db.model_db.base_definition
This module contains a basic Definition Model
Classes
class BaseDefinition (**kwargs)
-
BaseDefinition model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.
Ancestors
Subclasses
Class variables
var APPROVED_CASE_TAGS
var KEY_PATTERN
Static methods
def by_key(key: Union[BaseKey, str], language: str = None, case_sensitive: bool = False) ‑> flask_sqlalchemy.BaseQuery
-
Definition.Query filtered by specified key
Args
key
- Union[BaseKey, str]:
language
- str: Language of key (Default value = None)
case_sensitive
- bool: (Default value = False)
Returns
BaseQuery
Instance variables
var body
var grammar : str
-
Combine definition's 'slots' and 'grammar_code' attributes
Returns
String with grammar data like (3v) or (2n)
var grammar_code
var id
-
Definition's internal ID number: Integer
var keys : flask_sqlalchemy.BaseQuery
-
Returns:
var language
var notes
var position
var slots
var source_word : flask_sqlalchemy.BaseQuery
-
Returns:
var usage
var word_id
Methods
def link_key_from_str(self, word: str, language: str = None) ‑> Optional[BaseKey]
-
Linking vernacular word with BaseDefinition object Only new word will be linked, skipping this that was previously linked
Args
word
- str: name of BaseWord on vernacular language
language
- str: BaseWord's language (Default value = None)
Returns
Linked BaseKey object or None if it were already linked
def link_keys(self, source: Union[List[str], str, ForwardRef(None)] = None, language: str = None, pattern: str = '(?<=\\«)(.+?)(?=\\»)') ‑> Union[BaseKey, List[BaseKey], ForwardRef(None)]
-
Universal method for linking all available types of key sources with BaseDefinition
Args
source
- Union[List[str], str, None]: If no source is provided, keys will be extracted from the BaseDefinition's body If source is a string or a list of strings, the language of the keys must be specified TypeError will be raised if the source contains inappropriate data (Default value = None)
language
- str: Language of BaseDefinition's keys (Default value = None)
pattern
- str: Regex pattern for extracting keys from the BaseDefinition's body (Default value = KEY_PATTERN)
Returns
None, BaseKey, or List of BaseKeys
def link_keys_from_definition_body(self, language: str = None, pattern: str = '(?<=\\«)(.+?)(?=\\»)') ‑> List[BaseKey]
-
Extract and link keys from BaseDefinition's body
Args
language
- str: Language of BaseDefinition's keys (Default value = None)
pattern
- str: Regex pattern for extracting keys from the BaseDefinition's body (Default value = KEY_PATTERN)
Returns
List of linked BaseKey objects
def link_keys_from_list_of_str(self, source: List[str], language: str = None) ‑> List[BaseKey]
-
Linking a list of vernacular words with BaseDefinition Only new words will be linked, skipping those that were previously linked
Args
source
- List[str]: List of words on vernacular language
language
- str: Language of source words (Default value = None)
Returns
List of linked BaseKey objects
Inherited members