<commit_before>class Element(dict):

    fields = {}

    def __init__(self, fields={}, element=None, keys=None):
        self.element = element
        dict.__init__(self, self.fields)
        if not keys:
            keys = fields.keys()
        for key in keys:
            if key in fields:
                self[key] = fields[keys] 

    @staticmethod
    def get(xml, xpath, element_class=Element, fields=None):
        """
        Search the specifed xml node for elements that match the 
        specified xpath query. 
        Returns a list of objectes instanced by the specfied element_class.
        """
        if not fields:
           fields = element_class.fields.keys()
        elems = xml.xpath(xpath, namespaces)
        objs = []
        for elem in elems:
            if not fields:
                obj = element_class(elem.attrib, elem)
            else:
                obj = element_class({}, elem)
                for field in fields:
                    if field in elem.attrib:<commit_msg>fix NameError<commit_after>class Element(dict):

    fields = {}

    def __init__(self, fields={}, element=None, keys=None):
        self.element = element
        dict.__init__(self, self.fields)
        if not keys:
            keys = fields.keys()
        for key in keys:
            if key in fields:
                self[key] = fields[keys] 

    @staticmethod
    def get(xml, xpath, element_class=None, fields=None):
        """
        Search the specifed xml node for elements that match the 
        specified xpath query. 
        Returns a list of objectes instanced by the specfied element_class.
        """
        if not element_class:
            element_class = Element
        if not fields:
           fields = element_class.fields.keys()
        elems = xml.xpath(xpath, namespaces)
        objs = []
        for elem in elems:
            if not fields:
                obj = element_class(elem.attrib, elem)
            else:
                obj = element_class({}, elem)
                for field in fields:
                    if field in elem.attrib:
{'fraction_non_alphanumeric': 0.084089823220258, 'fraction_numerical': 0.0, 'mean_word_length': 1.6641221374045803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '4097896', 'n_tokens_mistral': 574, 'n_tokens_neox': 551, 'n_words': 179}