| 1 | #!/usr/bin/perl -W | ||||||||||||||||||||||||||||
| 2 | package AI::MicroStructure; | ||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Digest::MD5 qw(md5 md5_hex md5_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use File::Glob; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Data::Printer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use AI::MicroStructure::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 8 | our $absstructdir = ""; | |||||||||||||||||||||||||||
| 18 | 8 | our $structdir = ""; | |||||||||||||||||||||||||||
| 19 | 8 | our $VERSION = '0.016'; | |||||||||||||||||||||||||||
| 20 | 8 | our $Structure = 'any'; # default structure | |||||||||||||||||||||||||||
| 21 | 8 | our $CODESET = 'utf8'; | |||||||||||||||||||||||||||
| 22 | 8 | our $LANG = ''; | |||||||||||||||||||||||||||
| 23 | 8 | our %MICRO; | |||||||||||||||||||||||||||
| 24 | 8 | our %MODS; | |||||||||||||||||||||||||||
| 25 | 8 | our %ALIEN; | |||||||||||||||||||||||||||
| 26 | 8 | our $str = "[A-Z]"; | |||||||||||||||||||||||||||
| 27 | 8 | our $special = "any"; | |||||||||||||||||||||||||||
| 28 | 8 | our $search; | |||||||||||||||||||||||||||
| 29 | 8 | our $data={}; | |||||||||||||||||||||||||||
| 30 | 8 | our $item=""; | |||||||||||||||||||||||||||
| 31 | 8 | our @items; | |||||||||||||||||||||||||||
| 32 | 8 | our @a=(); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 8 | our ($init,$new,$drop,$available,$lib, | |||||||||||||||||||||||||||
| 36 | $list,$use,$off,$switch,$mirror, | ||||||||||||||||||||||||||||
| 37 | $version,$help,$write,$verbose) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 8 | eval "\$$_=1; " for @ARGV; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 8 | ▶ | if( grep{/\bnew\b/} @ARGV ){ $new = 1; cleanArgs("new"); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 8 | ▶ | if( grep{/\bwrite\b/} @ARGV ){ $write = 1; cleanArgs("write"); }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 8 | ▶ | if( grep{/\bdrop\b/} @ARGV ){ $drop = 1; cleanArgs("drop"); }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 8 | ▶ | if( grep{/\bverbose\b/} @ARGV ){ $verbose = 1; cleanArgs("verbose"); }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 8 | our $StructureName = $ARGV[0]; # default structure | |||||||||||||||||||||||||||
| 49 | 8 | our $structure = $ARGV[0]; # default structure | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 8 | our $state = AI::MicroStructure::Util::config(); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 8 | our @CWD=(); | |||||||||||||||||||||||||||
| 54 | 8 | push @CWD , $state->{path}->{"cwd/structures"}; | |||||||||||||||||||||||||||
| 55 | 8 | our $config = $state->{cfg}; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 8 | our $micro = AI::MicroStructure->new($Structure); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 8 | $absstructdir = $state->{path}->{"cwd/structures"}; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub cleanArgs{ | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my ($key) = @_; | ||||||||||||||||||||||||||
|
Subroutine
cleanArgs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | my @tmp=(); | |||||||||||||||||||||||||||
| 68 | 0 | foreach(@ARGV){ | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | push @tmp,$_ unless($_=~/$key/);} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | @ARGV=@tmp; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | # private class method | ||||||||||||||||||||||||||||
| 73 | sub find_structures { | ||||||||||||||||||||||||||||
| 74 | 8 | ▶ | my ( $class, @dirs ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
find_structures: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | $ALIEN{"base"} = [map @$_, | ||||||||||||||||||||||||||||
| 76 | 0 | map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } | |||||||||||||||||||||||||||
| 77 | 8 | map { File::Glob::bsd_glob( | |||||||||||||||||||||||||||
| 78 | File::Spec->catfile( $_, ($structdir,"*") ) ) } @dirs]; | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # $ALIEN{"store"}=[split("\n",`cat @dirs/* | egrep -v "(our|my|use|sub|package)" | data-freq | egrep -iv "^ [1]:`), | ||||||||||||||||||||||||||||
| 81 | # split("\n",`cat @dirs/* | egrep -v "(our|my|use|sub|package)" | data-freq | egrep -i "^ [1]:`)]; | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | ##p %ALIEN; | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 8 | return @{$ALIEN{"base"}}; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # fetch the list of standard structures | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub find_modules { | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 8 | ▶ | my $structures = {}; | ||||||||||||||||||||||||||
|
Subroutine
find_modules: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 8 | foreach(@INC) | |||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | my @set = grep /($str)/, map @$_, | ||||||||||||||||||||||||||||
| 99 | 840 | map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } | |||||||||||||||||||||||||||
| 100 | 64 | map { File::Glob::bsd_glob( | |||||||||||||||||||||||||||
| 101 | File::Spec->catfile( $_, qw( AI MicroStructure *.pm ) ) ) } $_; | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 64 | foreach(@set){ | |||||||||||||||||||||||||||
| 104 | 1440 | $structures->{$_}=$_;# unless($_=~/(usr\/local|basis)/); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 8 | return %$structures; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 8 | $MICRO{$_} = 0 for keys %{{__PACKAGE__->find_structures(@CWD)} }; | |||||||||||||||||||||||||||
| 113 | 8 | $MODS{$_} = $_ for keys %{{__PACKAGE__->find_modules(@INC)} }; | |||||||||||||||||||||||||||
| 114 | 8 | $search = join("|",keys %MICRO); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | #p @{[__PACKAGE__->getComponents]}; | ||||||||||||||||||||||||||||
| 117 | #die; | ||||||||||||||||||||||||||||
| 118 | #if( grep{/$search/} @ARGV ){ $Structure = $ARGV[0] unless(!$ARGV[0]); } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # fetch the list of standard structures | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | #print Dumper keys %MICRO; | ||||||||||||||||||||||||||||
| 123 | sub getComponents{ | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $x= {}; | ||||||||||||||||||||||||||
|
Subroutine
getComponents: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | $x->{"all_structures"} = [keys %MICRO]; | |||||||||||||||||||||||||||
| 130 | 0 | $x->{"count_struct"} = sprintf(keys %MICRO); | |||||||||||||||||||||||||||
| 131 | 0 | $x->{"structures"} = {}; | |||||||||||||||||||||||||||
| 132 | 0 | $x->{"structures"}->{"json"} = sprintf(`ls /home/santex/repos/KnowledgeInterDisciplinary/data/json | egrep -i "($structure)";`); | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | foreach my $con (@{$x->{"all_structures"}}){ | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | next unless($con!~/any/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | my @in = split("\n",eval{`cat $state->{path}->{"cwd/structures"}/$con.pm`;}); | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # my $conc=join("|",@{$x->{"nsubcon"}->{$state->{path}->{"cwd/structures"}}->{$con}->{all}}); | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | $x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{name} = [grep{$_}grep {!/(our|my|use|sub|use|package|#|__|1)/}split("\n",`cat $state->{path}->{"cwd/structures"}/$con.pm`)];#, | |||||||||||||||||||||||||||
| 142 | #split("\n",grep{$con}@{$x->{"structures"}->{"json"}})]; | ||||||||||||||||||||||||||||
| 143 | 0 | $x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{files} = [split("\n",`ls -R /home/santex/repos/KnowledgeInterDisciplinary/data/json | egrep -i "($con)";`)]; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | #$x->{"nsubcon"}->{$state->{path}->{"cwd/structures"}}->{$con}->{n} = grep{$_}grep {!/(our|my|use|sub|use|package|#|__|1)/}split("\n",`cat $state->{path}->{"cwd/structures"}/$con.pm`) ; | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | # | ||||||||||||||||||||||||||||
| 149 | 0 | $x->{"structures"}->{"json"} = []; | |||||||||||||||||||||||||||
| 150 | #p @{[$x]}; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # $x->{"structures"}->{json}=[]; | ||||||||||||||||||||||||||||
| 153 | #my @got = [values %{$x->{"structures"}}]; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | # p @got; | ||||||||||||||||||||||||||||
| 156 | # foreach(@got){ | ||||||||||||||||||||||||||||
| 157 | # if(!$#_ && 0){ | ||||||||||||||||||||||||||||
| 158 | #$x->{"structures"}->{$_} = [grep{$_}ssplit("^*\n",`cat '$state->{path}->{"cwd/structures"}/$_.pm'`)]; | ||||||||||||||||||||||||||||
| 159 | #die(); | ||||||||||||||||||||||||||||
| 160 | # } | ||||||||||||||||||||||||||||
| 161 | #} | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | # if(!@{$x->{"structures"}->{$_}}){ | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | # $x->{"structures"}->{$_} = [split("^*\n",`cat $state->{path}->{"cwd/structures"}/$_.pm | | egrep -i "($_)\$"`)] for( @{$x->{"all structures"}}); | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # "glue"=>split("\n",`cat $CWD[0]/* | egrep -v "(our|my|use|sub|package)" | egrep -i "($structure)$" | data-freq | egrep -v "^ [1]:"`)}; | ||||||||||||||||||||||||||||
| 168 | # | ||||||||||||||||||||||||||||
| 169 | 0 | return $x; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub import { | ||||||||||||||||||||||||||||
| 176 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=20.0
| |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | my @structures = ( grep { $_ eq ':all' } @_ ) | |||||||||||||||||||||||||||
| 179 | 8 | ▶ | ? ( 'foo', grep { !/^(?:foo|:all)$/ } keys %MICRO ) # 'foo' is still first | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | : @_; | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 8 | ▶ | $Structure = $structures[0] if @structures; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 8 | $micro = AI::MicroStructure->new( $Structure ); | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # export the microname() function | ||||||||||||||||||||||||||||
| 186 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 187 | 8 | my $callpkg = caller; | |||||||||||||||||||||||||||
| 188 | 8 | *{"$callpkg\::microname"} = \µname; # standard theme | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | # load the classes in @structures | ||||||||||||||||||||||||||||
| 191 | 8 | for my $structure( @structures ) { | |||||||||||||||||||||||||||
| 192 | 0 | eval "require AI::MicroStructure::$structure; import AI::MicroStructure::$structure;"; | |||||||||||||||||||||||||||
| 193 | 0 | ▶ | croak $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | *{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | sub new { | ||||||||||||||||||||||||||||
| 199 | 18 | ▶ | my ( $class, @args ) = ( @_ ); | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 200 | 18 | my $structure; | |||||||||||||||||||||||||||
| 201 | 18 | ▶ | $structure = shift @args if @args % 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 18 | ▶ | $structure = $Structure unless $structure; # same default everywhere | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | # defer croaking until name() is actually called | ||||||||||||||||||||||||||||
| 205 | 18 | bless { structure => $structure, args => { @args }, micro => {} ,state=>$state}, $class; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub _rearrange{ | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_rearrange: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $self->{'payload'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | return %$self; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | # CLASS METHODS | ||||||||||||||||||||||||||||
| 218 | sub add_structure { | ||||||||||||||||||||||||||||
| 219 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_structure: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 220 | 2 | my %structures = @_; | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 2 | for my $structure ( keys %structures ) { | |||||||||||||||||||||||||||
| 223 | 2 | ▶ | croak "The structure $structure already exists!" if exists $MICRO{$structure}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 2 | my @badnames = grep { !/^[a-z_]\w*$/i } @{$structures{$structure}}; | |||||||||||||||||||||||||||
| 225 | 2 | ▶ | croak "Invalid names (@badnames) for structure $structure" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | if @badnames; | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 2 | my $code = << "EOC"; | |||||||||||||||||||||||||||
| 229 | package AI::MicroStructure::$structure; | ||||||||||||||||||||||||||||
| 230 | use strict; | ||||||||||||||||||||||||||||
| 231 | use AI::MicroStructure::List; | ||||||||||||||||||||||||||||
| 232 | our \@ISA = qw( AI::MicroStructure::List ); | ||||||||||||||||||||||||||||
| 233 | 2 | our \@List = qw( @{$structures{$structure}} ); | |||||||||||||||||||||||||||
| 234 | __PACKAGE__->init(); | ||||||||||||||||||||||||||||
| 235 | 1; | ||||||||||||||||||||||||||||
| 236 | EOC | ||||||||||||||||||||||||||||
| 237 | 2 | ▶ | eval $code; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 238 | 2 | $MICRO{$structure} = 1; # loaded | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | # export the microstructure() function | ||||||||||||||||||||||||||||
| 241 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 242 | 2 | my $callpkg = caller; | |||||||||||||||||||||||||||
| 243 | 2 | ▶ | *{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # load the content of __DATA__ into a structure | ||||||||||||||||||||||||||||
| 252 | # this class method is used by the other AI::MicroStructure classes | ||||||||||||||||||||||||||||
| 253 | sub load_data { | ||||||||||||||||||||||||||||
| 254 | 4 | ▶ | my ($class, $structure ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_data: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 255 | 4 | $data = {}; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 4 | my $fh; | |||||||||||||||||||||||||||
| 258 | 8 | ▶ | { no strict 'refs'; $fh = *{"$structure\::DATA"}{IO}; } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 4 | my $item; | |||||||||||||||||||||||||||
| 261 | my @items; | ||||||||||||||||||||||||||||
| 262 | 4 | $$item = ""; | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||
| 265 | 4 | ▶ | if(defined($fh)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 2 | local $_; | |||||||||||||||||||||||||||
| 267 | 2 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 32 | ▶ | /^#\s*(\w+.*)$/ && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 14 | push @items, $item; | |||||||||||||||||||||||||||
| 270 | 14 | $item = $data; | |||||||||||||||||||||||||||
| 271 | 14 | my $last; | |||||||||||||||||||||||||||
| 272 | 14 | my @keys = split m!\s+|\s*/\s*!, $1; | |||||||||||||||||||||||||||
| 273 | 14 | ▶ | $last = $item, $item = $item->{$_} ||= {} for @keys; | ||||||||||||||||||||||||||
|
Condition100%2/2
$item->{$_} ||= {}
MC/DC100%1/1
$item->{$_} ||= {}
$item->{$_}
Truth table100%2/2
A
A= $item->{$_}
| |||||||||||||||||||||||||||||
| 274 | 14 | $item = \( $last->{ $keys[-1] } = "" ); | |||||||||||||||||||||||||||
| 275 | 14 | next; | |||||||||||||||||||||||||||
| 276 | }; | ||||||||||||||||||||||||||||
| 277 | 18 | $$item .= $_; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | # clean up the items | ||||||||||||||||||||||||||||
| 282 | 4 | for( @items, $item ) { | |||||||||||||||||||||||||||
| 283 | 18 | $$_ =~ s/\A\s*//; | |||||||||||||||||||||||||||
| 284 | 18 | $$_ =~ s/\s*\z//; | |||||||||||||||||||||||||||
| 285 | 18 | $$_ =~ s/\s+/ /g; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 4 | return $data; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | #fitnes | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | sub fitnes { | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
fitnes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 298 | 0 | return sha1_hex($self->structures()); | |||||||||||||||||||||||||||
| 299 | ##my ($config,$structure, $config ) = (shift,[$self->structures()]); FIXME | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | # main function | ||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub microname { $micro->name( @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
microname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | sub shitname { | ||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shitname: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 310 | 0 | my ( $structure, $count ) = ("any",1); | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 0 | ( $structure, $count ) = @_; | |||||||||||||||||||||||||||
| 314 | 0 | ▶ | ( $structure, $count ) = ( $self->{structure}, $structure ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | if $structure =~ /^(?:0|[1-9]\d*)$/; | ||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | else { | ||||||||||||||||||||||||||||
| 318 | 0 | ( $structure, $count ) = ( $self->{structure}, 1 ); | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if( ! exists $self->{micro}{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | my ( $structure, $category ) = split /\//, $structure, 2; | |||||||||||||||||||||||||||
| 323 | 0 | ▶ | if( ! $MICRO{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | try{ | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | # `micro new $structure`; | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | ▶ | eval "require '$absstructdir/$structure.pm';"; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 329 | 0 | $MICRO{$structure} = 1; # loaded | |||||||||||||||||||||||||||
| 330 | 0 | $self->{micro}{$structure} = AI::MicroStructure->new($structure,category => $category); | |||||||||||||||||||||||||||
| 331 | 0 | print $self->{micro}{$structure}->name( $count ); | |||||||||||||||||||||||||||
| 332 | 0 | return; | |||||||||||||||||||||||||||
| 333 | ▶ | } catch{ | |||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | 0 | } | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | # corresponding method | ||||||||||||||||||||||||||||
| 345 | sub name { | ||||||||||||||||||||||||||||
| 346 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 347 | 0 | my ( $structure, $count ) = ("any",1); | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 350 | 0 | ( $structure, $count ) = @_; | |||||||||||||||||||||||||||
| 351 | 0 | ▶ | ( $structure, $count ) = ( $self->{structure}, $structure ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $structure and $structure =~ /^(?:0|[1-9]\d*)$/
MC/DC0%0/2
defined $structure and $structure =~ /^(?:0|[1-9]\d*)$/
defined $structure
$structure =~ /^(?:0|[1-9]\d*)$/
Truth table0%0/3
A and B
A= defined $structureB= $structure =~ /^(?:0|[1-9]\d*)$/
| |||||||||||||||||||||||||||||
| 352 | if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; | ||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | else { | ||||||||||||||||||||||||||||
| 355 | 0 | ( $structure, $count ) = ( $self->{structure}, 1 ); | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if( ! exists $self->{micro}{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if( ! $MICRO{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 360 | 0 | eval "require '$absstructdir/$structure.pm';"; | |||||||||||||||||||||||||||
| 361 | 0 | ▶ | croak "MicroStructure list $structure does not exist!" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 0 | $MICRO{$structure} = 1; # loaded | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | $self->{micro}{$structure} = | ||||||||||||||||||||||||||||
| 365 | 0 | "AI::MicroStructure::$structure"->new( %{ $self->{args} } ); | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | $self->{micro}{$structure}->name( $count ); | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | # corresponding method | ||||||||||||||||||||||||||||
| 372 | sub namex { | ||||||||||||||||||||||||||||
| 373 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
namex: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 374 | 0 | my ( $structure, $count ) = ("any",1); | |||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | 0 | ( $structure, $count ) = @_; | |||||||||||||||||||||||||||
| 378 | 0 | ▶ | ( $structure, $count ) = ( $self->{structure}, $structure ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $structure and $structure =~ /^(?:0|[1-9]\d*)$/
MC/DC0%0/2
defined $structure and $structure =~ /^(?:0|[1-9]\d*)$/
defined $structure
$structure =~ /^(?:0|[1-9]\d*)$/
Truth table0%0/3
A and B
A= defined $structureB= $structure =~ /^(?:0|[1-9]\d*)$/
| |||||||||||||||||||||||||||||
| 379 | if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; | ||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | else { | ||||||||||||||||||||||||||||
| 382 | 0 | ( $structure, $count ) = ( $self->{structure}, 1 ); | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if( ! exists $self->{micro}{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if( ! $MICRO{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | try { | ||||||||||||||||||||||||||||
| 388 | 0 | ▶ | eval "require '$absstructdir/$structure.pm';"; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 389 | 0 | $MICRO{$structure} = 1; # loaded | |||||||||||||||||||||||||||
| 390 | 0 | ▶ | croak "MicroStructure list $structure does not exist!" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | ▶ | }catch{ | |||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | 0 | } | |||||||||||||||||||||||||||
| 396 | $self->{micro}{$structure} = | ||||||||||||||||||||||||||||
| 397 | 0 | "AI::MicroStructure::$structure"->new( %{ $self->{args} } ); | |||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 0 | $self->{micro}{$structure}->name( $count ); | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | # other methods | ||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub structures { wantarray ? ( sort keys %MICRO ) : scalar keys %MICRO } | ||||||||||||||||||||||||||
|
Subroutine
structures: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub has_structure { $_[1] ? exists $MICRO{$_[1]} : 0 } | ||||||||||||||||||||||||||
|
Subroutine
has_structure: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub configure_driver { $_[1] ? exists $MICRO{$_[1]} : 0 } | ||||||||||||||||||||||||||
|
Subroutine
configure_driver: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | sub count { | ||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
count: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 421 | 0 | my ( $structure, $count ); | |||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | ( $structure, $count ) = @_; | |||||||||||||||||||||||||||
| 425 | 0 | ▶ | ( $structure, $count ) = ( $self->{structure}, $structure ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | if $structure =~ /^(?:0|[1-9]\d*)$/; | ||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | ▶ | if( ! exists $self->{micro}{$structure} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | 0 | return scalar ($self->{micro}{$structure}->new); | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 0 | return 0; | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | sub trim | ||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||
| 440 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
trim: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 441 | 0 | my $string = shift; | |||||||||||||||||||||||||||
| 442 | 0 | ▶ | $string = "" unless $string; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 0 | $string =~ s/^\s+//; | |||||||||||||||||||||||||||
| 444 | 0 | $string =~ s/\s+$//; | |||||||||||||||||||||||||||
| 445 | 0 | $string =~ s/\t//; | |||||||||||||||||||||||||||
| 446 | 0 | $string =~ s/^\s//; | |||||||||||||||||||||||||||
| 447 | 0 | return $string; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | sub getBundle { | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getBundle: not called CC=8 SCAR=40.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | my @structures = grep { !/^(?:any)/ } AI::MicroStructure->structures; | |||||||||||||||||||||||||||
| 458 | 0 | my @micros; | |||||||||||||||||||||||||||
| 459 | 0 | my @search=[]; | |||||||||||||||||||||||||||
| 460 | 0 | for my $structure (@structures) { | |||||||||||||||||||||||||||
| 461 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 462 | 0 | eval "require '$absstructdir/$structure.pm';"; | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | my %isa = map { $_ => 1 } @{"AI::MicroStructure::$structure\::ISA"}; | |||||||||||||||||||||||||||
| 465 | 0 | ▶ | if( exists $isa{'AI::MicroStructure::Locale'} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 466 | 0 | for my $lang ( "AI::MicroStructure::$structure"->languages() ) { | |||||||||||||||||||||||||||
| 467 | 0 | push @micros, | |||||||||||||||||||||||||||
| 468 | ["AI::MicroStructure::$structure"->new( lang => $lang ),$lang]; | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | elsif( exists $isa{'AI::MicroStructure::MultiList'} ) { | ||||||||||||||||||||||||||||
| 474 | 0 | for my $cat ( "AI::MicroStructure::$structure"->categories(), ':all' ) { | |||||||||||||||||||||||||||
| 475 | 0 | push @micros, | |||||||||||||||||||||||||||
| 476 | [ "AI::MicroStructure::$structure"->new( category => $cat ),$cat]; | ||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||
| 480 | 0 | push @micros, ["AI::MicroStructure::$structure"->new(),'']; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | my $all ={}; | |||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 0 | for my $test (@micros) { | |||||||||||||||||||||||||||
| 487 | 0 | my $micro = $test->[0]; | |||||||||||||||||||||||||||
| 488 | 0 | my %items; | |||||||||||||||||||||||||||
| 489 | 0 | my $items = $micro->name(0); | |||||||||||||||||||||||||||
| 490 | 0 | $items{$_}++ for $micro->name(0); | |||||||||||||||||||||||||||
| 491 | 0 | my $key=sprintf("%s",$micro->structure); | |||||||||||||||||||||||||||
| 492 | 0 | $all->{$key}=[$test->[1],$micro->name($items)]; | |||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | 0 | return $all; | |||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | sub save_cat { | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
save_cat: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 505 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 506 | 0 | my $dat; | |||||||||||||||||||||||||||
| 507 | 0 | my $ret = ""; | |||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 0 | foreach my $key(sort keys %{$data} ) { | |||||||||||||||||||||||||||
| 511 | 0 | ▶ | next unless($_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 512 | #ref $hash->{$_} eq "HASH" | ||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if(ref $data->{$key} eq "HASH"){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 514 | 0 | $ret .= "\n".$self->save_cat($data->{$key}); | |||||||||||||||||||||||||||
| 515 | }else{ | ||||||||||||||||||||||||||||
| 516 | 0 | $dat = $data->{$key}; | |||||||||||||||||||||||||||
| 517 | 0 | $dat =~ s/^|,/\n/g; | |||||||||||||||||||||||||||
| 518 | 0 | $dat =~ s/\n\n/\n/g; | |||||||||||||||||||||||||||
| 519 | 0 | $dat =~ s/->\n|[0-9]\n//g; | |||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 0 | ▶ | $ret .= "# ".($key=~/names|default|[a-z]/?$key:"names ".$key); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 522 | 0 | $ret .= "\n ".$dat."\n"; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 0 | return $ret; | |||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | sub save_default { | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
save_default: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 534 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 535 | 0 | my $line = shift; | |||||||||||||||||||||||||||
| 536 | 0 | my $dat = {}; | |||||||||||||||||||||||||||
| 537 | 0 | my @in = (); | |||||||||||||||||||||||||||
| 538 | 0 | my $active=0; | |||||||||||||||||||||||||||
| 539 | 0 | ▶ | $line = $Structure unless($line); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 0 | foreach(@{$data->{rows}->{"coordinate"}}){ | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if($_ eq $line){ $active=1; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if(1+$line eq $_){ $active=0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | 0 | ▶ | if($active==1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 548 | 0 | $_=~s/,//g; | |||||||||||||||||||||||||||
| 549 | 0 | $_ = $self->trim($_); | |||||||||||||||||||||||||||
| 550 | 0 | ▶ | $dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 0 | foreach(@{$data->{rows}->{"search"}}){ | |||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if($_ eq $line){ $active=1; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if(1+$line eq $_){ $active=0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if($active==1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 563 | 0 | $_=~s/,//g; | |||||||||||||||||||||||||||
| 564 | 0 | $_ = $self->trim($_); | |||||||||||||||||||||||||||
| 565 | 0 | ▶ | $dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 0 | push @in , keys %{$dat->{names}}; | |||||||||||||||||||||||||||
| 573 | 0 | push @in , values %{$data->{names}}; | |||||||||||||||||||||||||||
| 574 | 0 | $dat->{names} = join(" ",@in); | |||||||||||||||||||||||||||
| 575 | 0 | $dat->{names} =~ s/$line(.*?)\-\>(.*?) [1-9] /$1 $2/g; | |||||||||||||||||||||||||||
| 576 | 0 | $dat->{names} =~ s/ / /g; | |||||||||||||||||||||||||||
| 577 | 0 | my @file = grep{/$Structure/}map{File::Glob::bsd_glob( | |||||||||||||||||||||||||||
| 578 | File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if(@file){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 582 | 0 | ▶ | open(SELF,"+<$file[0]") || die $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | 0 | ▶ | while(<SELF>){last if /^__DATA__/} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | 0 | truncate(SELF,tell SELF); | |||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 0 | print SELF $self->save_cat($dat); | |||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | 0 | truncate(SELF,tell SELF); | |||||||||||||||||||||||||||
| 591 | 0 | close SELF; | |||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | sub openData{ | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
openData: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 0 | my @datax = (); | |||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if(<DATA>){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | 0 | @datax = <DATA>; | |||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | 0 | ▶ | while(@datax){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 607 | 0 | chomp; | |||||||||||||||||||||||||||
| 608 | 0 | ▶ | if($_=~/^#\s*(\w+.*)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 609 | 0 | @a=split(" ",$1); | |||||||||||||||||||||||||||
| 610 | 0 | ▶ | if($#a){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 611 | 0 | $data->{$a[0]}->{$a[1]}=""; | |||||||||||||||||||||||||||
| 612 | }else{ | ||||||||||||||||||||||||||||
| 613 | 0 | $data->{$1}=""; | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | 0 | ▶ | $item=$1 unless($#a); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | }else{ | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | 0 | my @keys = split m!\s+|\s*/\s*!,$_; | |||||||||||||||||||||||||||
| 620 | 0 | foreach(sort @keys){ | |||||||||||||||||||||||||||
| 621 | 0 | ▶ | if($#a){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 622 | 0 | ▶ | $data->{$a[0]}->{$a[1]} .= " $_" unless($_ eq ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 623 | }else{ | ||||||||||||||||||||||||||||
| 624 | 0 | ▶ | $data->{$item} .= " $_" unless($_ eq ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | }; | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | 0 | return $data; | |||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | sub getBlank { | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getBlank: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 640 | 0 | my $structure = shift; | |||||||||||||||||||||||||||
| 641 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | 0 | my $usage = ""; | |||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | 0 | $usage = "#!/usr/bin/perl -W\n"; | |||||||||||||||||||||||||||
| 648 | 0 | $usage .= << "EOC"; | |||||||||||||||||||||||||||
| 649 | package AI::MicroStructure::$structure; | ||||||||||||||||||||||||||||
| 650 | use strict; | ||||||||||||||||||||||||||||
| 651 | use AI::MicroStructure::List; | ||||||||||||||||||||||||||||
| 652 | our \@ISA = qw( AI::MicroStructure::List ); | ||||||||||||||||||||||||||||
| 653 | our \@List = qw( \@{\$structures{\$structure}} ); | ||||||||||||||||||||||||||||
| 654 | __PACKAGE__->init(); | ||||||||||||||||||||||||||||
| 655 | 1; | ||||||||||||||||||||||||||||
| 656 | EOC | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 0 | my $new = {}; | |||||||||||||||||||||||||||
| 661 | 0 | foreach my $k | |||||||||||||||||||||||||||
| 662 | 0 | (grep{!/^[0-9]/}map{$_=$self->trim($_)}@{$data->{rows}->{"search"}}){ | |||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 0 | $k =~ s/[ ]/_/g; | |||||||||||||||||||||||||||
| 665 | 0 | $k =~ s/[\(]|[\)]//g; | |||||||||||||||||||||||||||
| 666 | 0 | ▶ | next if($k=~/synonyms|hypernyms/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 667 | 0 | print $k; | |||||||||||||||||||||||||||
| 668 | 0 | $new->{$k}=[map{$_=[map{$_=$self->trim($_)}split("\n|, ",$_)]} | |||||||||||||||||||||||||||
| 669 | 0 | grep{!/synonyms|hypernyms/}split("sense~~~~~~~~~", | |||||||||||||||||||||||||||
| 670 | lc `micro-wnet $k`)]; | ||||||||||||||||||||||||||||
| 671 | 0 | ▶ | next unless(@{$new->{$k}}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 672 | # $new->{$k}=~s/Sense*\n(.*?)\n\n/$1/g; | ||||||||||||||||||||||||||||
| 673 | # @{$new->{$k}} = [split("\n|,",$new->{$k})]; | ||||||||||||||||||||||||||||
| 674 | 0 | $data->{rows}->{"ident"}->{md5_base64($new->{$k})} = $new->{$k}; | |||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | 0 | my $list = join("\n",sort keys %$new); | |||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | # $list =~ s/_//g; | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | 0 | $usage .= " | |||||||||||||||||||||||||||
| 685 | __DATA__ | ||||||||||||||||||||||||||||
| 686 | # names | ||||||||||||||||||||||||||||
| 687 | ".$list; | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | sub save_new { | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
save_new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 697 | 0 | my $StructureName = shift; | |||||||||||||||||||||||||||
| 698 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if($StructureName){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 701 | #$StructureName = lc $self->trim(`micro`) unless($StructureName); | ||||||||||||||||||||||||||||
| 702 | 0 | my $file = "$absstructdir/$StructureName.pm"; | |||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | 0 | ▶ | print `mkdir -p $absstructdir` unless(-d $absstructdir); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 705 | 0 | my $fh; | |||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | 0 | ▶ | open($fh,">$file") || warn @{[$file,$!]}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | 0 | print $fh $self->getBlank($StructureName,$data); | |||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | 0 | close $fh; | |||||||||||||||||||||||||||
| 712 | 0 | $Structure = $StructureName; | |||||||||||||||||||||||||||
| 713 | 0 | push @CWD,$file; | |||||||||||||||||||||||||||
| 714 | 0 | return 1; | |||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | sub drop { | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 723 | 0 | my $StructureName = shift; | |||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | 0 | my @file = grep{/$StructureName.pm/}map{File::Glob::bsd_glob( | |||||||||||||||||||||||||||
| 726 | File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; | ||||||||||||||||||||||||||||
| 727 | 0 | my $fh = shift @file; | |||||||||||||||||||||||||||
| 728 | 0 | ▶ | if(`ls $fh`) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 729 | { | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | 0 | print `rm $fh`; | |||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||
| 733 | #push @CWD,$file[1]; | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 0 | return 1; | |||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | ▶ | sub help{ | |||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||
| 745 | END{ | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | 8 | ▶ | if($init){} | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=20 SCAR=48.1
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 748 | 8 | ▶ | if($available){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 749 | 8 | ▶ | if($lib){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 750 | 8 | ▶ | if($list){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 751 | 0 | p @{[__PACKAGE__->getComponents]}; | |||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||
| 754 | 8 | ▶ | if($use){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 755 | 8 | ▶ | if($off){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 756 | 8 | ▶ | if($switch){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 757 | 8 | ▶ | if($mirror){} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 758 | 8 | ▶ | if($version){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 759 | 0 | printf($VERSION); | |||||||||||||||||||||||||||
| 760 | 0 | exit(0); | |||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | 8 | ▶ | if($help) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 766 | 0 | printf(__PACKAGE__->help()); | |||||||||||||||||||||||||||
| 767 | 0 | exit(0); | |||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | 8 | ▶ | if($drop == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 776 | 0 | __PACKAGE__->drop($StructureName); | |||||||||||||||||||||||||||
| 777 | 0 | exit 0; | |||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||
| 780 | 8 | ▶ | if($new==1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||
| 782 | 8 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 783 | 8 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | 0 | my $data = decode_json(lc`micro-sense $StructureName words`); | |||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | 0 | my $char; | |||||||||||||||||||||||||||
| 790 | my $line; | ||||||||||||||||||||||||||||
| 791 | 0 | my $senses=@{$data->{"senses"}}; | |||||||||||||||||||||||||||
| 792 | 0 | ▶ | $senses= 0 unless($senses); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 793 | 0 | ▶ | if(!$verbose){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | 0 | printf("\n | |||||||||||||||||||||||||||
| 796 | \033[0;34m | ||||||||||||||||||||||||||||
| 797 | %s | ||||||||||||||||||||||||||||
| 798 | Type: the number you choose 1..$senses | ||||||||||||||||||||||||||||
| 799 | \033[0m",__PACKAGE__->usage($StructureName,$senses,$data)); | ||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||
| 801 | 0 | ▶ | $line = 1 unless($senses != 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 802 | 0 | ▶ | if($verbose){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 803 | 0 | $line=1; | |||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||
| 805 | 0 | ▶ | chomp($line = <STDIN>) unless($line); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | 0 | my $d = join("#",@{$data->{rows}->{search}}); | |||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | 0 | my @d = grep{/^$line#/}split("sense~~~~~~~~~",$d); | |||||||||||||||||||||||||||
| 810 | 0 | @{$data->{rows}->{"search"}}=split("#",join("",@d)); | |||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||
| 812 | 0 | ▶ | if($line>0){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 813 | 0 | __PACKAGE__->save_new($StructureName,$data,$line); | |||||||||||||||||||||||||||
| 814 | 0 | exit 0; | |||||||||||||||||||||||||||
| 815 | }else{ | ||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | 0 | printf "your logic is today impaired !!!\n"; | |||||||||||||||||||||||||||
| 818 | 0 | exit 0; | |||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||
| 826 | 8 | ▶ | if($write == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 827 | 0 | __PACKAGE__->save_default(); | |||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||
| 835 | sub usage { | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||
| 840 | 0 | my $search = shift; | |||||||||||||||||||||||||||
| 841 | 0 | my $senseNr = shift; | |||||||||||||||||||||||||||
| 842 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | 0 | my $usage = << 'EOT'; | |||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | .--'"""""--.>_ | ||||||||||||||||||||||||||||
| 848 | .-' o\\b.\o._o.`-. | ||||||||||||||||||||||||||||
| 849 | .-'.- ) \d888888888888b. | ||||||||||||||||||||||||||||
| 850 | /.' b Y8888888888888888b. | ||||||||||||||||||||||||||||
| 851 | .-'. 8888888888888888888888888b | ||||||||||||||||||||||||||||
| 852 | / o888 Y Y8888888888888888888888b | ||||||||||||||||||||||||||||
| 853 | / d888P/ /| Y"Y8888888888888888888b | ||||||||||||||||||||||||||||
| 854 | J d8888/| Y .o._. "Y8888888888888Y" \ | ||||||||||||||||||||||||||||
| 855 | |d Y888b|obd88888bo. """Y88888Y' .od8 | ||||||||||||||||||||||||||||
| 856 | Fdd 8888888888888888888bo._'|| d88888| | ||||||||||||||||||||||||||||
| 857 | Fd d 88\ Y8888Y "Y888888888b, d888888P | ||||||||||||||||||||||||||||
| 858 | d-b 8888b Y88P' """""Y888b8888P"| | ||||||||||||||||||||||||||||
| 859 | J 8\88888888P `m. """"" | | ||||||||||||||||||||||||||||
| 860 | || `8888888P' "Ymm._ _J | ||||||||||||||||||||||||||||
| 861 | |\\ Y8888P ' .mmm.YM) .mMF"' | ||||||||||||||||||||||||||||
| 862 | | \\ Y888J ' < (@)>.- ` /MFm. | | ||||||||||||||||||||||||||||
| 863 | J \ `YY ""' :: MM @)>F | ||||||||||||||||||||||||||||
| 864 | L /) 88 : | ""\| | ||||||||||||||||||||||||||||
| 865 | | ( ( Yb . ' . | L | ||||||||||||||||||||||||||||
| 866 | \ bo 8b . . J | <0>_ | ||||||||||||||||||||||||||||
| 867 | \ "' . . . . L F <1>_ | ||||||||||||||||||||||||||||
| 868 | o._.:. . . \mm,__J/ / <2>_ | ||||||||||||||||||||||||||||
| 869 | Y8::'|. / `Y8P J <3>_ | ||||||||||||||||||||||||||||
| 870 | `|' J: . . ' . . | F <4>_ | ||||||||||||||||||||||||||||
| 871 | | L ' . _: | <5>_ | ||||||||||||||||||||||||||||
| 872 | | `: . .:oood8bdb. | 1>_ | ||||||||||||||||||||||||||||
| 873 | F `:. "-._ `" F 2>_ | ||||||||||||||||||||||||||||
| 874 | / `::. """' / 3>_ | ||||||||||||||||||||||||||||
| 875 | / `::. "" / 4>_ | ||||||||||||||||||||||||||||
| 876 | _.-d( `:::. F 5>_ | ||||||||||||||||||||||||||||
| 877 | -888b. `::::. . J 6>_ | ||||||||||||||||||||||||||||
| 878 | Y888888b. `::::::::::' 7>_ | ||||||||||||||||||||||||||||
| 879 | Y88888888bo. `::::::d 8>_ | ||||||||||||||||||||||||||||
| 880 | `"Y8888888888boo.._ `"dd88b. 9>_ | ||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||
| 886 | """"""""""""""""""""""""""""""""""""""""""""""" | ||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||
| 888 | EOT | ||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | 0 | $usage =~ s/<0>_/\033[0;32mThe word $search\033[255;34m/g; | |||||||||||||||||||||||||||
| 892 | 0 | $usage =~ s/<1>_/\033[0;32mhas $senseNr concept's\033[255;34m/g; | |||||||||||||||||||||||||||
| 893 | 0 | $usage =~ s/<2>_/\033[0;32mwe need to find out the which one\033[255;34m/g; | |||||||||||||||||||||||||||
| 894 | 0 | $usage =~ s/<3>_/\033[0;32mto use for our new,\033[255;34m/g; | |||||||||||||||||||||||||||
| 895 | 0 | $usage =~ s/<4>_/\033[0;32mmicro-structure,\033[255;34m/g; | |||||||||||||||||||||||||||
| 896 | 0 | $usage =~ s/<5>_//g; | |||||||||||||||||||||||||||
| 897 | 0 | my @row = (); | |||||||||||||||||||||||||||
| 898 | 0 | my $ii=0; | |||||||||||||||||||||||||||
| 899 | 0 | foreach my $sensnrx (sort keys %{$data->{"rows"}->{"senses"}}) | |||||||||||||||||||||||||||
| 900 | { | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | 0 | my $row = $data->{"rows"}->{"senses"}->{$sensnrx}; | |||||||||||||||||||||||||||
| 905 | 0 | my $txt=""; | |||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||
| 907 | 0 | foreach(@{$row->{"basics"}}[1..2]){ | |||||||||||||||||||||||||||
| 908 | 0 | ▶ | next unless($_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 909 | 0 | $txt .= sprintf("\033[0;31m %s\033[255;34m",$_); | |||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||
| 912 | 0 | $txt .= sprintf("",$_); | |||||||||||||||||||||||||||
| 913 | 0 | $usage =~ s/$sensnrx>_/($sensnrx):$txt/g; | |||||||||||||||||||||||||||
| 914 | 0 | ▶ | if($sensnrx>9){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 915 | 0 | $usage .= sprintf("\n(%d):%s",$sensnrx,$txt); | |||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||
| 920 | 0 | foreach my $ii (0..16){ | |||||||||||||||||||||||||||
| 921 | 0 | $usage =~ s/$ii>_//g; | |||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | 0 | return $usage; | |||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||
| 928 | 8 | 1; | |||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | __END__ | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | 1; | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | __END__ | ||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | #print Dumper $micro; | ||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||
| 939 | # ABSTRACT: AI::MicroStructure Creates Concepts for words | ||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||
| 941 | =head1 NAME | ||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||
| 943 | AI::MicroStructure | ||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||
| 945 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||
| 947 | Creates Concepts for words | ||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||
| 951 | ~$ micro new world | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | ~$ micro structures | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | ~$ micro any 2 | ||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | ~$ micro drop world | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | ~$ micro | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||
| 963 | Hagen Geissler <santex@cpan.org> | ||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||
| 965 | =head1 COPYRIGHT AND LICENCE | ||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||
| 967 | Hagen Geissler <santex@cpan.org> | ||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||
| 969 | =head1 SUPPORT AND DOCUMENTATION | ||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||
| 971 | [sample using concepts](http://quantup.com) | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | [PDF info on my works](https://github.com/santex) | ||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||
| 976 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | AI-MicroStructure | ||||||||||||||||||||||||||||
| 979 | AI-MicroStructure-Cache | ||||||||||||||||||||||||||||
| 980 | AI-MicroStructure-Deamon | ||||||||||||||||||||||||||||
| 981 | AI-MicroStructure-Relations | ||||||||||||||||||||||||||||
| 982 | AI-MicroStructure-Concept | ||||||||||||||||||||||||||||
| 983 | AI-MicroStructure-Data | ||||||||||||||||||||||||||||
| 984 | AI-MicroStructure-Driver | ||||||||||||||||||||||||||||
| 985 | AI-MicroStructure-Plugin-Pdf | ||||||||||||||||||||||||||||
| 986 | AI-MicroStructure-Plugin-Twitter | ||||||||||||||||||||||||||||
| 987 | AI-MicroStructure-Plugin-Wiki | ||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | __DATA__ | ||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||
| 995 | our $VERSION = '0.014'; | ||||||||||||||||||||||||||||
| 996 | our $Structure = 'any'; # default structure | ||||||||||||||||||||||||||||
| 997 | our $CODESET = 'utf8'; | ||||||||||||||||||||||||||||
| 998 | our $LANG = ''; | ||||||||||||||||||||||||||||
| 999 | our %MICRO; | ||||||||||||||||||||||||||||
| 1000 | our %MODS; | ||||||||||||||||||||||||||||
| 1001 | our %ALIEN; | ||||||||||||||||||||||||||||
| 1002 | our $str = "[A-Z]"; | ||||||||||||||||||||||||||||
| 1003 | our $special = "any"; | ||||||||||||||||||||||||||||
| 1004 | our $search; | ||||||||||||||||||||||||||||
| 1005 | our $data={}; | ||||||||||||||||||||||||||||
| 1006 | our $item=""; | ||||||||||||||||||||||||||||
| 1007 | our @items; | ||||||||||||||||||||||||||||
| 1008 | our @a=(); | ||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | our ($new, $write,$drop) =(0,0,0); | ||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||
| 1016 | my $state = AI::MicroStructure::util::load_config(); my @CWD=$state->{cwd}; my $config=$state->{cfg}; | ||||||||||||||||||||||||||||
| 1017 | our $structdir = "structures"; | ||||||||||||||||||||||||||||
| 1018 | our $absstructdir = "$CWD[0]/$structdir"; | ||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||
| 1020 | if( grep{/\bnew\b/} @ARGV ){ $new = 1; cleanArgs("new"); } | ||||||||||||||||||||||||||||
| 1021 | if( grep{/\bwrite\b/} @ARGV ){ $write = 1; cleanArgs("write"); }; | ||||||||||||||||||||||||||||
| 1022 | if( grep{/\bdrop\b/} @ARGV ){ $drop = 1; cleanArgs("drop"); }; | ||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||
| 1024 | our $StructureName = $ARGV[0]; # default structure | ||||||||||||||||||||||||||||
| 1025 | our $structure = $ARGV[0]; # default structure | ||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||
| 1027 | ########################################################################## | ||||||||||||||||||||||||||||
| 1028 | cat $dir/* | egrep -v "(our|my|use|sub|package)" | egrep -i "(instance|animal|whale|mammal|sea)$" | egrep "^ [1]:" | ||||||||||||||||||||||||||||
| 1029 | 1: andaman_sea | ||||||||||||||||||||||||||||
| 1030 | 1: swansea | ||||||||||||||||||||||||||||
| 1031 | 1: domesticanimal | ||||||||||||||||||||||||||||
| 1032 | 1: fictionalanimal | ||||||||||||||||||||||||||||
| 1033 | 1: marineanimal | ||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||
| 1037 | cat $dir/* | egrep -v "(our|my|use|sub|package)" | egrep -i "(instance|animal|whale|mammal|sea)$" | data-freq | egrep -v "^ [1]:" | ||||||||||||||||||||||||||||
| 1038 | 84: animal | ||||||||||||||||||||||||||||
| 1039 | 26: mammal | ||||||||||||||||||||||||||||
| 1040 | 25: eutherian_mammal | ||||||||||||||||||||||||||||
| 1041 | 25: placental_mammal | ||||||||||||||||||||||||||||
| 1042 | 12: domesticated_animal | ||||||||||||||||||||||||||||
| 1043 | 11: domestic_animal | ||||||||||||||||||||||||||||
| 1044 | 6: predatory_animal | ||||||||||||||||||||||||||||
| 1045 | 6: sea_animal | ||||||||||||||||||||||||||||
| 1046 | 5: fictional_animal | ||||||||||||||||||||||||||||
| 1047 | 5: marine_animal | ||||||||||||||||||||||||||||
| 1048 | 5: range_animal | ||||||||||||||||||||||||||||
| 1049 | 5: work_animal | ||||||||||||||||||||||||||||
| 1050 | 5: hoofed_mammal | ||||||||||||||||||||||||||||
| 1051 | 3: artiodactyl_mammal | ||||||||||||||||||||||||||||
| 1052 | 2: perissodactyl_mammal | ||||||||||||||||||||||||||||
| 1053 | 2: instance | ||||||||||||||||||||||||||||
| 1054 | 2: moss_animal | ||||||||||||||||||||||||||||
| 1055 | 2: anglesea | ||||||||||||||||||||||||||||
| 1056 | 2: female_mammal | ||||||||||||||||||||||||||||
| 1057 | 2: fossorial_mammal | ||||||||||||||||||||||||||||
| 1058 | 2: mediterranean_sea | ||||||||||||||||||||||||||||
| 1059 | 2: aquatic_mammal | ||||||||||||||||||||||||||||
| 1060 | 2: cetacean_mammal | ||||||||||||||||||||||||||||
| 1061 | 2: toothed_whale | ||||||||||||||||||||||||||||
| 1062 | 2: whale | ||||||||||||||||||||||||||||