<commit_before>class CompUnit {
    has Lock     $!lock;
    has Str      $.from;
    has IO::Path $.path;
    has Str      $!WHICH;
    has Bool     $.loaded;

    my Lock $global = Lock.new;
    my %instances;

    method new( $path is copy, :$from = 'perl6' ) {
        $path = IO::Spec.rel2abs($path);
        for $path.IO -> $io {
            return Nil if !$io.e or $io.d;
        }
        $global.protect( { %instances{$path} //= self.bless(:$path,:$from) } );
    }

    method BUILD( :$path, :$!from ) {
        $!lock  = Lock.new;
        $!WHICH = "{self.^name}|$path";
        $!path  = $path.path;
        self
    }

    method WHICH { self.DEFINITE ?? $!WHICH !! self.^name }
    method Str   { self.DEFINITE ?? $!path.Str !! Nil }
    method gist  { self.DEFINITE
      ?? "{self.name}:{$!path.Str}"
      !! self.^name;
    }
    method perl  { self.DEFINITE
      ?? "CompUnit.new('{$!path.Str}')"
      !! self.^name;
    }

    # same magic I'm not sure we need
    my Mu $p6ml := nqp::gethllsym('perl6', 'ModuleLoader');
    method p6ml { $p6ml }
    method ctxsave() { $p6ml.ctxsave() }
    method absolute_path($path) { $p6ml.absolute_path($path) }
    method load_setting($setting_name) { $p6ml.load_setting($setting_name) }<commit_msg>Add CompUnit.name and fix .perl<commit_after>class CompUnit {
    has Lock     $!lock;
    has Str      $.from;
    has Str      $.name;
    has IO::Path $.path;
    has Str      $!WHICH;
    has Bool     $.loaded;

    my Lock $global = Lock.new;
    my $default-from = 'perl6';
    my %instances;

    method new( $path is copy, :$name, :$from = $default-from ) {
        $path = IO::Spec.rel2abs($path);
        for $path.IO -> $io {
            return Nil if !$io.e or $io.d;
        }
        $global.protect( { %instances{$path} //=
          self.bless(:$path,:$name,:$from) } );
    }

    method BUILD( :$path, :$!name, :$!from ) {
        $!lock  = Lock.new;
        $!WHICH = "{self.^name}|$path";
        $!path  = $path.path;
        self
    }

    method WHICH { self.DEFINITE ?? $!WHICH !! self.^name }
    method Str   { self.DEFINITE ?? $!path.Str !! Nil }
    method gist  { self.DEFINITE
      ?? "{self.name}:{$!path.Str}"
      !! self.^name;
    }
    method perl  { self.DEFINITE
      ?? "CompUnit.new('{$!path.Str}',:name<$!name>{",:from<$!from>" if $!from ne $default-from})"
      !! self.^name;
    }

    # same magic I'm not sure we need
    my Mu $p6ml := nqp::gethllsym('perl6', 'ModuleLoader');
    method p6ml { $p6ml }
    method ctxsave() { $p6ml.ctxsave() }
    method absolute_path($path) { $p6ml.absolute_path($path) }
    method load_setting($setting_name) { $p6ml.load_setting($setting_name) }
{'fraction_non_alphanumeric': 0.18212166172106825, 'fraction_numerical': 0.0066765578635014835, 'mean_word_length': 2.2145411203814063, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6774339', 'n_tokens_mistral': 1027, 'n_tokens_neox': 983, 'n_words': 214}