<commit_before>package Resource;

use strict;
use warnings;

use DateTimeFactory;
use ScheduleUtils;
use Google;

sub new {
	my ($class, $record) = @_;
	my %self = ((dtf => DateTimeFactory->new()), %$record);
	bless \%self, $class;
}

sub vacancies {
	my ($self, $duration, $span) = @_;

	my $events = Google::CalendarAPI::Events::list($self->{calendar}, $span);

	my @free = map { $_->{span} } grep { $_->{transparent} } @$events;
	my @busy = map { $_->{span} } grep { not $_->{transparent} } @$events;

	sub _enclosing_event {
		my ($events, $span) = @_;

		my @result = grep {
			$_->{transparent} and $_->{span}->contains($span);
		} @$events;

		scalar @result ? $result[0] : undef;
	}

	my @result = map {{
		span => $_,
		instructor => _enclosing_event($events, $_)->{summary}
	}} ScheduleUtils::vacancies(\@free, \@busy, $duration);

	\@result;
}

sub schedule {
	my ($self, $instructor, $span) = @_;

	my $dtf = $self->{dtf};

	my $events = Google::CalendarAPI::Events::list($self->{calendar}, $span);

	my @free = grep { $_->{summary} eq $instructor }
		grep { $_->{transparent} } @$events;

	my @busy = grep {
		my $span = $_->{span};
		my @result = grep { $_->{span}->contains($span) } @free;
		scalar @result;

	} grep { not $_->{transparent} } @$events;

	my @result = map { {span => $_->{span}, busy => not $_->{transparent}} }
		sort { $dtf->cmp($a->{span}->start, $b->{span}->start) }
		(@free, @busy);

	\@result;
}
<commit_msg>syntax error fixed<commit_after>package Resource;

use strict;
use warnings;

use DateTimeFactory;
use ScheduleUtils;
use Google;

sub new {
	my ($class, $record) = @_;
	my %self = ((dtf => DateTimeFactory->new()), %$record);
	bless \%self, $class;
}

sub vacancies {
	my ($self, $duration, $span) = @_;

	my $events = Google::CalendarAPI::Events::list($self->{calendar}, $span);

	my @free = map { $_->{span} } grep { $_->{transparent} } @$events;
	my @busy = map { $_->{span} } grep { not $_->{transparent} } @$events;

	sub _enclosing_event {
		my ($events, $span) = @_;

		my @result = grep {
			$_->{transparent} and $_->{span}->contains($span);
		} @$events;

		scalar @result ? $result[0] : undef;
	}

	my $vacancies = ScheduleUtils::vacancies(\@free, \@busy, $duration);
	my @result = map {{
		span => $_,
		instructor => _enclosing_event($events, $_)->{summary}
	}} @{$vacancies};

	\@result;
}

sub schedule {
	my ($self, $instructor, $span) = @_;

	my $dtf = $self->{dtf};

	my $events = Google::CalendarAPI::Events::list($self->{calendar}, $span);

	my @free = grep { $_->{summary} eq $instructor }
		grep { $_->{transparent} } @$events;

	my @busy = grep {
		my $span = $_->{span};
		my @result = grep { $_->{span}->contains($span) } @free;
		scalar @result;

	} grep { not $_->{transparent} } @$events;

	my @result = map { {span => $_->{span}, busy => not $_->{transparent}} }
		sort { $dtf->cmp($a->{span}->start, $b->{span}->start) }
		(@free, @busy);

	\@result;
}

{'fraction_non_alphanumeric': 0.2304540798907477, 'fraction_numerical': 0.0006828269033799932, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 63, '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': '1251626', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1098, 'n_words': 265}