<commit_before>class ErrorType(object):
    def __init__(self, osm_type):
        if osm_type is None:
            raise ValueError("The passed osm_type is not set")
        self.osm_type = osm_type

    def apply_fix(self, kort_fix):
        pass


class MissingTagErrorType(ErrorType):
    @classmethod
    def handles_error(cls, error):
        return False

    def apply_fix(self, kort_fix):
        osm_tag = kort_fix['osm_tag']
        if osm_tag in self.osm_type['tag']:
            raise ErrorTypeError(
                "Tag %s already exists (%s)"
                % (osm_tag, self.osm_type['tag'][osm_tag])
            )
        self.osm_type['tag'][osm_tag] = kort_fix['answer']
        return (
            self.osm_type,
            "Set tag '%s' to '%s'" % (osm_tag, kort_fix['answer'])
        )


class PoiNameErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'poi_name'


class MissingTrackTypeErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'missing_track_type'


class MissingMaxspeedErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'missing_maxspeed'


class ReligionErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'religion'


class LanguageErrorType(ErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'language_unknown'

    def apply_fix(self, kort_fix):
        try:
            orig_tag = kort_fix['osm_tag'].replace(':XX', '')
            new_tag = '%s:%s' % (orig_tag, kort_fix['answer'])
            orig_value = self.osm_type['tag'][orig_tag]

            if (new_tag in self.osm_type['tag'] and
                    self.osm_type['tag'][new_tag] == orig_value):
                raise ErrorTypeError("The fix has already been applied")

            self.osm_type['tag'].update({
                new_tag: orig_value
            })
        except KeyError, e:<commit_msg>Added missing_cuisine and motorway_ref error types<commit_after>class ErrorType(object):
    def __init__(self, osm_type):
        if osm_type is None:
            raise ValueError("The passed osm_type is not set")
        self.osm_type = osm_type

    def apply_fix(self, kort_fix):
        pass


class MissingTagErrorType(ErrorType):
    @classmethod
    def handles_error(cls, error):
        return False

    def apply_fix(self, kort_fix):
        osm_tag = kort_fix['osm_tag']
        if osm_tag in self.osm_type['tag']:
            raise ErrorTypeError(
                "Tag %s already exists (%s)"
                % (osm_tag, self.osm_type['tag'][osm_tag])
            )
        self.osm_type['tag'][osm_tag] = kort_fix['answer']
        return (
            self.osm_type,
            "Set tag '%s' to '%s'" % (osm_tag, kort_fix['answer'])
        )


class PoiNameErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'poi_name'


class MissingTrackTypeErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'missing_track_type'


class MissingMaxspeedErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'missing_maxspeed'


class ReligionErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'religion'


class MotorwayRefErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'motorway_ref'


class MissingCuisineErrorType(MissingTagErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'missing_cuisine'


class LanguageErrorType(ErrorType):
    @classmethod
    def handles_error(cls, error):
        return error == 'language_unknown'

    def apply_fix(self, kort_fix):
        try:
            orig_tag = kort_fix['osm_tag'].replace(':XX', '')
            new_tag = '%s:%s' % (orig_tag, kort_fix['answer'])
            orig_value = self.osm_type['tag'][orig_tag]

            if (new_tag in self.osm_type['tag'] and
                    self.osm_type['tag'][new_tag] == orig_value):
                raise ErrorTypeError("The fix has already been applied")

            self.osm_type['tag'].update({
                new_tag: orig_value
            })
        except KeyError, e:
{'fraction_non_alphanumeric': 0.10830163347505034, 'fraction_numerical': 0.0, 'mean_word_length': 2.5932475884244375, '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': '2073631', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1367, 'n_words': 294}