<commit_before>#!/usr/bin/perl
use warnings;

sub emit;

sub is_zero
{
	return shift =~ /^(space|zero)$/;
}

my %sizes = (
	'byte'  => 1,
	'word'  => 2,
	'long'  => 4,
	'quad'  => 8,
);
my %sizes_r = map { $sizes{$_} => $_ } keys %sizes;

my @parts; # { size, value } or { lbl }
my $any = 0;

while(<>){
	s/#.*//;
	if(/^[ \t]*\.(byte|word|long|quad|zero|space)[ \t]+(.*)/){
		my $is_zero = is_zero($1);

		(my $rest = $2) =~ s/ +$//;

		for(split /, */, $rest){
			my $r;
			if($is_zero){
				$r = { size  => $_,
					     value => 0 };
			}else{
				$r = { size  => $sizes{$1},
					     value => $_ };
			}

			emit($r);
		}
		$any = 1;
	}elsif(/(.*): *$/){
		emit({ lbl => $1 });
		$any = 1;
	}
}

die "$0: no input\n" unless $any;

sub flush;
sub emit2;
my $last;
END {
	flush();
}<commit_msg>Trim leading underscores for tests<commit_after>#!/usr/bin/perl
use warnings;

sub emit;

sub is_zero
{
	return shift =~ /^(space|zero)$/;
}

my %sizes = (
	'byte'  => 1,
	'word'  => 2,
	'long'  => 4,
	'quad'  => 8,
);
my %sizes_r = map { $sizes{$_} => $_ } keys %sizes;

my @parts; # { size, value } or { lbl }
my $any = 0;

while(<>){
	s/#.*//;
	if(/^[ \t]*\.(byte|word|long|quad|zero|space)[ \t]+(.*)/){
		my $is_zero = is_zero($1);

		(my $rest = $2) =~ s/ +$//;

		for(split /, */, $rest){
			my $r;
			if($is_zero){
				$r = { size  => $_,
					     value => 0 };
			}else{
				$r = { size  => $sizes{$1},
					     value => $_ };
			}

			emit($r);
		}
		$any = 1;
	}elsif(/(.*): *$/){
		(my $lbl = $1) =~ s/^_//;
		emit({ lbl => $lbl });
		$any = 1;
	}
}

die "$0: no input\n" unless $any;

sub flush;
sub emit2;
my $last;
END {
	flush();
}
{'fraction_non_alphanumeric': 0.278419452887538, 'fraction_numerical': 0.01702127659574468, 'mean_word_length': 2.3052208835341363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2196393', 'n_tokens_mistral': 879, 'n_tokens_neox': 776, 'n_words': 176}