<commit_before># -*- coding: utf-8 -*-

from sklearn_porter.enums import Language, Method, Template


class SklearnPorterError(Exception):
    def __init__(self, message: str):
        self.message = message
        super().__init__(message)


class NotFittedEstimatorError(SklearnPorterError):
    def __init__(self, message: str):
        hint = 'The passed estimator of kind `{}` ' \
               'is not fitted.'.format(message)
        self.message = hint
        super().__init__(self.message)


class NotSupportedError(SklearnPorterError):
    def __init__(self, message: str):
        hint = 'You can check the documentation ' \
               'or create a new feature request at ' \
               'https://github.com/nok/sklearn-porter .'
        self.message = message + '\n' + hint
        super().__init__(self.message)


class InvalidMethodError(SklearnPorterError):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(m.value) for m in list(Method)])
        hint = 'The passed method `{}` is invalid. ' \
               'Valid methods are: {}.'.format(message, opts)
        self.message = hint
        super().__init__(self.message)


class InvalidLanguageError(SklearnPorterError):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(l.value.KEY) for l in list(Language)])
        hint = 'The passed language `{}` is invalid. ' \
               'Valid languages are: {}.'.format(message, opts)
        self.message = hint
        super().__init__(self.message)


class InvalidTemplateError(SklearnPorterError):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(t.value) for t in list(Template)])
        hint = 'The passed template `{}` is invalid. ' \
               'Valid templates are: {}.'.format(message, opts)
        self.message = hint
        super().__init__(self.message)
<commit_msg>feature/oop-api-refactoring: Make exceptions simpler and more compact<commit_after># -*- coding: utf-8 -*-

from sklearn_porter.enums import Language, Method, Template


class NotFittedEstimatorError(Exception):
    def __init__(self, message: str):
        self.message = 'The passed estimator of kind `{}` ' \
                       'is not fitted.'.format(message)
        super().__init__(self.message)


class NotSupportedYetError(Exception):
    def __init__(self, message: str):
        hint = 'You can check the documentation ' \
               'or create a new feature request at ' \
               'https://github.com/nok/sklearn-porter .'
        self.message = message + '\n\n' + hint
        super().__init__(self.message)


class InvalidMethodError(Exception):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(m.value) for m in list(Method)])
        self.message = 'The passed method `{}` is invalid. ' \
                       'Valid methods are: {}.'.format(message, opts)
        super().__init__(self.message)


class InvalidLanguageError(Exception):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(l.value.KEY) for l in list(Language)])
        self.message = 'The passed language `{}` is invalid. ' \
                       'Valid languages are: {}.'.format(message, opts)
        super().__init__(self.message)


class InvalidTemplateError(Exception):
    def __init__(self, message: str):
        opts = ', '.join(['`{}`'.format(t.value) for t in list(Template)])
        self.message = 'The passed template `{}` is invalid. ' \
                       'Valid templates are: {}.'.format(message, opts)
        super().__init__(self.message)

{'fraction_non_alphanumeric': 0.14372581536760642, 'fraction_numerical': 0.000552791597567717, 'mean_word_length': 2.5867195242814667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1066281', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1021, 'n_words': 267}