danoan.word_def.core.model module

Data models and interfaces.

class danoan.word_def.core.model.Plugin(package_name: str, adapter_factory: danoan.word_def.core.model.PluginFactory)[source]

Bases: object

Parameters:
adapter_factory: PluginFactory
package_name: str
class danoan.word_def.core.model.PluginFactory(*args, **kwargs)[source]

Bases: Protocol

get_adapter(configuration_stream: TextIO | None = None) PluginProtocol[source]

Instantiate an implementation of PluginProtocol according with the configuration file.

Raises:

ConfigurationFileRequiredError if api needs configurations settings but a toml configuration file is not passed.

Parameters:

configuration_stream (TextIO | None) –

Return type:

PluginProtocol

get_language() str[source]

Get the language IETF 639-3 code. An empty string means multilanguage.

Return type:

str

version() str[source]

Get the version of the plugin.

Version should follow the semantic versioning scheme. A plugin is considered compatible with a word-def package version if that major component is the same.

Return type:

str

class danoan.word_def.core.model.PluginProtocol(*args, **kwargs)[source]

Bases: Protocol

get_definition(word: str) Sequence[str][source]
Raises:

UnexpectedResponseError if status code of request is different from 200.

Parameters:

word (str) –

Return type:

Sequence[str]

get_pos_tag(word: str) Sequence[PosTag][source]

Get part-of-speech tag of the given word.

The first tag correspond to the first entry in the dictionary.

Parameters:

word (str) –

Return type:

Sequence[PosTag]

get_synonym(word: str) Sequence[str][source]
Raises:

UnexpectedResponseError if status code of request is different from 200.

Parameters:

word (str) –

Return type:

Sequence[str]

get_usage_example(word: str) Sequence[str][source]
Raises:

UnexpectedResponseError if status code of request is different from 200.

Parameters:

word (str) –

Return type:

Sequence[str]

class danoan.word_def.core.model.PosTag(value)[source]

Bases: Enum

Part-of-speech tags as defined in: https://universaldependencies.org/u/pos/all.html

Adjective = 'Adjective'
Adposition = 'Adposition'
Adverb = 'Adverb'
Auxiliary = 'Auxiliary'
Conjunction = 'Conjunction'
CoordinatingConjunction = 'Coodrinating Conjunction'
Determiner = 'Determiner'
Interjection = 'Interjection'
Noun = 'Noun'
Numeral = 'Numeral'
Other = 'Other'
Particle = 'Particle'
Pronoun = 'Pronoun'
ProperNoun = 'Proper Noun'
Punctuation = 'Punctuation'
SubordinatingConjunction = 'Subordinating Conjunction'
Symbol = 'Symbol'
Verb = 'Verb'