<commit_before>
__author__ = 'luigolas'

# import time
# import re
# from memory_profiler import profile
# import itertools
import sys
from package.utilities import InitializationError
import numpy as np
from package.dataset import Dataset
from package.feature_extractor import FeatureExtractor
from package.feature_matcher import FeatureMatcher


class Execution():
    def __init__(self, dataset, preproc, feature_extractor, feature_matcher, train_split=None):

        if not isinstance(dataset, Dataset):
            raise TypeError("dataset is not of class Dataset")
        else:
            self.dataset = dataset

        if train_split is not None:
            self.dataset.generate_train_set(train_split)

        self.preprocessing = preproc

        if not isinstance(feature_extractor, FeatureExtractor):
            raise TypeError("feature_extractor is not of class FeatureExtractor")
        else:
            self.feature_extractor = feature_extractor

        if not isinstance(feature_matcher, FeatureMatcher):
            raise TypeError("feature_matcher is not of class FeatureMatcher")
        else:
            self.feature_matcher = feature_matcher

        self.matching_matrix = None
        # self.ranking_matrix = None

    def set_probe(self, folder):
        self.dataset.set_probe(folder)

    def set_gallery(self, folder):
        self.dataset.set_gallery(folder)

    def set_id_regex(self, regex):
        self.dataset.set_id_regex(regex)

    def set_feature_extractor(self, feature_extractor):
        self.feature_extractor = feature_extractor

    def set_feature_matcher(self, feature_matcher):
        self.feature_matcher = feature_matcher

    def set_preprocessing(self, preprocessing):
        if self.preprocessing is None:
            self.preprocessing = [preprocessing]
        else:
            self.preprocessing.append(preprocessing)

    def set_post_ranker(self, post_ranker):
        self.post_ranker = post_ranker

    def name(self):
        """
        example:
            P2_cam1_P2_cam2_Grabcut2OptimalMask_Histogram_IIP_[5, 5, 5]_6R_3D_BHATT
        :return:
        """
        # TODO Set unique and descriptive name
        name = "%s_%s_%s" % (
            self.dataset.name(), self.feature_extractor.name, self.feature_matcher.name)
        return name
<commit_msg>Change name from set preprocessing to add<commit_after>
__author__ = 'luigolas'

# import time
# import re
# from memory_profiler import profile
# import itertools
import sys
from package.utilities import InitializationError
import numpy as np
from package.dataset import Dataset
from package.feature_extractor import FeatureExtractor
from package.feature_matcher import FeatureMatcher


class Execution():
    def __init__(self, dataset, preproc, feature_extractor, feature_matcher, train_split=None):

        if not isinstance(dataset, Dataset):
            raise TypeError("dataset is not of class Dataset")
        else:
            self.dataset = dataset

        if train_split is not None:
            self.dataset.generate_train_set(train_split)

        self.preprocessing = preproc

        if not isinstance(feature_extractor, FeatureExtractor):
            raise TypeError("feature_extractor is not of class FeatureExtractor")
        else:
            self.feature_extractor = feature_extractor

        if not isinstance(feature_matcher, FeatureMatcher):
            raise TypeError("feature_matcher is not of class FeatureMatcher")
        else:
            self.feature_matcher = feature_matcher

        self.matching_matrix = None
        # self.ranking_matrix = None

    def set_probe(self, folder):
        self.dataset.set_probe(folder)

    def set_gallery(self, folder):
        self.dataset.set_gallery(folder)

    def set_id_regex(self, regex):
        self.dataset.set_id_regex(regex)

    def set_feature_extractor(self, feature_extractor):
        self.feature_extractor = feature_extractor

    def set_feature_matcher(self, feature_matcher):
        self.feature_matcher = feature_matcher

    def add_preprocessing(self, preprocessing):
        if self.preprocessing is None:
            self.preprocessing = [preprocessing]
        else:
            self.preprocessing.append(preprocessing)

    def name(self):
        """
        example:
            P2_cam1_P2_cam2_Grabcut2OptimalMask_Histogram_IIP_[5, 5, 5]_6R_3D_BHATT
        :return:
        """
        # TODO Set unique and descriptive name
        name = "%s_%s_%s" % (
            self.dataset.name(), self.feature_extractor.name, self.feature_matcher.name)
        return name

{'fraction_non_alphanumeric': 0.06990881458966565, 'fraction_numerical': 0.004342162396873643, 'mean_word_length': 2.920851063829787, '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': '5483507', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1271, 'n_words': 313}