<commit_before><commit_msg>added functions to parse PADX for REM carnival data; waiting for upcoming event to add godfest support<commit_after>import collections
import os.path

import requests
from lxml import html


Event = collections.namedtuple('Event', ['title', 'members'])

PADXURL = 'http://puzzledragonx.com/'
REMTITLE = '//table[@id="event"]//a[@id="rareegg"]/../div/h2'
# rem icon src is spacer.gif until loaded, must use data-original attribute
REMMEMBERS = '//td[@class="rareegg"]//td[@class="peticon"]/a/img/@data-original'


def fetch(url):
    
    r = requests.get(url)
    
    return html.document_fromstring(r.text)


def parse_rem(document):
    
    title = document.xpath(REMTITLE)[0].text
    members = {id_from_path(path) for path in document.xpath(REMMEMBERS)}
    
    return Event(title, members)


def id_from_path(path):
    
    base = os.path.basename(path)
    id, ext = os.path.splitext(base)
    
    return int(id)


if __name__ == '__main__':
    doc = fetch(PADXURL)
    event = parse_rem(doc)
    
    print(event)
{'fraction_non_alphanumeric': 0.13580246913580246, 'fraction_numerical': 0.001899335232668566, 'mean_word_length': 3.7477477477477477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '2777288', 'n_tokens_mistral': 377, 'n_tokens_neox': 361, 'n_words': 83}