<commit_before>from bs4 import BeautifulSoup
import re
import dateutil.parser as dparser

def parse_html(html):
    soup = BeautifulSoup(html, 'html5lib')
    recordings = [
        parse_link_element(link)
        for link in soup.find_all('a')
        if link.get('href') and link.get('href').endswith('mp3')
    ]

    return recordings

def parse_link_element(link):
    time_reg = r'\(([\d]*:)?([\d]*):([\d]*)\)'

    full_title_text = ' '.join([
        string
        for string in (
            link.find_previous('img', src='/images/play.gif')
            .find_previous('a')
            .find_previous('li')
            .stripped_strings
        )
        if string.lower() != 'mp3'
    ])

    title = re.split(time_reg, full_title_text)[0].strip()

    file_length = (re.search(time_reg, full_title_text)
                   .group()
                   .replace('(', '')
                   .replace(')', ''))

    event = ' '.join(link.find_previous('h2').stripped_strings)

    try:
        date = dparser.parse(event, fuzzy=True).isoformat()
    except ValueError as err:
        date = ''

    return {
        'title': title,
        'length': file_length,
        'link': link.get('href'),
        'event': event,
        'date': date
    }<commit_msg>refinging the process after errors<commit_after>from bs4 import BeautifulSoup
import re
import dateutil.parser as dparser

def parse_html(html):
    soup = BeautifulSoup(html, 'html5lib')
    recordings = [
        parse_link_element(link)
        for link in soup.find_all('a')
        if link.get('href') and link.get('href').endswith('mp3')
    ]

    return recordings

def parse_link_element(link):
    time_reg = r'\(([\d]*:)?([\d]*):([\d]*)\)'

    reading_elem = link.find_parent('li')
    if not reading_elem:
        reading_elem = link.previous_sibling

    event_elem = link.find_previous(re.compile("^h"))

    try:
        full_title_text = ' '.join([
            string
            for string in reading_elem.stripped_strings
            if string.lower() != 'mp3'
        ])
    except AttributeError as err:
        full_title_text = reading_elem

    title = re.split(time_reg, full_title_text)[0].strip()

    file_length = (re.search(time_reg, full_title_text)
                   .group()
                   .replace('(', '')
                   .replace(')', ''))

    event = ' '.join(event_elem.stripped_strings)

    try:
        date = dparser.parse(event, fuzzy=True).isoformat()
    except ValueError as err:
        date = ''

    return {
        'title': title,
        'length': file_length,
        'link': link.get('href'),
        'event': event,
        'date': date
    }
{'fraction_non_alphanumeric': 0.1462228870605834, 'fraction_numerical': 0.004113687359760658, 'mean_word_length': 2.192124105011933, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2901839', 'n_tokens_mistral': 861, 'n_tokens_neox': 830, 'n_words': 168}