<commit_before>package SeriesInfo::NameParser;

sub parse {
    my ($s) = @_;

    $_ = $s;
    return build($1, $2, $3, $4, "simple") if (m/(.+?) (\d?) (\d?) (.+)$/);
    return build($1, $2, $3, $4, "SxxExx") if (m/(.+?)\WS(\d\d?)E(\d\d?)\W(.+)$/);
    return build($1, $2, $3, $4,  "__x__") if (m/(.+?)\D(\d\d?)x(\d\d?)\W(.+)$/);
    return;
}

sub build {
    my ($show, $season, $number, $title, $match) = @_;
    my $year;
    if ($show =~ /(.+)\W+(\d\d\d\d)/) {
        $show = $1;
        $year = $2 + 0;
    }
    return {
        show => $show,
        year => $year,
        season => $season + 0,
        number => $number + 0,
        title => $title,
        match => $match,
    };
}

1;<commit_msg>convert to int before building hash<commit_after>package SeriesInfo::NameParser;

sub parse {
    my ($s) = @_;

    $_ = $s;
    return build($1, $2, $3, $4, "simple") if (m/(.+?) (\d?) (\d?) (.+)$/);
    return build($1, $2, $3, $4, "SxxExx") if (m/(.+?)\WS(\d\d?)E(\d\d?)\W(.+)$/);
    return build($1, $2, $3, $4,  "__x__") if (m/(.+?)\D(\d\d?)x(\d\d?)\W(.+)$/);
    return;
}

sub build {
    my ($show, $season, $number, $title, $match) = @_;
    my $year;
    if ($show =~ /(.+)\W+(\d\d\d\d)/) {
        $show = $1;
        $year = $2 + 0;
    }
    $season += 0;
    $number += 0;

    return {
        show => $show,
        year => $year,
        season => $season,
        number => $number,
        title => $title,
        match => $match,
    };
}

1;
{'fraction_non_alphanumeric': 0.2880324543610548, 'fraction_numerical': 0.02434077079107505, 'mean_word_length': 1.9191321499013807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '480729', 'n_tokens_mistral': 657, 'n_tokens_neox': 634, 'n_words': 142}