<commit_before>package Dudl::StorUnit;

use strict;
use warnings;

use Dudl::DBo;
use Carp;

our @ISA = qw(Dudl::DBo);

my %scheme = (
	name => 'stor_unit',
	cols => [qw( id collection colnum volname size )],
	pkey => 'id',
	);

sub table_scheme {
	return \%scheme;
}

sub load_path {
	my $proto = shift;
	my $a = ref $_[0] eq "HASH" ? shift : { @_ };

	croak "missing path argument" unless exists $a->{path};
	$a->{path} =~ /([^\d\/]+)(\d+)$/
		or croak "invalid path";
	$a->{where} = {
		collection => "'$1'", # TODO: quote properly 
		colnum => $2,
		 };

	$proto->load( $a ), 
}

sub dir {
	my $self = shift;
	my $path = shift;

	return sprintf( "%s/%s%04d",
		$self->{data}{collection}, 
		$self->{data}{collection}, 
		$self->{data}{colnum} );<commit_msg>strip trailing slash from path names, too<commit_after>package Dudl::StorUnit;

use strict;
use warnings;

use Dudl::DBo;
use Carp;

our @ISA = qw(Dudl::DBo);

my %scheme = (
	name => 'stor_unit',
	cols => [qw( id collection colnum volname size )],
	pkey => 'id',
	);

sub table_scheme {
	return \%scheme;
}

sub load_path {
	my $proto = shift;
	my $a = ref $_[0] eq "HASH" ? shift : { @_ };

	croak "missing path argument" unless exists $a->{path};
	$a->{path} =~ /([^\d\/]+)(\d+)\/*$/
		or croak "invalid path";
	$a->{where} = {
		collection => "'$1'", # TODO: quote properly 
		colnum => $2,
		 };

	$proto->load( $a ), 
}

sub dir {
	my $self = shift;
	my $path = shift;

	return sprintf( "%s/%s%04d",
		$self->{data}{collection}, 
		$self->{data}{collection}, 
		$self->{data}{colnum} );
{'fraction_non_alphanumeric': 0.2189311010946555, 'fraction_numerical': 0.00643915003219575, 'mean_word_length': 3.5306122448979593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '2306739', 'n_tokens_mistral': 675, 'n_tokens_neox': 636, 'n_words': 164}