<commit_before>"""Contains data handling functionality. The DataHandler class is resposible
for serving all data necessary for the recommender"""


class DataHandler(object):
    """Represents the interface each data provider class should implement."""

    def get_content(self):
        """Returns a dictionary containing the data on which recommendations
        are based."""
        raise NotImplementedError

    def get_top_matching_items(self, item):
        """Returns a dictionary containing the top matching items to
        a given item.

        parameters:
            item The item for which the top matches are returned"""
        raise NotImplementedError

    def update_top_matching_items(self, top_matches):
        """Save updated data for item similarities

        parameters:
            top_mathces A dictionary containing items that should be updated"""
        raise NotImplementedError

    def transposd_content(self):
        """Transpose the content so that properties become keys
        and keys become properties."""
        result = {}
        for key, value in self.get_content().items():
            for property, score in value.items():
                result.setdefault(property, {})
                result[property][key] = score
        return result<commit_msg>Had a typo in the transposed_data method.<commit_after>"""Contains data handling functionality. The DataHandler class is resposible
for serving all data necessary for the recommender"""


class DataHandler(object):
    """Represents the interface each data provider class should implement."""

    def get_content(self):
        """Returns a dictionary containing the data on which recommendations
        are based."""
        raise NotImplementedError

    def get_top_matching_items(self, item):
        """Returns a dictionary containing the top matching items to
        a given item.

        parameters:
            item The item for which the top matches are returned"""
        raise NotImplementedError

    def update_top_matching_items(self, top_matches):
        """Save updated data for item similarities

        parameters:
            top_mathces A dictionary containing items that should be updated"""
        raise NotImplementedError

    def transposed_content(self):
        """Transpose the content so that properties become keys
        and keys become properties."""
        result = {}
        for key, value in self.get_content().items():
            for property, score in value.items():
                result.setdefault(property, {})
                result[property][key] = score
        return result
{'fraction_non_alphanumeric': 0.06874287884542347, 'fraction_numerical': 0.0, 'mean_word_length': 2.7203389830508473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365270', 'n_tokens_mistral': 599, 'n_tokens_neox': 575, 'n_words': 249}