<commit_before>#------------------------------------------------------------------------------
package Indent::Block;
#------------------------------------------------------------------------------
# $Id: Block.pm,v 1.4 2007-02-18 21:29:59 skim Exp $

# Pragmas.
use strict;

# Modules.
use Error::Simple::Multiple qw(err);

# Version.
our $VERSION = 0.01;

#------------------------------------------------------------------------------
sub new {
#------------------------------------------------------------------------------
# Constructor.

	my $class = shift;
	my $self = bless {}, $class;

	# Options.
	$self->{'line_size'} = 79;
	$self->{'next_indent'} = "\t";

	# Output.
	$self->{'output_separator'} = "\n";

	# Strict mode.
	$self->{'strict'} = 1;

	# Process params.
	while (@_) {
		my $key = shift;
		my $val = shift;
		err "Unknown parameter '$key'." unless exists $self->{$key};
		$self->{$key} = $val;
	}

	# Line_size check.
	if ($self->{'line_size'} !~ /^\d*$/) {
		err "Bad line_size = '$self->{'line_size'}'.";
	}

	# Object.
	return $self;
}

#------------------------------------------------------------------------------
sub indent {
#------------------------------------------------------------------------------
# Parses tag to indented data.
# @param $data Reference to data array.
# @param $indent String to actual indent.
# @param $non_indent Flag, than says no-indent.

	my ($self, $data, $indent, $non_indent) = @_;

	# Undef indent.
	if (! $indent) {
		$indent = '';
	}

	# If non_indent data, than return.
	return $indent.join('', @{$data}) if $non_indent;

	# Indent.
	my @data = ();
	my ($first, $second);
	$first = shift @{$data};
	$first = $indent.$first;
	while (@{$data}) {
		$second = shift @{$data};
		if (length $first >= $self->{'line_size'}
			|| length $first.$second > $self->{'line_size'}) {

			if ($first !~ /^\s+$/) {
				push @data, $first;
			}
			$first = $second;
			$second = '';
		} else {
			$first .= $second;
		}
	}

	# Add other data to @data array.
	push @data, $first if $first || $first !~ /^\s*$/;

	# Return as array or one line with output separator between its.
	return wantarray ? @data : join($self->{'output_separator'}, @data);<commit_msg>New version.<commit_after>#------------------------------------------------------------------------------
package Indent::Block;
#------------------------------------------------------------------------------
# $Id: Block.pm,v 1.5 2007-02-18 21:39:13 skim Exp $

# Pragmas.
use strict;

# Modules.
use Error::Simple::Multiple qw(err);

# Version.
our $VERSION = 0.01;

#------------------------------------------------------------------------------
sub new {
#------------------------------------------------------------------------------
# Constructor.

	my $class = shift;
	my $self = bless {}, $class;

	# Options.
	$self->{'line_size'} = 79;
	$self->{'next_indent'} = "\t";

	# Output.
	$self->{'output_separator'} = "\n";

	# Strict mode.
	$self->{'strict'} = 1;

	# Process params.
	while (@_) {
		my $key = shift;
		my $val = shift;
		err "Unknown parameter '$key'." unless exists $self->{$key};
		$self->{$key} = $val;
	}

	# Line_size check.
	if ($self->{'line_size'} !~ /^\d*$/) {
		err "Bad line_size = '$self->{'line_size'}'.";
	}

	# Object.
	return $self;
}

#------------------------------------------------------------------------------
sub indent {
#------------------------------------------------------------------------------
# Parses tag to indented data.
# @param $data Reference to data array.
# @param $indent String to actual indent.
# @param $non_indent Flag, than says no-indent.

	my ($self, $data, $indent, $non_indent) = @_;

	# Undef indent.
	if (! $indent) {
		$indent = '';
	}

	# If non_indent data, than return.
	return $indent.join('', @{$data}) if $non_indent;

	# Indent.
	my @data = ();
	my ($first, $second);
	$first = shift @{$data};
	$first = $indent.$first;
	while (@{$data}) {
		$second = shift @{$data};
		if (length $first >= $self->{'line_size'}
			|| length $first.$second > $self->{'line_size'}) {

			$first =~ s/^\s*//;
			$first =~ s/\s*$//;
			if ($first eq '') {
				$first .= $second;				
			$first = $second;
			$second = '';
			} else {
				push @data, $first;
				$first = $second;
				$second = '';
			}
		} else {
			$first .= $second;
		}
	}

	# Add other data to @data array.
	if ($first) {
		$first =~ s/^\s*//;
		$first =~ s/\s*$//;
		if ($first ne '') {
			push @data, $first;
		}
	}

	# Return as array or one line with output separator between its.
	return wantarray ? @data : join($self->{'output_separator'}, @data);
{'fraction_non_alphanumeric': 0.3769599303135889, 'fraction_numerical': 0.009581881533101045, 'mean_word_length': 1.5084653194975424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '296320', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1426, 'n_words': 379}