<commit_before># <NAME> <<EMAIL>>

##____________________________________________________________________________||
class GenericKeyComposer(object):
    def __init__(self, varNames, binnings, indices = None):
        self.varNames = varNames
        self.binnings = binnings
        self.indices = indices if indices is not None else [None]*len(self.varNames)

    def begin(self, event): pass

    def __call__(self, event):
        ret = [ ]
        for varName, binning, index in zip(self.varNames, self.binnings, self.indices):
            var = getattr(event, varName)
            if index is not None:
                if len(var) <= index: return ()
                var = var[index]
            var_bin = binning(var)
            if var_bin is None: return ()
            ret.append(var_bin)
        return (tuple(ret), )

##____________________________________________________________________________||
class GenericKeyComposerFactory(object):
    def __init__(self, varNames, binnings, indices = None):
        self.varNames = varNames
        self.binnings = binnings
        self.indices = indices
    def __call__(self):
        return GenericKeyComposer(varNames = self.varNames, binnings = self.binnings, indices = self.indices)

##____________________________________________________________________________||<commit_msg>rename varNames branchNames in GenericKeyComposer<commit_after># <NAME> <<EMAIL>>

##____________________________________________________________________________||
class GenericKeyComposer(object):
    def __init__(self, branchNames, binnings, indices = None):
        self.branchNames = branchNames
        self.binnings = binnings
        self.indices = indices if indices is not None else [None]*len(self.branchNames)

    def begin(self, event): pass

    def __call__(self, event):
        ret = [ ]
        for varName, binning, index in zip(self.branchNames, self.binnings, self.indices):
            var = getattr(event, varName)
            if index is not None:
                if len(var) <= index: return ()
                var = var[index]
            var_bin = binning(var)
            if var_bin is None: return ()
            ret.append(var_bin)
        return (tuple(ret), )

##____________________________________________________________________________||
class GenericKeyComposerFactory(object):
    def __init__(self, branchNames, binnings, indices = None):
        self.branchNames = branchNames
        self.binnings = binnings
        self.indices = indices
    def __call__(self):
        return GenericKeyComposer(branchNames = self.branchNames, binnings = self.binnings, indices = self.indices)

##____________________________________________________________________________||
{'fraction_non_alphanumeric': 0.08984660336011688, 'fraction_numerical': 0.0, 'mean_word_length': 3.2333848531684697, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1445013', 'n_tokens_mistral': 666, 'n_tokens_neox': 658, 'n_words': 178}