<commit_before>"""
Classes for converting from the output of a model/data comparison
to the value required for particular score type.
"""

from string import Template
from .scores import BooleanScore

class Converter(object):
    """
    Base converter class.  
    Only derived classes should be used in applications.
    """

    @property
    def description(self):
        s = self.__doc__.strip().replace('\n','')
        t = Template(s)
        s = t.safe_substitute(self.__dict__)
        return s

    def _convert(self,score):
        """
        Takes the score attribute of a score instance
        and recasts it as instance of another score type.  
        """
        NotImplementedError(("The '_convert' method for %s "
                                    "it not implemented." %
                                    self.__class__.__name__))

    def convert(self,score):
        new_score = self._convert(score.score)
        for key,value in score.__dict__.items():
            if key != 'score':<commit_msg>Updated description generation for converters<commit_after>"""
Classes for converting from the output of a model/data comparison
to the value required for particular score type.
"""

from string import Template
from .scores import BooleanScore

class Converter(object):
    """
    Base converter class.  
    Only derived classes should be used in applications.
    """

    @property
    def description(self):
        s = ' '.join([si.strip() for si in self.__doc__.split('\n')]).strip()
        t = Template(s)
        s = t.safe_substitute(self.__dict__)
        return s

    def _convert(self,score):
        """
        Takes the score attribute of a score instance
        and recasts it as instance of another score type.  
        """
        NotImplementedError(("The '_convert' method for %s "
                                    "it not implemented." %
                                    self.__class__.__name__))

    def convert(self,score):
        new_score = self._convert(score.score)
        for key,value in score.__dict__.items():
            if key != 'score':
{'fraction_non_alphanumeric': 0.09336492890995261, 'fraction_numerical': 0.0, 'mean_word_length': 2.1135693215339235, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4188264', 'n_tokens_mistral': 543, 'n_tokens_neox': 526, 'n_words': 187}