Lookup

DataSource

class cardbuilder.lookup.data_source.DataSource[source]

Bases: abc.ABC

The base class for all data sources, responsible for looking up various linguistic data about words. It implements basic logic for generating SQLite tables with the default schema (word TEXT, content) where the content type is defined by the class variable content_type.

class cardbuilder.lookup.data_source.WebApiDataSource(enable_cache_retrieval=True)[source]

Bases: cardbuilder.lookup.data_source.DataSource, abc.ABC

The base class for data sources which directly look up data somewhere online, either by calling an APi or scraping HTML.

class cardbuilder.lookup.data_source.ExternalDataDataSource[source]

Bases: cardbuilder.lookup.data_source.DataSource, abc.ABC

The base class for data sources which depend on external data such as downloaded files. Contains logic for ingesting these files into SQlite tables and looking up data from those tables.

class cardbuilder.lookup.data_source.AggregatingDataSource[source]

Bases: cardbuilder.lookup.data_source.DataSource, abc.ABC

The base class for data sources that own other data sources and don’t have a sqlite table of their own.

LookupData

class cardbuilder.lookup.lookup_data.LookupData(word, found_form, raw_data, data)[source]

An empty base class for all word data so that a common type exists. Data sources all return instances of a subclass of this type, as defined by their @outputs decorator.

Values

class cardbuilder.lookup.value.Value[source]

Abstract base class for all values.

class cardbuilder.lookup.value.SingleValue(val)[source]

Bases: cardbuilder.lookup.value.Value

Represents a single value, such as a part of speech, IPA for a word, or a word itself.

get_data()[source]
Return type

str

input_type

alias of str

class cardbuilder.lookup.value.MultiValue(list_header_tuples)[source]

Bases: cardbuilder.lookup.value.Value

Represents multiple values, each optionally paired with a header value. Useful for capturing pairs or mappings of values, such as words where pronunciation is different based on the part of speech. For straightforward lists of values, use ListValue

get_data()[source]
Return type

List[Tuple[SingleValue, Optional[SingleValue]]]

class cardbuilder.lookup.value.ListValue(value_list)[source]

Bases: cardbuilder.lookup.value.Value

Represents a list of values, such as multiple possible parts of speech or multiple definitions.

get_data()[source]
Return type

List[SingleValue]

input_type

alias of List[str]

class cardbuilder.lookup.value.MultiListValue(list_header_tuples)[source]

Bases: cardbuilder.lookup.value.Value

Represents multiple lists of values, each optionally paired with a header value. Most commonly used in cases where a word has multiple possible parts of speech, and there is a list of values (such as definitions) associated with each part of speech.

get_data()[source]
Return type

List[Tuple[ListValue, Optional[SingleValue]]]

class cardbuilder.lookup.value.LinksValue(link_data)[source]

Bases: cardbuilder.lookup.value.Value

Represents a link in a dictionary to another word. Useful only in very specific cases.

get_data()[source]
Return type

List[ForwardRef]