rics.translation.offline.types#
Types used for offline translation.
Classes
|
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.
- source: SourceType#
Source from which translations were retrieved.
- 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.
- classmethod make(source: SourceType, data: Union[PlaceholderTranslations, DataFrame, Dict[str, Sequence[Any]]]) PlaceholderTranslations[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], 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[source]#
Create instance from a pandas DataFrame.
- classmethod from_dict(source: SourceType, data: Dict[str, Sequence[Any]]) PlaceholderTranslations[source]#
Create instance from a dict.