| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -W |
|
2
|
|
|
|
|
|
|
package AI::MicroStructure; |
|
3
|
8
|
|
|
8
|
|
317356
|
use strict; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
224
|
|
|
4
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
278
|
|
|
5
|
8
|
|
|
8
|
|
40
|
use Carp; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
610
|
|
|
6
|
8
|
|
|
8
|
|
40
|
use Digest::MD5 qw(md5 md5_hex md5_base64); |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
466
|
|
|
7
|
8
|
|
|
8
|
|
5769
|
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); |
|
|
8
|
|
|
|
|
6313
|
|
|
|
8
|
|
|
|
|
539
|
|
|
8
|
8
|
|
|
8
|
|
6358
|
use Try::Tiny; |
|
|
8
|
|
|
|
|
19612
|
|
|
|
8
|
|
|
|
|
462
|
|
|
9
|
8
|
|
|
8
|
|
47
|
use File::Basename; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
776
|
|
|
10
|
8
|
|
|
8
|
|
41
|
use File::Spec; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
217
|
|
|
11
|
8
|
|
|
8
|
|
38
|
use File::Glob; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
383
|
|
|
12
|
8
|
|
|
8
|
|
5189
|
use Data::Dumper; |
|
|
8
|
|
|
|
|
50159
|
|
|
|
8
|
|
|
|
|
417
|
|
|
13
|
8
|
|
|
8
|
|
6580
|
use Data::Printer; |
|
|
8
|
|
|
|
|
291530
|
|
|
|
8
|
|
|
|
|
57
|
|
|
14
|
8
|
|
|
8
|
|
17974
|
use AI::MicroStructure::Util; |
|
|
8
|
|
|
|
|
26
|
|
|
|
8
|
|
|
|
|
235
|
|
|
15
|
8
|
|
|
8
|
|
43
|
use Carp qw(croak); |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
11721
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $absstructdir = ""; |
|
18
|
|
|
|
|
|
|
our $structdir = ""; |
|
19
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
|
20
|
|
|
|
|
|
|
our $Structure = 'any'; # default structure |
|
21
|
|
|
|
|
|
|
our $CODESET = 'utf8'; |
|
22
|
|
|
|
|
|
|
our $LANG = ''; |
|
23
|
|
|
|
|
|
|
our %MICRO; |
|
24
|
|
|
|
|
|
|
our %MODS; |
|
25
|
|
|
|
|
|
|
our %ALIEN; |
|
26
|
|
|
|
|
|
|
our $str = "[A-Z]"; |
|
27
|
|
|
|
|
|
|
our $special = "any"; |
|
28
|
|
|
|
|
|
|
our $search; |
|
29
|
|
|
|
|
|
|
our $data={}; |
|
30
|
|
|
|
|
|
|
our $item=""; |
|
31
|
|
|
|
|
|
|
our @items; |
|
32
|
|
|
|
|
|
|
our @a=(); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
eval "\$$_=1; " for @ARGV; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
if( grep{/\bnew\b/} @ARGV ){ $new = 1; cleanArgs("new"); } |
|
44
|
|
|
|
|
|
|
if( grep{/\bwrite\b/} @ARGV ){ $write = 1; cleanArgs("write"); }; |
|
45
|
|
|
|
|
|
|
if( grep{/\bdrop\b/} @ARGV ){ $drop = 1; cleanArgs("drop"); }; |
|
46
|
|
|
|
|
|
|
if( grep{/\bverbose\b/} @ARGV ){ $verbose = 1; cleanArgs("verbose"); }; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our $StructureName = $ARGV[0]; # default structure |
|
49
|
|
|
|
|
|
|
our $structure = $ARGV[0]; # default structure |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
our $state = AI::MicroStructure::Util::config(); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our @CWD=(); |
|
54
|
|
|
|
|
|
|
push @CWD , $state->{path}->{"cwd/structures"}; |
|
55
|
|
|
|
|
|
|
our $config = $state->{cfg}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our $micro = AI::MicroStructure->new($Structure); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$absstructdir = $state->{path}->{"cwd/structures"}; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub cleanArgs{ |
|
66
|
0
|
|
|
0
|
0
|
0
|
my ($key) = @_; |
|
67
|
0
|
|
|
|
|
0
|
my @tmp=(); |
|
68
|
0
|
|
|
|
|
0
|
foreach(@ARGV){ |
|
69
|
0
|
0
|
|
|
|
0
|
push @tmp,$_ unless($_=~/$key/);} |
|
70
|
0
|
|
|
|
|
0
|
@ARGV=@tmp; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
# private class method |
|
73
|
|
|
|
|
|
|
sub find_structures { |
|
74
|
8
|
|
|
8
|
0
|
20
|
my ( $class, @dirs ) = @_; |
|
75
|
|
|
|
|
|
|
$ALIEN{"base"} = [map @$_, |
|
76
|
0
|
|
|
|
|
0
|
map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } |
|
77
|
8
|
|
|
|
|
19
|
map { File::Glob::bsd_glob( |
|
|
8
|
|
|
|
|
590
|
|
|
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
|
|
|
|
|
19
|
return @{$ALIEN{"base"}}; |
|
|
8
|
|
|
|
|
41
|
|
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# fetch the list of standard structures |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub find_modules { |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
8
|
|
|
8
|
0
|
17
|
my $structures = {}; |
|
95
|
8
|
|
|
|
|
27
|
foreach(@INC) |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my @set = grep /($str)/, map @$_, |
|
99
|
408
|
|
|
|
|
9072
|
map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } |
|
100
|
88
|
|
|
|
|
142
|
map { File::Glob::bsd_glob( |
|
|
88
|
|
|
|
|
13961
|
|
|
101
|
|
|
|
|
|
|
File::Spec->catfile( $_, qw( AI MicroStructure *.pm ) ) ) } $_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
88
|
|
|
|
|
363
|
foreach(@set){ |
|
104
|
576
|
|
|
|
|
1411
|
$structures->{$_}=$_;# unless($_=~/(usr\/local|basis)/); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
8
|
|
|
|
|
418
|
return %$structures; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$MICRO{$_} = 0 for keys %{{__PACKAGE__->find_structures(@CWD)} }; |
|
113
|
|
|
|
|
|
|
$MODS{$_} = $_ for keys %{{__PACKAGE__->find_modules(@INC)} }; |
|
114
|
|
|
|
|
|
|
$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
|
|
|
0
|
0
|
0
|
my $x= {}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
$x->{"all_structures"} = [keys %MICRO]; |
|
130
|
0
|
|
|
|
|
0
|
$x->{"count_struct"} = sprintf(keys %MICRO); |
|
131
|
0
|
|
|
|
|
0
|
$x->{"structures"} = {}; |
|
132
|
0
|
|
|
|
|
0
|
$x->{"structures"}->{"json"} = sprintf(`ls /home/santex/repos/KnowledgeInterDisciplinary/data/json | egrep -i "($structure)";`); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
foreach my $con (@{$x->{"all_structures"}}){ |
|
|
0
|
|
|
|
|
0
|
|
|
136
|
0
|
0
|
|
|
|
0
|
next unless($con!~/any/); |
|
137
|
0
|
|
|
|
|
0
|
my @in = split("\n",eval{`cat $state->{path}->{"cwd/structures"}/$con.pm`;}); |
|
|
0
|
|
|
|
|
0
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# my $conc=join("|",@{$x->{"nsubcon"}->{$state->{path}->{"cwd/structures"}}->{$con}->{all}}); |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
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`)];#, |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
142
|
|
|
|
|
|
|
#split("\n",grep{$con}@{$x->{"structures"}->{"json"}})]; |
|
143
|
0
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
0
|
return $x; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub import { |
|
176
|
8
|
|
|
8
|
|
65
|
my $class = shift; |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
0
|
my @structures = ( grep { $_ eq ':all' } @_ ) |
|
179
|
8
|
50
|
|
|
|
39
|
? ( 'foo', grep { !/^(?:foo|:all)$/ } keys %MICRO ) # 'foo' is still first |
|
|
0
|
|
|
|
|
0
|
|
|
180
|
|
|
|
|
|
|
: @_; |
|
181
|
|
|
|
|
|
|
|
|
182
|
8
|
50
|
|
|
|
34
|
$Structure = $structures[0] if @structures; |
|
183
|
8
|
|
|
|
|
26
|
$micro = AI::MicroStructure->new( $Structure ); |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# export the microname() function |
|
186
|
8
|
|
|
8
|
|
45
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
3620
|
|
|
187
|
8
|
|
|
|
|
90
|
my $callpkg = caller; |
|
188
|
8
|
|
|
|
|
22
|
*{"$callpkg\::microname"} = \µname; # standard theme |
|
|
8
|
|
|
|
|
56
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# load the classes in @structures |
|
191
|
8
|
|
|
|
|
5770
|
for my $structure( @structures ) { |
|
192
|
0
|
|
|
|
|
0
|
eval "require AI::MicroStructure::$structure; import AI::MicroStructure::$structure;"; |
|
193
|
0
|
0
|
|
|
|
0
|
croak $@ if $@; |
|
194
|
0
|
|
|
0
|
|
0
|
*{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub new { |
|
199
|
18
|
|
|
18
|
0
|
602
|
my ( $class, @args ) = ( @_ ); |
|
200
|
18
|
|
|
|
|
28
|
my $structure; |
|
201
|
18
|
50
|
|
|
|
72
|
$structure = shift @args if @args % 2; |
|
202
|
18
|
50
|
|
|
|
50
|
$structure = $Structure unless $structure; # same default everywhere |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# defer croaking until name() is actually called |
|
205
|
18
|
|
|
|
|
109
|
bless { structure => $structure, args => { @args }, micro => {} ,state=>$state}, $class; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub _rearrange{ |
|
212
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
213
|
0
|
0
|
|
|
|
0
|
$self->{'payload'} = shift if @_; |
|
214
|
0
|
|
|
|
|
0
|
return %$self; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# CLASS METHODS |
|
218
|
|
|
|
|
|
|
sub add_structure { |
|
219
|
2
|
|
|
2
|
0
|
665
|
my $class = shift; |
|
220
|
2
|
|
|
|
|
6
|
my %structures = @_; |
|
221
|
|
|
|
|
|
|
|
|
222
|
2
|
|
|
|
|
7
|
for my $structure ( keys %structures ) { |
|
223
|
2
|
50
|
|
|
|
9
|
croak "The structure $structure already exists!" if exists $MICRO{$structure}; |
|
224
|
2
|
|
|
|
|
5
|
my @badnames = grep { !/^[a-z_]\w*$/i } @{$structures{$structure}}; |
|
|
4
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
5
|
|
|
225
|
2
|
50
|
|
|
|
11
|
croak "Invalid names (@badnames) for structure $structure" |
|
226
|
|
|
|
|
|
|
if @badnames; |
|
227
|
|
|
|
|
|
|
|
|
228
|
2
|
|
|
|
|
7
|
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
|
|
|
|
|
8
|
our \@List = qw( @{$structures{$structure}} ); |
|
234
|
|
|
|
|
|
|
__PACKAGE__->init(); |
|
235
|
|
|
|
|
|
|
1; |
|
236
|
|
|
|
|
|
|
EOC |
|
237
|
2
|
|
|
1
|
|
148
|
eval $code; |
|
|
1
|
|
|
1
|
|
5
|
|
|
|
1
|
|
|
1
|
|
2
|
|
|
|
1
|
|
|
1
|
|
23
|
|
|
|
1
|
|
|
|
|
627
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
58
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
53
|
|
|
238
|
2
|
|
|
|
|
5
|
$MICRO{$structure} = 1; # loaded |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# export the microstructure() function |
|
241
|
8
|
|
|
8
|
|
43
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
1120
|
|
|
242
|
2
|
|
|
|
|
4
|
my $callpkg = caller; |
|
243
|
2
|
|
|
0
|
|
8
|
*{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; |
|
|
2
|
|
|
|
|
16
|
|
|
|
0
|
|
|
|
|
0
|
|
|
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
|
|
|
4
|
0
|
217
|
my ($class, $structure ) = @_; |
|
255
|
4
|
|
|
|
|
12
|
$data = {}; |
|
256
|
|
|
|
|
|
|
|
|
257
|
4
|
|
|
|
|
9
|
my $fh; |
|
258
|
8
|
|
|
8
|
|
38
|
{ no strict 'refs'; $fh = *{"$structure\::DATA"}{IO}; } |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
12195
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
24
|
|
|
259
|
|
|
|
|
|
|
|
|
260
|
4
|
|
|
|
|
9
|
my $item; |
|
261
|
|
|
|
|
|
|
my @items; |
|
262
|
4
|
|
|
|
|
10
|
$$item = ""; |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
{ |
|
265
|
4
|
100
|
|
|
|
5
|
if(defined($fh)){ |
|
|
4
|
|
|
|
|
18
|
|
|
266
|
2
|
|
|
|
|
3
|
local $_; |
|
267
|
2
|
|
|
|
|
29
|
while (<$fh>) { |
|
268
|
32
|
100
|
|
|
|
117
|
/^#\s*(\w+.*)$/ && do { |
|
269
|
14
|
|
|
|
|
26
|
push @items, $item; |
|
270
|
14
|
|
|
|
|
16
|
$item = $data; |
|
271
|
14
|
|
|
|
|
17
|
my $last; |
|
272
|
14
|
|
|
|
|
101
|
my @keys = split m!\s+|\s*/\s*!, $1; |
|
273
|
14
|
|
100
|
|
|
157
|
$last = $item, $item = $item->{$_} ||= {} for @keys; |
|
274
|
14
|
|
|
|
|
31
|
$item = \( $last->{ $keys[-1] } = "" ); |
|
275
|
14
|
|
|
|
|
75
|
next; |
|
276
|
|
|
|
|
|
|
}; |
|
277
|
18
|
|
|
|
|
102
|
$$item .= $_; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
# clean up the items |
|
282
|
4
|
|
|
|
|
12
|
for( @items, $item ) { |
|
283
|
18
|
|
|
|
|
53
|
$$_ =~ s/\A\s*//; |
|
284
|
18
|
|
|
|
|
75
|
$$_ =~ s/\s*\z//; |
|
285
|
18
|
|
|
|
|
53
|
$$_ =~ s/\s+/ /g; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
|
|
289
|
4
|
|
|
|
|
22
|
return $data; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
#fitnes |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub fitnes { |
|
296
|
|
|
|
|
|
|
|
|
297
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
298
|
0
|
|
|
|
|
0
|
return sha1_hex($self->structures()); |
|
299
|
|
|
|
|
|
|
##my ($config,$structure, $config ) = (shift,[$self->structures()]); FIXME |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# main function |
|
304
|
0
|
|
|
0
|
0
|
0
|
sub microname { $micro->name( @_ ) }; |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub shitname { |
|
309
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
310
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
|
311
|
|
|
|
|
|
|
|
|
312
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
313
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
|
314
|
0
|
0
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
|
315
|
|
|
|
|
|
|
if $structure =~ /^(?:0|[1-9]\d*)$/; |
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
else { |
|
318
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
|
319
|
|
|
|
|
|
|
} |
|
320
|
|
|
|
|
|
|
|
|
321
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
|
322
|
0
|
|
|
|
|
0
|
my ( $structure, $category ) = split /\//, $structure, 2; |
|
323
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
|
324
|
|
|
|
|
|
|
try{ |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
# `micro new $structure`; |
|
327
|
|
|
|
|
|
|
|
|
328
|
0
|
|
|
0
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
|
329
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
|
330
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure} = AI::MicroStructure->new($structure,category => $category); |
|
331
|
0
|
|
|
|
|
0
|
print $self->{micro}{$structure}->name( $count ); |
|
332
|
0
|
|
|
|
|
0
|
return; |
|
333
|
|
|
|
0
|
|
|
} catch{ |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
} |
|
336
|
0
|
|
|
|
|
0
|
} |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
# corresponding method |
|
345
|
|
|
|
|
|
|
sub name { |
|
346
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
347
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
|
348
|
|
|
|
|
|
|
|
|
349
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
350
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
|
351
|
0
|
0
|
0
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
|
352
|
|
|
|
|
|
|
if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
else { |
|
355
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
|
356
|
|
|
|
|
|
|
} |
|
357
|
|
|
|
|
|
|
|
|
358
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
|
359
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
|
360
|
0
|
|
|
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
|
361
|
0
|
0
|
|
|
|
0
|
croak "MicroStructure list $structure does not exist!" if $@; |
|
362
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
$self->{micro}{$structure} = |
|
365
|
0
|
|
|
|
|
0
|
"AI::MicroStructure::$structure"->new( %{ $self->{args} } ); |
|
|
0
|
|
|
|
|
0
|
|
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure}->name( $count ); |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
# corresponding method |
|
372
|
|
|
|
|
|
|
sub namex { |
|
373
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
374
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
|
375
|
|
|
|
|
|
|
|
|
376
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
377
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
|
378
|
0
|
0
|
0
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
|
379
|
|
|
|
|
|
|
if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
else { |
|
382
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
|
383
|
|
|
|
|
|
|
} |
|
384
|
|
|
|
|
|
|
|
|
385
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
|
386
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
|
387
|
|
|
|
|
|
|
try { |
|
388
|
0
|
|
|
0
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
|
389
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
|
390
|
0
|
0
|
|
|
|
0
|
croak "MicroStructure list $structure does not exist!" if $@; |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
0
|
|
|
}catch{ |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
} |
|
395
|
0
|
|
|
|
|
0
|
} |
|
396
|
|
|
|
|
|
|
$self->{micro}{$structure} = |
|
397
|
0
|
|
|
|
|
0
|
"AI::MicroStructure::$structure"->new( %{ $self->{args} } ); |
|
|
0
|
|
|
|
|
0
|
|
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
} |
|
406
|
|
|
|
|
|
|
|
|
407
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure}->name( $count ); |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# other methods |
|
416
|
0
|
0
|
|
0
|
0
|
0
|
sub structures { wantarray ? ( sort keys %MICRO ) : scalar keys %MICRO } |
|
417
|
0
|
0
|
|
0
|
0
|
0
|
sub has_structure { $_[1] ? exists $MICRO{$_[1]} : 0 } |
|
418
|
0
|
0
|
|
0
|
0
|
0
|
sub configure_driver { $_[1] ? exists $MICRO{$_[1]} : 0 } |
|
419
|
|
|
|
|
|
|
sub count { |
|
420
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
421
|
0
|
|
|
|
|
0
|
my ( $structure, $count ); |
|
422
|
|
|
|
|
|
|
|
|
423
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
424
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
|
425
|
0
|
0
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
|
426
|
|
|
|
|
|
|
if $structure =~ /^(?:0|[1-9]\d*)$/; |
|
427
|
|
|
|
|
|
|
} |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
|
|
430
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
|
431
|
0
|
|
|
|
|
0
|
return scalar ($self->{micro}{$structure}->new); |
|
432
|
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
|
|
434
|
0
|
|
|
|
|
0
|
return 0; |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
sub trim |
|
439
|
|
|
|
|
|
|
{ |
|
440
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
441
|
0
|
|
|
|
|
0
|
my $string = shift; |
|
442
|
0
|
0
|
|
|
|
0
|
$string = "" unless $string; |
|
443
|
0
|
|
|
|
|
0
|
$string =~ s/^\s+//; |
|
444
|
0
|
|
|
|
|
0
|
$string =~ s/\s+$//; |
|
445
|
0
|
|
|
|
|
0
|
$string =~ s/\t//; |
|
446
|
0
|
|
|
|
|
0
|
$string =~ s/^\s//; |
|
447
|
0
|
|
|
|
|
0
|
return $string; |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub getBundle { |
|
452
|
|
|
|
|
|
|
|
|
453
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
|
|
457
|
0
|
|
|
|
|
0
|
my @structures = grep { !/^(?:any)/ } AI::MicroStructure->structures; |
|
|
0
|
|
|
|
|
0
|
|
|
458
|
0
|
|
|
|
|
0
|
my @micros; |
|
459
|
0
|
|
|
|
|
0
|
my @search=[]; |
|
460
|
0
|
|
|
|
|
0
|
for my $structure (@structures) { |
|
461
|
8
|
|
|
8
|
|
51
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
17918
|
|
|
462
|
0
|
|
|
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
|
463
|
|
|
|
|
|
|
|
|
464
|
0
|
|
|
|
|
0
|
my %isa = map { $_ => 1 } @{"AI::MicroStructure::$structure\::ISA"}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
465
|
0
|
0
|
|
|
|
0
|
if( exists $isa{'AI::MicroStructure::Locale'} ) { |
|
|
|
0
|
|
|
|
|
|
|
466
|
0
|
|
|
|
|
0
|
for my $lang ( "AI::MicroStructure::$structure"->languages() ) { |
|
467
|
0
|
|
|
|
|
0
|
push @micros, |
|
468
|
|
|
|
|
|
|
["AI::MicroStructure::$structure"->new( lang => $lang ),$lang]; |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
} |
|
472
|
|
|
|
|
|
|
} |
|
473
|
|
|
|
|
|
|
elsif( exists $isa{'AI::MicroStructure::MultiList'} ) { |
|
474
|
0
|
|
|
|
|
0
|
for my $cat ( "AI::MicroStructure::$structure"->categories(), ':all' ) { |
|
475
|
0
|
|
|
|
|
0
|
push @micros, |
|
476
|
|
|
|
|
|
|
[ "AI::MicroStructure::$structure"->new( category => $cat ),$cat]; |
|
477
|
|
|
|
|
|
|
} |
|
478
|
|
|
|
|
|
|
} |
|
479
|
|
|
|
|
|
|
else { |
|
480
|
0
|
|
|
|
|
0
|
push @micros, ["AI::MicroStructure::$structure"->new(),'']; |
|
481
|
|
|
|
|
|
|
} |
|
482
|
|
|
|
|
|
|
} |
|
483
|
|
|
|
|
|
|
|
|
484
|
0
|
|
|
|
|
0
|
my $all ={}; |
|
485
|
|
|
|
|
|
|
|
|
486
|
0
|
|
|
|
|
0
|
for my $test (@micros) { |
|
487
|
0
|
|
|
|
|
0
|
my $micro = $test->[0]; |
|
488
|
0
|
|
|
|
|
0
|
my %items; |
|
489
|
0
|
|
|
|
|
0
|
my $items = $micro->name(0); |
|
490
|
0
|
|
|
|
|
0
|
$items{$_}++ for $micro->name(0); |
|
491
|
0
|
|
|
|
|
0
|
my $key=sprintf("%s",$micro->structure); |
|
492
|
0
|
|
|
|
|
0
|
$all->{$key}=[$test->[1],$micro->name($items)]; |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
|
|
497
|
0
|
|
|
|
|
0
|
return $all; |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
} |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
sub save_cat { |
|
503
|
|
|
|
|
|
|
|
|
504
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
505
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
506
|
0
|
|
|
|
|
0
|
my $dat; |
|
507
|
0
|
|
|
|
|
0
|
my $ret = ""; |
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
0
|
foreach my $key(sort keys %{$data} ) { |
|
|
0
|
|
|
|
|
0
|
|
|
511
|
0
|
0
|
|
|
|
0
|
next unless($_); |
|
512
|
|
|
|
|
|
|
#ref $hash->{$_} eq "HASH" |
|
513
|
0
|
0
|
|
|
|
0
|
if(ref $data->{$key} eq "HASH"){ |
|
514
|
0
|
|
|
|
|
0
|
$ret .= "\n".$self->save_cat($data->{$key}); |
|
515
|
|
|
|
|
|
|
}else{ |
|
516
|
0
|
|
|
|
|
0
|
$dat = $data->{$key}; |
|
517
|
0
|
|
|
|
|
0
|
$dat =~ s/^|,/\n/g; |
|
518
|
0
|
|
|
|
|
0
|
$dat =~ s/\n\n/\n/g; |
|
519
|
0
|
|
|
|
|
0
|
$dat =~ s/->\n|[0-9]\n//g; |
|
520
|
|
|
|
|
|
|
|
|
521
|
0
|
0
|
|
|
|
0
|
$ret .= "# ".($key=~/names|default|[a-z]/?$key:"names ".$key); |
|
522
|
0
|
|
|
|
|
0
|
$ret .= "\n ".$dat."\n"; |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
} |
|
526
|
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
0
|
return $ret; |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
sub save_default { |
|
532
|
|
|
|
|
|
|
|
|
533
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
534
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
535
|
0
|
|
|
|
|
0
|
my $line = shift; |
|
536
|
0
|
|
|
|
|
0
|
my $dat = {}; |
|
537
|
0
|
|
|
|
|
0
|
my @in = (); |
|
538
|
0
|
|
|
|
|
0
|
my $active=0; |
|
539
|
0
|
0
|
|
|
|
0
|
$line = $Structure unless($line); |
|
540
|
|
|
|
|
|
|
|
|
541
|
0
|
|
|
|
|
0
|
foreach(@{$data->{rows}->{"coordinate"}}){ |
|
|
0
|
|
|
|
|
0
|
|
|
542
|
|
|
|
|
|
|
|
|
543
|
0
|
0
|
|
|
|
0
|
if($_ eq $line){ $active=1; } |
|
|
0
|
|
|
|
|
0
|
|
|
544
|
|
|
|
|
|
|
|
|
545
|
0
|
0
|
|
|
|
0
|
if(1+$line eq $_){ $active=0; } |
|
|
0
|
|
|
|
|
0
|
|
|
546
|
|
|
|
|
|
|
|
|
547
|
0
|
0
|
|
|
|
0
|
if($active==1){ |
|
548
|
0
|
|
|
|
|
0
|
$_=~s/,//g; |
|
549
|
0
|
|
|
|
|
0
|
$_ = $self->trim($_); |
|
550
|
0
|
0
|
|
|
|
0
|
$dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); |
|
551
|
|
|
|
|
|
|
} |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
|
|
555
|
0
|
|
|
|
|
0
|
foreach(@{$data->{rows}->{"search"}}){ |
|
|
0
|
|
|
|
|
0
|
|
|
556
|
|
|
|
|
|
|
|
|
557
|
0
|
0
|
|
|
|
0
|
if($_ eq $line){ $active=1; } |
|
|
0
|
|
|
|
|
0
|
|
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
|
|
560
|
0
|
0
|
|
|
|
0
|
if(1+$line eq $_){ $active=0; } |
|
|
0
|
|
|
|
|
0
|
|
|
561
|
|
|
|
|
|
|
|
|
562
|
0
|
0
|
|
|
|
0
|
if($active==1){ |
|
563
|
0
|
|
|
|
|
0
|
$_=~s/,//g; |
|
564
|
0
|
|
|
|
|
0
|
$_ = $self->trim($_); |
|
565
|
0
|
0
|
|
|
|
0
|
$dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
} |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
} |
|
571
|
|
|
|
|
|
|
|
|
572
|
0
|
|
|
|
|
0
|
push @in , keys %{$dat->{names}}; |
|
|
0
|
|
|
|
|
0
|
|
|
573
|
0
|
|
|
|
|
0
|
push @in , values %{$data->{names}}; |
|
|
0
|
|
|
|
|
0
|
|
|
574
|
0
|
|
|
|
|
0
|
$dat->{names} = join(" ",@in); |
|
575
|
0
|
|
|
|
|
0
|
$dat->{names} =~ s/$line(.*?)\-\>(.*?) [1-9] /$1 $2/g; |
|
576
|
0
|
|
|
|
|
0
|
$dat->{names} =~ s/ / /g; |
|
577
|
0
|
|
|
|
|
0
|
my @file = grep{/$Structure/}map{File::Glob::bsd_glob( |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
578
|
|
|
|
|
|
|
File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
|
|
581
|
0
|
0
|
|
|
|
0
|
if(@file){ |
|
582
|
0
|
0
|
|
|
|
0
|
open(SELF,"+<$file[0]") || die $!; |
|
583
|
|
|
|
|
|
|
|
|
584
|
0
|
0
|
|
|
|
0
|
while(<SELF>){last if /^__DATA__/} |
|
|
0
|
|
|
|
|
0
|
|
|
585
|
|
|
|
|
|
|
|
|
586
|
0
|
|
|
|
|
0
|
truncate(SELF,tell SELF); |
|
587
|
|
|
|
|
|
|
|
|
588
|
0
|
|
|
|
|
0
|
print SELF $self->save_cat($dat); |
|
589
|
|
|
|
|
|
|
|
|
590
|
0
|
|
|
|
|
0
|
truncate(SELF,tell SELF); |
|
591
|
0
|
|
|
|
|
0
|
close SELF; |
|
592
|
|
|
|
|
|
|
} |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
} |
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
sub openData{ |
|
597
|
|
|
|
|
|
|
|
|
598
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
599
|
|
|
|
|
|
|
|
|
600
|
0
|
|
|
|
|
0
|
my @datax = (); |
|
601
|
|
|
|
|
|
|
|
|
602
|
0
|
0
|
|
|
|
0
|
if(<DATA>){ |
|
603
|
|
|
|
|
|
|
|
|
604
|
0
|
|
|
|
|
0
|
@datax = <DATA>; |
|
605
|
|
|
|
|
|
|
|
|
606
|
0
|
|
|
|
|
0
|
while(@datax){ |
|
607
|
0
|
|
|
|
|
0
|
chomp; |
|
608
|
0
|
0
|
|
|
|
0
|
if($_=~/^#\s*(\w+.*)$/) { |
|
609
|
0
|
|
|
|
|
0
|
@a=split(" ",$1); |
|
610
|
0
|
0
|
|
|
|
0
|
if($#a){ |
|
611
|
0
|
|
|
|
|
0
|
$data->{$a[0]}->{$a[1]}=""; |
|
612
|
|
|
|
|
|
|
}else{ |
|
613
|
0
|
|
|
|
|
0
|
$data->{$1}=""; |
|
614
|
|
|
|
|
|
|
} |
|
615
|
0
|
0
|
|
|
|
0
|
$item=$1 unless($#a); |
|
616
|
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
}else{ |
|
618
|
|
|
|
|
|
|
|
|
619
|
0
|
|
|
|
|
0
|
my @keys = split m!\s+|\s*/\s*!,$_; |
|
620
|
0
|
|
|
|
|
0
|
foreach(sort @keys){ |
|
621
|
0
|
0
|
|
|
|
0
|
if($#a){ |
|
622
|
0
|
0
|
|
|
|
0
|
$data->{$a[0]}->{$a[1]} .= " $_" unless($_ eq ""); |
|
623
|
|
|
|
|
|
|
}else{ |
|
624
|
0
|
0
|
|
|
|
0
|
$data->{$item} .= " $_" unless($_ eq ""); |
|
625
|
|
|
|
|
|
|
} |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
}; |
|
629
|
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
} |
|
631
|
|
|
|
|
|
|
} |
|
632
|
0
|
|
|
|
|
0
|
return $data; |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
} |
|
636
|
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
sub getBlank { |
|
638
|
|
|
|
|
|
|
|
|
639
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
640
|
0
|
|
|
|
|
0
|
my $structure = shift; |
|
641
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
642
|
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
|
|
645
|
0
|
|
|
|
|
0
|
my $usage = ""; |
|
646
|
|
|
|
|
|
|
|
|
647
|
0
|
|
|
|
|
0
|
$usage = "#!/usr/bin/perl -W\n"; |
|
648
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
my $new = {}; |
|
661
|
0
|
|
|
|
|
0
|
foreach my $k |
|
662
|
0
|
|
|
|
|
0
|
(grep{!/^[0-9]/}map{$_=$self->trim($_)}@{$data->{rows}->{"search"}}){ |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
663
|
|
|
|
|
|
|
|
|
664
|
0
|
|
|
|
|
0
|
$k =~ s/[ ]/_/g; |
|
665
|
0
|
|
|
|
|
0
|
$k =~ s/[\(]|[\)]//g; |
|
666
|
0
|
0
|
|
|
|
0
|
next if($k=~/synonyms|hypernyms/); |
|
667
|
0
|
|
|
|
|
0
|
print $k; |
|
668
|
0
|
|
|
|
|
0
|
$new->{$k}=[map{$_=[map{$_=$self->trim($_)}split("\n|, ",$_)]} |
|
|
0
|
|
|
|
|
0
|
|
|
669
|
0
|
|
|
|
|
0
|
grep{!/synonyms|hypernyms/}split("sense~~~~~~~~~", |
|
|
0
|
|
|
|
|
0
|
|
|
670
|
|
|
|
|
|
|
lc `micro-wnet $k`)]; |
|
671
|
0
|
0
|
|
|
|
0
|
next unless(@{$new->{$k}}); |
|
|
0
|
|
|
|
|
0
|
|
|
672
|
|
|
|
|
|
|
# $new->{$k}=~s/Sense*\n(.*?)\n\n/$1/g; |
|
673
|
|
|
|
|
|
|
# @{$new->{$k}} = [split("\n|,",$new->{$k})]; |
|
674
|
0
|
|
|
|
|
0
|
$data->{rows}->{"ident"}->{md5_base64($new->{$k})} = $new->{$k}; |
|
675
|
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
} |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
|
|
679
|
0
|
|
|
|
|
0
|
my $list = join("\n",sort keys %$new); |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# $list =~ s/_//g; |
|
683
|
|
|
|
|
|
|
|
|
684
|
0
|
|
|
|
|
0
|
$usage .= " |
|
685
|
|
|
|
|
|
|
__DATA__ |
|
686
|
|
|
|
|
|
|
# names |
|
687
|
|
|
|
|
|
|
".$list; |
|
688
|
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
} |
|
693
|
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
sub save_new { |
|
695
|
|
|
|
|
|
|
|
|
696
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
697
|
0
|
|
|
|
|
0
|
my $StructureName = shift; |
|
698
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
699
|
|
|
|
|
|
|
|
|
700
|
0
|
0
|
|
|
|
0
|
if($StructureName){ |
|
701
|
|
|
|
|
|
|
#$StructureName = lc $self->trim(`micro`) unless($StructureName); |
|
702
|
0
|
|
|
|
|
0
|
my $file = "$absstructdir/$StructureName.pm"; |
|
703
|
|
|
|
|
|
|
|
|
704
|
0
|
0
|
|
|
|
0
|
print `mkdir -p $absstructdir` unless(-d $absstructdir); |
|
705
|
0
|
|
|
|
|
0
|
my $fh; |
|
706
|
|
|
|
|
|
|
|
|
707
|
0
|
0
|
|
|
|
0
|
open($fh,">$file") || warn @{[$file,$!]}; |
|
|
0
|
|
|
|
|
0
|
|
|
708
|
|
|
|
|
|
|
|
|
709
|
0
|
|
|
|
|
0
|
print $fh $self->getBlank($StructureName,$data); |
|
710
|
|
|
|
|
|
|
|
|
711
|
0
|
|
|
|
|
0
|
close $fh; |
|
712
|
0
|
|
|
|
|
0
|
$Structure = $StructureName; |
|
713
|
0
|
|
|
|
|
0
|
push @CWD,$file; |
|
714
|
0
|
|
|
|
|
0
|
return 1; |
|
715
|
|
|
|
|
|
|
} |
|
716
|
|
|
|
|
|
|
} |
|
717
|
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
sub drop { |
|
721
|
|
|
|
|
|
|
|
|
722
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
723
|
0
|
|
|
|
|
0
|
my $StructureName = shift; |
|
724
|
|
|
|
|
|
|
|
|
725
|
0
|
|
|
|
|
0
|
my @file = grep{/$StructureName.pm/}map{File::Glob::bsd_glob( |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
726
|
|
|
|
|
|
|
File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; |
|
727
|
0
|
|
|
|
|
0
|
my $fh = shift @file; |
|
728
|
0
|
0
|
|
|
|
0
|
if(`ls $fh`) |
|
729
|
|
|
|
|
|
|
{ |
|
730
|
|
|
|
|
|
|
|
|
731
|
0
|
|
|
|
|
0
|
print `rm $fh`; |
|
732
|
|
|
|
|
|
|
} |
|
733
|
|
|
|
|
|
|
#push @CWD,$file[1]; |
|
734
|
|
|
|
|
|
|
|
|
735
|
0
|
|
|
|
|
0
|
return 1; |
|
736
|
|
|
|
|
|
|
} |
|
737
|
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
|
|
739
|
|
|
|
0
|
0
|
|
sub help{ |
|
740
|
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
} |
|
742
|
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
END{ |
|
746
|
|
|
|
|
|
|
|
|
747
|
8
|
50
|
|
8
|
|
4366
|
if($init){} |
|
748
|
8
|
50
|
|
|
|
48
|
if($available){} |
|
749
|
8
|
50
|
|
|
|
28
|
if($lib){} |
|
750
|
8
|
50
|
|
|
|
28
|
if($list){ |
|
751
|
0
|
|
|
|
|
0
|
p @{[__PACKAGE__->getComponents]}; |
|
|
0
|
|
|
|
|
0
|
|
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
} |
|
754
|
8
|
50
|
|
|
|
27
|
if($use){} |
|
755
|
8
|
50
|
|
|
|
25
|
if($off){} |
|
756
|
8
|
50
|
|
|
|
30
|
if($switch){} |
|
757
|
8
|
50
|
|
|
|
67
|
if($mirror){} |
|
758
|
8
|
50
|
|
|
|
29
|
if($version){ |
|
759
|
0
|
|
|
|
|
0
|
printf($VERSION); |
|
760
|
0
|
|
|
|
|
0
|
exit(0); |
|
761
|
|
|
|
|
|
|
} |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
|
|
765
|
8
|
50
|
|
|
|
27
|
if($help) { |
|
766
|
0
|
|
|
|
|
0
|
printf(__PACKAGE__->help()); |
|
767
|
0
|
|
|
|
|
0
|
exit(0); |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
} |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
|
|
775
|
8
|
50
|
|
|
|
27
|
if($drop == 1) { |
|
776
|
0
|
|
|
|
|
0
|
__PACKAGE__->drop($StructureName); |
|
777
|
0
|
|
|
|
|
0
|
exit 0; |
|
778
|
|
|
|
|
|
|
} |
|
779
|
|
|
|
|
|
|
|
|
780
|
8
|
50
|
|
|
|
31
|
if($new==1){ |
|
781
|
|
|
|
|
|
|
|
|
782
|
8
|
|
|
8
|
|
7275
|
use Term::ReadKey; |
|
|
8
|
|
|
|
|
36978
|
|
|
|
8
|
|
|
|
|
716
|
|
|
783
|
8
|
|
|
8
|
|
8551
|
use JSON; |
|
|
8
|
|
|
|
|
103930
|
|
|
|
8
|
|
|
|
|
38
|
|
|
784
|
|
|
|
|
|
|
|
|
785
|
0
|
|
|
|
|
0
|
my $data = decode_json(lc`micro-sense $StructureName words`); |
|
786
|
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
|
|
789
|
0
|
|
|
|
|
0
|
my $char; |
|
790
|
|
|
|
|
|
|
my $line; |
|
791
|
0
|
|
|
|
|
0
|
my $senses=@{$data->{"senses"}}; |
|
|
0
|
|
|
|
|
0
|
|
|
792
|
0
|
0
|
|
|
|
0
|
$senses= 0 unless($senses); |
|
793
|
0
|
0
|
|
|
|
0
|
if(!$verbose){ |
|
794
|
|
|
|
|
|
|
|
|
795
|
0
|
|
|
|
|
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
|
0
|
|
|
|
0
|
$line = 1 unless($senses != 1); |
|
802
|
0
|
0
|
|
|
|
0
|
if($verbose){ |
|
803
|
0
|
|
|
|
|
0
|
$line=1; |
|
804
|
|
|
|
|
|
|
} |
|
805
|
0
|
0
|
|
|
|
0
|
chomp($line = <STDIN>) unless($line); |
|
806
|
|
|
|
|
|
|
|
|
807
|
0
|
|
|
|
|
0
|
my $d = join("#",@{$data->{rows}->{search}}); |
|
|
0
|
|
|
|
|
0
|
|
|
808
|
|
|
|
|
|
|
|
|
809
|
0
|
|
|
|
|
0
|
my @d = grep{/^$line#/}split("sense~~~~~~~~~",$d); |
|
|
0
|
|
|
|
|
0
|
|
|
810
|
0
|
|
|
|
|
0
|
@{$data->{rows}->{"search"}}=split("#",join("",@d)); |
|
|
0
|
|
|
|
|
0
|
|
|
811
|
|
|
|
|
|
|
|
|
812
|
0
|
0
|
|
|
|
0
|
if($line>0){ |
|
813
|
0
|
|
|
|
|
0
|
__PACKAGE__->save_new($StructureName,$data,$line); |
|
814
|
0
|
|
|
|
|
0
|
exit 0; |
|
815
|
|
|
|
|
|
|
}else{ |
|
816
|
|
|
|
|
|
|
|
|
817
|
0
|
|
|
|
|
0
|
printf "your logic is today impaired !!!\n"; |
|
818
|
0
|
|
|
|
|
0
|
exit 0; |
|
819
|
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
} |
|
821
|
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
} |
|
825
|
|
|
|
|
|
|
|
|
826
|
8
|
50
|
|
|
|
62
|
if($write == 1) { |
|
827
|
0
|
|
|
|
|
0
|
__PACKAGE__->save_default(); |
|
828
|
|
|
|
|
|
|
} |
|
829
|
|
|
|
|
|
|
} |
|
830
|
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
sub usage { |
|
836
|
|
|
|
|
|
|
|
|
837
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
838
|
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
|
|
840
|
0
|
|
|
|
|
0
|
my $search = shift; |
|
841
|
0
|
|
|
|
|
0
|
my $senseNr = shift; |
|
842
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
843
|
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
|
|
845
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
$usage =~ s/<0>_/\033[0;32mThe word $search\033[255;34m/g; |
|
892
|
0
|
|
|
|
|
0
|
$usage =~ s/<1>_/\033[0;32mhas $senseNr concept's\033[255;34m/g; |
|
893
|
0
|
|
|
|
|
0
|
$usage =~ s/<2>_/\033[0;32mwe need to find out the which one\033[255;34m/g; |
|
894
|
0
|
|
|
|
|
0
|
$usage =~ s/<3>_/\033[0;32mto use for our new,\033[255;34m/g; |
|
895
|
0
|
|
|
|
|
0
|
$usage =~ s/<4>_/\033[0;32mmicro-structure,\033[255;34m/g; |
|
896
|
0
|
|
|
|
|
0
|
$usage =~ s/<5>_//g; |
|
897
|
0
|
|
|
|
|
0
|
my @row = (); |
|
898
|
0
|
|
|
|
|
0
|
my $ii=0; |
|
899
|
0
|
|
|
|
|
0
|
foreach my $sensnrx (sort keys %{$data->{"rows"}->{"senses"}}) |
|
|
0
|
|
|
|
|
0
|
|
|
900
|
|
|
|
|
|
|
{ |
|
901
|
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
|
|
904
|
0
|
|
|
|
|
0
|
my $row = $data->{"rows"}->{"senses"}->{$sensnrx}; |
|
905
|
0
|
|
|
|
|
0
|
my $txt=""; |
|
906
|
|
|
|
|
|
|
|
|
907
|
0
|
|
|
|
|
0
|
foreach(@{$row->{"basics"}}[1..2]){ |
|
|
0
|
|
|
|
|
0
|
|
|
908
|
0
|
0
|
|
|
|
0
|
next unless($_); |
|
909
|
0
|
|
|
|
|
0
|
$txt .= sprintf("\033[0;31m %s\033[255;34m",$_); |
|
910
|
|
|
|
|
|
|
} |
|
911
|
|
|
|
|
|
|
|
|
912
|
0
|
|
|
|
|
0
|
$txt .= sprintf("",$_); |
|
913
|
0
|
|
|
|
|
0
|
$usage =~ s/$sensnrx>_/($sensnrx):$txt/g; |
|
914
|
0
|
0
|
|
|
|
0
|
if($sensnrx>9){ |
|
915
|
0
|
|
|
|
|
0
|
$usage .= sprintf("\n(%d):%s",$sensnrx,$txt); |
|
916
|
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
} |
|
918
|
|
|
|
|
|
|
} |
|
919
|
|
|
|
|
|
|
|
|
920
|
0
|
|
|
|
|
0
|
foreach my $ii (0..16){ |
|
921
|
0
|
|
|
|
|
0
|
$usage =~ s/$ii>_//g; |
|
922
|
|
|
|
|
|
|
} |
|
923
|
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
|
|
925
|
0
|
|
|
|
|
0
|
return $usage; |
|
926
|
|
|
|
|
|
|
} |
|
927
|
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
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 |