<commit_before>#!/usr/bin/python
"""
Reader for event log
"""

import re
import os
import subprocess

## ================================================================
## Basic eventlog reading
## ================================================================

class LogEntry :
    """Single entry in the event log which corresponds to user message.
       It contain timestamp, message tag and raw message
    """
    def __init__(self,t,tag,msg) :
        self.t   = t
        self.tag = tag
        self.msg = msg

    def __str__(self) :
        return "t={}: [{}] {}".format(self.t, self.tag, self.msg)
    def __repr__(self) :
        return "LogEntry{{t={}: [{}] {}}}".format(self.t, self.tag, self.msg)


def read_log_entries(stream) :
    "Read stream of LogEntry from textual stream of eventlog"
    regex = re.compile("([0-9]+): cap [0-9]+: ([A-Z]+) +(.*)")
    for line in stream :
        m = regex.match(line)
        if m is None :
            continue
        t   = int( m.group(1) )<commit_msg>Correctly parse output of ghc-events<commit_after>#!/usr/bin/python
"""
Reader for event log
"""

import re
import os
import subprocess

## ================================================================
## Basic eventlog reading
## ================================================================

class LogEntry :
    """Single entry in the event log which corresponds to user message.
       It contain timestamp, message tag and raw message
    """
    def __init__(self,t,tag,msg) :
        self.t   = t
        self.tag = tag
        self.msg = msg

    def __str__(self) :
        return "t={}: [{}] {}".format(self.t, self.tag, self.msg)
    def __repr__(self) :
        return "LogEntry{{t={}: [{}] {}}}".format(self.t, self.tag, self.msg)


def read_log_entries(stream) :
    "Read stream of LogEntry from textual stream of eventlog"
    regex = re.compile(" *([0-9]+): cap [0-9]+: ([A-Z]+) +(.*)")
    for line in stream :
        m = regex.match(line)
        if m is None :
            continue
        t   = int( m.group(1) )
{'fraction_non_alphanumeric': 0.25888077858880776, 'fraction_numerical': 0.004866180048661801, 'mean_word_length': 2.931166347992352, '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': '6785262', 'n_tokens_mistral': 631, 'n_tokens_neox': 593, 'n_words': 179}