src.fairreckitlib.data.ratings.rating_converter_factory

This module contains functionality to create the rating converter factory.

Functions:

create_rating_converter_factory: create a factory with rating converters.

This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)

 1"""This module contains functionality to create the rating converter factory.
 2
 3Functions:
 4
 5    create_rating_converter_factory: create a factory with rating converters.
 6
 7This program has been developed by students from the bachelor Computer Science at
 8Utrecht University within the Software Project course.
 9© Copyright Utrecht University (Department of Information and Computing Sciences)
10"""
11
12from ...core.config.config_factories import GroupFactory
13from ..data_modifier import DataModifierFactory, create_data_modifier_factory
14from ..set.dataset_registry import DataRegistry
15from .convert_constants import KEY_RATING_CONVERTER, CONVERTER_KL, CONVERTER_RANGE
16from .range_converter import create_range_converter, create_range_converter_params
17from .kl_converter import create_kl_converter, create_kl_converter_params
18
19
20def create_rating_converter_factory(data_registry: DataRegistry) -> GroupFactory:
21    """Create the rating converter factory.
22
23    Args:
24
25        data_registry: the data registry with available datasets.
26
27    Returns:
28        the factory with all available converters.
29    """
30    def on_add_entries(matrix_factory: DataModifierFactory, _) -> None:
31        """Add the rating converters to the matrix factory.
32
33        Args:
34            matrix_factory: the factory to add the converters to.
35            _: the dataset associated with the matrix factory.
36
37        """
38        if 'artist' in matrix_factory.get_name():
39            # add kl converter
40            matrix_factory.add_obj(
41                CONVERTER_KL,
42                create_kl_converter,
43                create_kl_converter_params
44            )
45
46        # add range converter
47        matrix_factory.add_obj(
48            CONVERTER_RANGE,
49            create_range_converter,
50            create_range_converter_params
51        )
52
53    return create_data_modifier_factory(data_registry, KEY_RATING_CONVERTER, on_add_entries)
def create_rating_converter_factory( data_registry: src.fairreckitlib.data.set.dataset_registry.DataRegistry) -> src.fairreckitlib.core.config.config_factories.GroupFactory:
21def create_rating_converter_factory(data_registry: DataRegistry) -> GroupFactory:
22    """Create the rating converter factory.
23
24    Args:
25
26        data_registry: the data registry with available datasets.
27
28    Returns:
29        the factory with all available converters.
30    """
31    def on_add_entries(matrix_factory: DataModifierFactory, _) -> None:
32        """Add the rating converters to the matrix factory.
33
34        Args:
35            matrix_factory: the factory to add the converters to.
36            _: the dataset associated with the matrix factory.
37
38        """
39        if 'artist' in matrix_factory.get_name():
40            # add kl converter
41            matrix_factory.add_obj(
42                CONVERTER_KL,
43                create_kl_converter,
44                create_kl_converter_params
45            )
46
47        # add range converter
48        matrix_factory.add_obj(
49            CONVERTER_RANGE,
50            create_range_converter,
51            create_range_converter_params
52        )
53
54    return create_data_modifier_factory(data_registry, KEY_RATING_CONVERTER, on_add_entries)

Create the rating converter factory.

Args:

data_registry: the data registry with available datasets.

Returns: the factory with all available converters.