rics.translation.offline.types#

Types used for offline translation.

Classes

PlaceholderTranslations(source, ...[, id_pos])

Matrix of ID translation components returned by fetchers.

class PlaceholderTranslations(source: SourceType, placeholders: Tuple[str, ...], records: Sequence[Sequence[Any]], id_pos: int = -1)[source]#

Bases: Generic[SourceType]

Matrix of ID translation components returned by fetchers.

MakeTypes#

alias of Union[PlaceholderTranslations, DataFrame, Dict[str, Sequence[Any]]]

source: SourceType#

Source from which translations were retrieved.

placeholders: Tuple[str, ...]#

Names of placeholders in the order in which they appear in records.

records: Sequence[Sequence[Any]]#

Matrix of shape N x M where N is the number of IDs returned and M is the length of placeholders.

id_pos: int = -1#

Position if the the ID placeholder in placeholders.

classmethod make(source: SourceType, data: Union[PlaceholderTranslations, DataFrame, Dict[str, Sequence[Any]]]) PlaceholderTranslations[SourceType][source]#

Try to make in instance from arbitrary input data.

Parameters:
  • source – Source label for the translations.

  • data – Some data to convert to a PlaceholderTranslations instance.

Returns:

A new PlaceholderTranslations instance.

Raises:

TypeError – If data cannot be converted.

to_dict(max_rows: int = 0) Dict[str, Sequence[Any]][source]#

Create a dict representation of the translations.

static to_dicts(source_translations: Dict[SourceType, PlaceholderTranslations[SourceType]], max_rows: int = 0) Dict[SourceType, Dict[str, Sequence[Any]]][source]#

Create a nested dict representation of the translations.

classmethod from_dataframe(source: SourceType, data: DataFrame) PlaceholderTranslations[SourceType][source]#

Create instance from a pandas DataFrame.

classmethod from_dict(source: SourceType, data: Dict[str, Sequence[Any]]) PlaceholderTranslations[SourceType][source]#

Create instance from a dict.