<commit_before>package Updater;

use Moose;
use InterMine::Model::Attribute;
use Webservice::InterMine::Path qw(type_of class_of next_class);
use InterMine::TypeLibrary (qw/Model File/);
use MooseX::Types::Moose   (qw/HashRef Str/);
use YAML;
use Scalar::Util qw(blessed);

has model => (
    is  => 'ro',
    isa => Model,
    handles => {
        class => 'get_classdescriptor_by_name',
    },
);

has logger => (
    is      => 'ro',
    isa     => 'Log::Handler',
    handles => [ 'warning', 'info', 'error', 'debug', ],
);

my $parse_changes = sub {
    my $self = shift;
    my $file = shift;
    my ( $delete_these, $translate_these ) = YAML::LoadFile($file);
    $delete_these = { map { $_ => 1 } @$delete_these };
    $self->set_deletions($delete_these);
    $self->set_translations($translate_these);
};

has changes => (
    is      => 'ro',
    isa     => File,
    trigger => $parse_changes,
);

has deletions => (
    isa     => HashRef,
    writer  => 'set_deletions',
    traits  => ['Hash'],
    handles => { has_deletion => 'exists', },
);

has translations => (
    isa     => HashRef,
    writer  => 'set_translations',
    traits  => ['Hash'],
    handles => { get_translation_for => 'get', },
);

sub knows_about_deletion_of {
    my $self = shift;
    my $key  = shift;
    my $prefix = $self->prefix;
    $key =~ s/$prefix//;
    return $self->has_deletion($key);
}

has processed_paths => (
    isa     => HashRef,
    traits  => ['Hash'],
    handles => {
        has_processed        => 'exists',
        processed_version_of => 'accessor',
        delete_processed     => 'delete',
    },
);

has prefix => (
    isa     => Str,
    is      => 'ro',<commit_msg>Attributes with hash traits now have hash defaults<commit_after>package Updater;

use Moose;
use InterMine::Model::Attribute;
use Webservice::InterMine::Path qw(type_of class_of next_class);
use InterMine::TypeLibrary (qw/Model File/);
use MooseX::Types::Moose   (qw/HashRef Str/);
use YAML;
use Scalar::Util qw(blessed);

has model => (
    is  => 'ro',
    isa => Model,
    handles => {
        class => 'get_classdescriptor_by_name',
    },
);

has logger => (
    is      => 'ro',
    isa     => 'Log::Handler',
    handles => [ 'warning', 'info', 'error', 'debug', ],
);

my $parse_changes = sub {
    my $self = shift;
    my $file = shift;
    my ( $delete_these, $translate_these ) = YAML::LoadFile($file);
    $delete_these = { map { $_ => 1 } @$delete_these };
    $self->set_deletions($delete_these);
    $self->set_translations($translate_these);
};

has changes => (
    is      => 'ro',
    isa     => File,
    trigger => $parse_changes,
);

has deletions => (
    isa     => HashRef,
    writer  => 'set_deletions',
    traits  => ['Hash'],
    default => sub { {} },
    handles => { has_deletion => 'exists', },
);

has translations => (
    isa     => HashRef,
    writer  => 'set_translations',
    traits  => ['Hash'],
    default => sub { {} },
    handles => { get_translation_for => 'get', },
);

sub knows_about_deletion_of {
    my $self = shift;
    my $key  = shift;
    my $prefix = $self->prefix;
    $key =~ s/$prefix//;
    return $self->has_deletion($key);
}

has processed_paths => (
    isa     => HashRef,
    traits  => ['Hash'],
    default => sub { {} },
    handles => {
        has_processed        => 'exists',
        processed_version_of => 'accessor',
        delete_processed     => 'delete',
    },
);

has prefix => (
    isa     => Str,
    is      => 'ro',
{'fraction_non_alphanumeric': 0.17591533180778032, 'fraction_numerical': 0.0005720823798627002, 'mean_word_length': 2.6733193277310923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 86, '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': '7047564', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1199, 'n_words': 266}