line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package AI::MicroStructure; |
3
|
8
|
|
|
8
|
|
323688
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
243
|
|
4
|
8
|
|
|
8
|
|
47
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
223
|
|
5
|
8
|
|
|
8
|
|
45
|
use Carp; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
681
|
|
6
|
8
|
|
|
8
|
|
45
|
use Digest::MD5 qw(md5 md5_hex md5_base64); |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
538
|
|
7
|
8
|
|
|
8
|
|
6182
|
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); |
|
8
|
|
|
|
|
6182
|
|
|
8
|
|
|
|
|
556
|
|
8
|
8
|
|
|
8
|
|
7996
|
use Try::Tiny; |
|
8
|
|
|
|
|
20085
|
|
|
8
|
|
|
|
|
479
|
|
9
|
8
|
|
|
8
|
|
51
|
use File::Basename; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
711
|
|
10
|
8
|
|
|
8
|
|
41
|
use File::Spec; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
201
|
|
11
|
8
|
|
|
8
|
|
38
|
use File::Glob; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
370
|
|
12
|
8
|
|
|
8
|
|
4940
|
use Data::Dumper; |
|
8
|
|
|
|
|
51225
|
|
|
8
|
|
|
|
|
429
|
|
13
|
8
|
|
|
8
|
|
6327
|
use Data::Printer; |
|
8
|
|
|
|
|
259589
|
|
|
8
|
|
|
|
|
54
|
|
14
|
8
|
|
|
8
|
|
5320
|
use AI::MicroStructure::Util; |
|
8
|
|
|
|
|
30
|
|
|
8
|
|
|
|
|
233
|
|
15
|
8
|
|
|
8
|
|
43
|
use Carp qw(croak); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
7977
|
|
16
|
|
|
|
|
|
|
our $absstructdir = ""; |
17
|
|
|
|
|
|
|
our $structdir = ""; |
18
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
19
|
|
|
|
|
|
|
our $Structure = 'any'; # default structure |
20
|
|
|
|
|
|
|
our $CODESET = 'utf8'; |
21
|
|
|
|
|
|
|
our $LANG = ''; |
22
|
|
|
|
|
|
|
our %MICRO; |
23
|
|
|
|
|
|
|
our %MODS; |
24
|
|
|
|
|
|
|
our %ALIEN; |
25
|
|
|
|
|
|
|
our $str = "[A-Z]"; |
26
|
|
|
|
|
|
|
our $special = "any"; |
27
|
|
|
|
|
|
|
our $search; |
28
|
|
|
|
|
|
|
our $data={}; |
29
|
|
|
|
|
|
|
our $item=""; |
30
|
|
|
|
|
|
|
our @items; |
31
|
|
|
|
|
|
|
our @a=(); |
32
|
|
|
|
|
|
|
our ($init,$new,$drop,$available,$lib, |
33
|
|
|
|
|
|
|
$list,$use,$off,$switch,$mirror, |
34
|
|
|
|
|
|
|
$version,$help,$write,$verbose) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0); |
35
|
|
|
|
|
|
|
eval "\$$_=1; " for @ARGV; |
36
|
|
|
|
|
|
|
if( grep{/\bnew\b/} @ARGV ){ $new = 1; cleanArgs("new"); } |
37
|
|
|
|
|
|
|
if( grep{/\bwrite\b/} @ARGV ){ $write = 1; cleanArgs("write"); }; |
38
|
|
|
|
|
|
|
if( grep{/\bdrop\b/} @ARGV ){ $drop = 1; cleanArgs("drop"); }; |
39
|
|
|
|
|
|
|
if( grep{/\bverbose\b/} @ARGV ){ $verbose = 1; cleanArgs("verbose"); }; |
40
|
|
|
|
|
|
|
our $StructureName = $ARGV[0]; # default structure |
41
|
|
|
|
|
|
|
our $structure = $ARGV[0]; # default structure |
42
|
|
|
|
|
|
|
our $state = AI::MicroStructure::Util::config(); |
43
|
|
|
|
|
|
|
our @CWD=(); |
44
|
|
|
|
|
|
|
push @CWD , $state->{path}->{"cwd/structures"}; |
45
|
|
|
|
|
|
|
our $config = $state->{cfg}; |
46
|
|
|
|
|
|
|
our $micro = AI::MicroStructure->new($Structure); |
47
|
|
|
|
|
|
|
$absstructdir = $state->{path}->{"cwd/structures"}; |
48
|
|
|
|
|
|
|
sub cleanArgs{ |
49
|
0
|
|
|
0
|
0
|
0
|
my ($key) = @_; |
50
|
0
|
|
|
|
|
0
|
my @tmp=(); |
51
|
0
|
|
|
|
|
0
|
foreach(@ARGV){ |
52
|
0
|
0
|
|
|
|
0
|
push @tmp,$_ unless($_=~/$key/);} |
53
|
0
|
|
|
|
|
0
|
@ARGV=@tmp; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
# private class method |
56
|
|
|
|
|
|
|
sub find_structures { |
57
|
8
|
|
|
8
|
0
|
20
|
my ( $class, @dirs ) = @_; |
58
|
|
|
|
|
|
|
$ALIEN{"base"} = [map @$_, |
59
|
0
|
|
|
|
|
0
|
map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } |
60
|
8
|
|
|
|
|
21
|
map { File::Glob::bsd_glob( |
|
8
|
|
|
|
|
610
|
|
61
|
|
|
|
|
|
|
File::Spec->catfile( $_, ($structdir,"*") ) ) } @dirs]; |
62
|
8
|
|
|
|
|
17
|
return @{$ALIEN{"base"}}; |
|
8
|
|
|
|
|
46
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# fetch the list of standard structures |
66
|
|
|
|
|
|
|
sub find_modules { |
67
|
8
|
|
|
8
|
0
|
17
|
my $structures = {}; |
68
|
8
|
|
|
|
|
25
|
foreach(@INC) |
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
my @set = grep /($str)/, map @$_, |
71
|
240
|
|
|
|
|
5909
|
map { [ ( fileparse( $_, qr/\.pm$/ ) )[0] => $_ ] } |
72
|
88
|
|
|
|
|
147
|
map { File::Glob::bsd_glob( |
|
88
|
|
|
|
|
10111
|
|
73
|
|
|
|
|
|
|
File::Spec->catfile( $_, qw( AI MicroStructure *.pm ) ) ) } $_; |
74
|
88
|
|
|
|
|
338
|
foreach(@set){ |
75
|
408
|
|
|
|
|
970
|
$structures->{$_}=$_;# unless($_=~/(usr\/local|basis)/); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
8
|
|
|
|
|
323
|
return %$structures; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
$MICRO{$_} = 0 for keys %{{__PACKAGE__->find_structures(@CWD)} }; |
81
|
|
|
|
|
|
|
$MODS{$_} = $_ for keys %{{__PACKAGE__->find_modules(@INC)} }; |
82
|
|
|
|
|
|
|
$search = join("|",keys %MICRO); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
BEGIN{ |
86
|
8
|
|
|
8
|
|
45
|
use File::HomeDir; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
813
|
|
87
|
8
|
|
|
8
|
|
42
|
my $fileDir = File::HomeDir->my_home . "/data-hub/structures/"; |
88
|
8
|
|
|
|
|
326
|
my $fileSpec = File::HomeDir->my_home . "/data-hub/structures/any.pm"; |
89
|
8
|
50
|
|
|
|
373
|
if ( -e $fileSpec ) { |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} else { |
93
|
8
|
|
|
|
|
87
|
mkdir($fileDir); |
94
|
8
|
|
|
|
|
4690
|
warn "missing:$fileSpec"; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub getComponents{ |
101
|
0
|
|
|
0
|
0
|
0
|
my $x= {}; |
102
|
0
|
|
|
|
|
0
|
$x->{"all_structures"} = [keys %MICRO]; |
103
|
0
|
|
|
|
|
0
|
$x->{"count_struct"} = sprintf(keys %MICRO); |
104
|
0
|
|
|
|
|
0
|
$x->{"structures"} = {}; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
0
|
foreach my $con (@{$x->{"all_structures"}}){ |
|
0
|
|
|
|
|
0
|
|
107
|
0
|
0
|
|
|
|
0
|
next unless($con!~/any/); |
108
|
0
|
|
|
|
|
0
|
my @in = split("\n",eval{`cat $state->{path}->{"cwd/structures"}/$con.pm`;}); |
|
0
|
|
|
|
|
0
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{name} = |
111
|
0
|
|
|
|
|
0
|
[grep{$_}grep {!/(our|my|use|sub|use|package|#|__|1)/}split("\n",`cat $state->{path}->{"cwd/structures"}/$con.pm`)];#, |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{files} = |
114
|
0
|
|
|
|
|
0
|
[split("\n",`ls -R /home/santex/repos/KnowledgeInterDisciplinary/data/json | egrep -i "($con)";`)]; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
0
|
return $x; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
sub import { |
120
|
8
|
|
|
8
|
|
68
|
my $class = shift; |
121
|
0
|
|
|
|
|
0
|
my @structures = ( grep { $_ eq ':all' } @_ ) |
122
|
8
|
50
|
|
|
|
39
|
? ( 'foo', grep { !/^(?:foo|:all)$/ } keys %MICRO ) # 'foo' is still first |
|
0
|
|
|
|
|
0
|
|
123
|
|
|
|
|
|
|
: @_; |
124
|
8
|
50
|
|
|
|
32
|
$Structure = $structures[0] if @structures; |
125
|
8
|
|
|
|
|
30
|
$micro = AI::MicroStructure->new( $Structure ); |
126
|
|
|
|
|
|
|
# export the microname() function |
127
|
8
|
|
|
8
|
|
46
|
no strict 'refs'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
3619
|
|
128
|
8
|
|
|
|
|
94
|
my $callpkg = caller; |
129
|
8
|
|
|
|
|
25
|
*{"$callpkg\::microname"} = \µname; # standard theme |
|
8
|
|
|
|
|
58
|
|
130
|
|
|
|
|
|
|
# load the classes in @structures |
131
|
8
|
|
|
|
|
5818
|
for my $structure( @structures ) { |
132
|
0
|
|
|
|
|
0
|
eval "require AI::MicroStructure::$structure; import AI::MicroStructure::$structure;"; |
133
|
0
|
0
|
|
|
|
0
|
croak $@ if $@; |
134
|
0
|
|
|
0
|
|
0
|
*{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
sub new { |
138
|
18
|
|
|
18
|
0
|
1202
|
my ( $class, @args ) = ( @_ ); |
139
|
18
|
|
|
|
|
28
|
my $structure; |
140
|
18
|
50
|
|
|
|
73
|
$structure = shift @args if @args % 2; |
141
|
18
|
50
|
|
|
|
51
|
$structure = $Structure unless $structure; # same default everywhere |
142
|
|
|
|
|
|
|
# defer croaking until name() is actually called |
143
|
18
|
|
|
|
|
118
|
bless { structure => $structure, args => { @args }, micro => {} ,state=>$state}, $class; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
sub _rearrange{ |
146
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
147
|
0
|
0
|
|
|
|
0
|
$self->{'payload'} = shift if @_; |
148
|
0
|
|
|
|
|
0
|
return %$self; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
# CLASS METHODS |
151
|
|
|
|
|
|
|
sub add_structure { |
152
|
2
|
|
|
2
|
0
|
643
|
my $class = shift; |
153
|
2
|
|
|
|
|
7
|
my %structures = @_; |
154
|
2
|
|
|
|
|
7
|
for my $structure ( keys %structures ) { |
155
|
2
|
50
|
|
|
|
7
|
croak "The structure $structure already exists!" if exists $MICRO{$structure}; |
156
|
2
|
|
|
|
|
5
|
my @badnames = grep { !/^[a-z_]\w*$/i } @{$structures{$structure}}; |
|
4
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
5
|
|
157
|
2
|
50
|
|
|
|
9
|
croak "Invalid names (@badnames) for structure $structure" |
158
|
|
|
|
|
|
|
if @badnames; |
159
|
2
|
|
|
|
|
7
|
my $code = << "EOC"; |
160
|
|
|
|
|
|
|
package AI::MicroStructure::$structure; |
161
|
|
|
|
|
|
|
use strict; |
162
|
|
|
|
|
|
|
use AI::MicroStructure::List; |
163
|
|
|
|
|
|
|
our \@ISA = qw( AI::MicroStructure::List ); |
164
|
2
|
|
|
|
|
9
|
our \@List = qw( @{$structures{$structure}} ); |
165
|
|
|
|
|
|
|
__PACKAGE__->init(); |
166
|
|
|
|
|
|
|
1; |
167
|
|
|
|
|
|
|
EOC |
168
|
2
|
|
|
1
|
|
152
|
eval $code; |
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
24
|
|
|
1
|
|
|
|
|
623
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
169
|
2
|
|
|
|
|
5
|
$MICRO{$structure} = 1; # loaded |
170
|
|
|
|
|
|
|
# export the microstructure() function |
171
|
8
|
|
|
8
|
|
48
|
no strict 'refs'; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
1149
|
|
172
|
2
|
|
|
|
|
4
|
my $callpkg = caller; |
173
|
2
|
|
|
0
|
|
12
|
*{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) }; |
|
2
|
|
|
|
|
18
|
|
|
0
|
|
|
|
|
0
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
# load the content of __DATA__ into a structure |
177
|
|
|
|
|
|
|
# this class method is used by the other AI::MicroStructure classes |
178
|
|
|
|
|
|
|
sub load_data { |
179
|
4
|
|
|
4
|
0
|
174
|
my ($class, $structure ) = @_; |
180
|
4
|
|
|
|
|
10
|
$data = {}; |
181
|
4
|
|
|
|
|
9
|
my $fh; |
182
|
8
|
|
|
8
|
|
39
|
{ no strict 'refs'; $fh = *{"$structure\::DATA"}{IO}; } |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
11450
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
24
|
|
183
|
4
|
|
|
|
|
8
|
my $item; |
184
|
|
|
|
|
|
|
my @items; |
185
|
4
|
|
|
|
|
12
|
$$item = ""; |
186
|
|
|
|
|
|
|
{ |
187
|
4
|
100
|
|
|
|
4
|
if(defined($fh)){ |
|
4
|
|
|
|
|
19
|
|
188
|
2
|
|
|
|
|
4
|
local $_; |
189
|
2
|
|
|
|
|
30
|
while (<$fh>) { |
190
|
32
|
100
|
|
|
|
117
|
/^#\s*(\w+.*)$/ && do { |
191
|
14
|
|
|
|
|
21
|
push @items, $item; |
192
|
14
|
|
|
|
|
20
|
$item = $data; |
193
|
14
|
|
|
|
|
16
|
my $last; |
194
|
14
|
|
|
|
|
98
|
my @keys = split m!\s+|\s*/\s*!, $1; |
195
|
14
|
|
100
|
|
|
161
|
$last = $item, $item = $item->{$_} ||= {} for @keys; |
196
|
14
|
|
|
|
|
30
|
$item = \( $last->{ $keys[-1] } = "" ); |
197
|
14
|
|
|
|
|
76
|
next; |
198
|
|
|
|
|
|
|
}; |
199
|
18
|
|
|
|
|
87
|
$$item .= $_; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
# clean up the items |
204
|
4
|
|
|
|
|
12
|
for( @items, $item ) { |
205
|
18
|
|
|
|
|
48
|
$$_ =~ s/\A\s*//; |
206
|
18
|
|
|
|
|
73
|
$$_ =~ s/\s*\z//; |
207
|
18
|
|
|
|
|
53
|
$$_ =~ s/\s+/ /g; |
208
|
|
|
|
|
|
|
} |
209
|
4
|
|
|
|
|
58
|
return $data; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
#fitnes |
212
|
|
|
|
|
|
|
sub fitnes { |
213
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
214
|
0
|
|
|
|
|
0
|
return sha1_hex($self->structures()); |
215
|
|
|
|
|
|
|
##my ($config,$structure, $config ) = (shift,[$self->structures()]); FIXME |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
# main function |
218
|
0
|
|
|
0
|
0
|
0
|
sub microname { $micro->name( @_ ) }; |
219
|
|
|
|
|
|
|
sub shitname { |
220
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
221
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
222
|
0
|
0
|
|
|
|
0
|
if (@_) { |
223
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
224
|
0
|
0
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
225
|
|
|
|
|
|
|
if $structure =~ /^(?:0|[1-9]\d*)$/; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
else { |
228
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
229
|
|
|
|
|
|
|
} |
230
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
231
|
0
|
|
|
|
|
0
|
my ( $structure, $category ) = split /\//, $structure, 2; |
232
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
233
|
|
|
|
|
|
|
try{ |
234
|
|
|
|
|
|
|
# `micro new $structure`; |
235
|
0
|
|
|
0
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
236
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
237
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure} = AI::MicroStructure->new($structure,category => $category); |
238
|
0
|
|
|
|
|
0
|
print $self->{micro}{$structure}->name( $count ); |
239
|
0
|
|
|
|
|
0
|
return; |
240
|
|
|
|
0
|
|
|
} catch{ |
241
|
|
|
|
|
|
|
} |
242
|
0
|
|
|
|
|
0
|
} |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
# corresponding method |
246
|
|
|
|
|
|
|
sub name { |
247
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
248
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
249
|
0
|
0
|
|
|
|
0
|
if (@_) { |
250
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
251
|
0
|
0
|
0
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
252
|
|
|
|
|
|
|
if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
else { |
255
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
256
|
|
|
|
|
|
|
} |
257
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
258
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
259
|
0
|
|
|
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
260
|
0
|
0
|
|
|
|
0
|
croak "MicroStructure list $structure does not exist!" if $@; |
261
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
$self->{micro}{$structure} = |
264
|
0
|
|
|
|
|
0
|
"AI::MicroStructure::$structure"->new( %{ $self->{args} } ); |
|
0
|
|
|
|
|
0
|
|
265
|
|
|
|
|
|
|
} |
266
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure}->name( $count ); |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
# corresponding method |
269
|
|
|
|
|
|
|
sub namex { |
270
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
271
|
0
|
|
|
|
|
0
|
my ( $structure, $count ) = ("any",1); |
272
|
0
|
0
|
|
|
|
0
|
if (@_) { |
273
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
274
|
0
|
0
|
0
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
275
|
|
|
|
|
|
|
if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
else { |
278
|
0
|
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, 1 ); |
279
|
|
|
|
|
|
|
} |
280
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
281
|
0
|
0
|
|
|
|
0
|
if( ! $MICRO{$structure} ) { |
282
|
|
|
|
|
|
|
try { |
283
|
0
|
|
|
0
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
284
|
0
|
|
|
|
|
0
|
$MICRO{$structure} = 1; # loaded |
285
|
0
|
0
|
|
|
|
0
|
croak "MicroStructure list $structure does not exist!" if $@; |
286
|
|
|
|
0
|
|
|
}catch{ |
287
|
|
|
|
|
|
|
} |
288
|
0
|
|
|
|
|
0
|
} |
289
|
|
|
|
|
|
|
$self->{micro}{$structure} = |
290
|
0
|
|
|
|
|
0
|
"AI::MicroStructure::$structure"->new( %{ $self->{args} } ); |
|
0
|
|
|
|
|
0
|
|
291
|
|
|
|
|
|
|
} |
292
|
0
|
|
|
|
|
0
|
$self->{micro}{$structure}->name( $count ); |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
# other methods |
295
|
0
|
0
|
|
0
|
0
|
0
|
sub structures { wantarray ? ( sort keys %MICRO ) : scalar keys %MICRO } |
296
|
0
|
0
|
|
0
|
0
|
0
|
sub has_structure { $_[1] ? exists $MICRO{$_[1]} : 0 } |
297
|
0
|
0
|
|
0
|
0
|
0
|
sub configure_driver { $_[1] ? exists $MICRO{$_[1]} : 0 } |
298
|
|
|
|
|
|
|
sub count { |
299
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
300
|
0
|
|
|
|
|
0
|
my ( $structure, $count ); |
301
|
0
|
0
|
|
|
|
0
|
if (@_) { |
302
|
0
|
|
|
|
|
0
|
( $structure, $count ) = @_; |
303
|
0
|
0
|
|
|
|
0
|
( $structure, $count ) = ( $self->{structure}, $structure ) |
304
|
|
|
|
|
|
|
if $structure =~ /^(?:0|[1-9]\d*)$/; |
305
|
|
|
|
|
|
|
} |
306
|
0
|
0
|
|
|
|
0
|
if( ! exists $self->{micro}{$structure} ) { |
307
|
0
|
|
|
|
|
0
|
return scalar ($self->{micro}{$structure}->new); |
308
|
|
|
|
|
|
|
} |
309
|
0
|
|
|
|
|
0
|
return 0; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
sub trim |
312
|
|
|
|
|
|
|
{ |
313
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
314
|
0
|
|
|
|
|
0
|
my $string = shift; |
315
|
0
|
0
|
|
|
|
0
|
$string = "" unless $string; |
316
|
0
|
|
|
|
|
0
|
$string =~ s/^\s+//; |
317
|
0
|
|
|
|
|
0
|
$string =~ s/\s+$//; |
318
|
0
|
|
|
|
|
0
|
$string =~ s/\t//; |
319
|
0
|
|
|
|
|
0
|
$string =~ s/^\s//; |
320
|
0
|
|
|
|
|
0
|
return $string; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
sub getBundle { |
323
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
324
|
0
|
|
|
|
|
0
|
my @structures = grep { !/^(?:any)/ } AI::MicroStructure->structures; |
|
0
|
|
|
|
|
0
|
|
325
|
0
|
|
|
|
|
0
|
my @micros; |
326
|
0
|
|
|
|
|
0
|
my @search=[]; |
327
|
0
|
|
|
|
|
0
|
for my $structure (@structures) { |
328
|
8
|
|
|
8
|
|
44
|
no strict 'refs'; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
18050
|
|
329
|
0
|
|
|
|
|
0
|
eval "require '$absstructdir/$structure.pm';"; |
330
|
0
|
|
|
|
|
0
|
my %isa = map { $_ => 1 } @{"AI::MicroStructure::$structure\::ISA"}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
331
|
0
|
0
|
|
|
|
0
|
if( exists $isa{'AI::MicroStructure::Locale'} ) { |
|
|
0
|
|
|
|
|
|
332
|
0
|
|
|
|
|
0
|
for my $lang ( "AI::MicroStructure::$structure"->languages() ) { |
333
|
0
|
|
|
|
|
0
|
push @micros, |
334
|
|
|
|
|
|
|
["AI::MicroStructure::$structure"->new( lang => $lang ),$lang]; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
elsif( exists $isa{'AI::MicroStructure::MultiList'} ) { |
338
|
0
|
|
|
|
|
0
|
for my $cat ( "AI::MicroStructure::$structure"->categories(), ':all' ) { |
339
|
0
|
|
|
|
|
0
|
push @micros, |
340
|
|
|
|
|
|
|
[ "AI::MicroStructure::$structure"->new( category => $cat ),$cat]; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
else { |
344
|
0
|
|
|
|
|
0
|
push @micros, ["AI::MicroStructure::$structure"->new(),'']; |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
} |
347
|
0
|
|
|
|
|
0
|
my $all ={}; |
348
|
0
|
|
|
|
|
0
|
for my $test (@micros) { |
349
|
0
|
|
|
|
|
0
|
my $micro = $test->[0]; |
350
|
0
|
|
|
|
|
0
|
my %items; |
351
|
0
|
|
|
|
|
0
|
my $items = $micro->name(0); |
352
|
0
|
|
|
|
|
0
|
$items{$_}++ for $micro->name(0); |
353
|
0
|
|
|
|
|
0
|
my $key=sprintf("%s",$micro->structure); |
354
|
0
|
|
|
|
|
0
|
$all->{$key}=[$test->[1],$micro->name($items)]; |
355
|
|
|
|
|
|
|
} |
356
|
0
|
|
|
|
|
0
|
return $all; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
sub save_cat { |
359
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
360
|
0
|
|
|
|
|
0
|
my $data = shift; |
361
|
0
|
|
|
|
|
0
|
my $dat; |
362
|
0
|
|
|
|
|
0
|
my $ret = ""; |
363
|
0
|
|
|
|
|
0
|
foreach my $key(sort keys %{$data} ) { |
|
0
|
|
|
|
|
0
|
|
364
|
0
|
0
|
|
|
|
0
|
next unless($_); |
365
|
|
|
|
|
|
|
#ref $hash->{$_} eq "HASH" |
366
|
0
|
0
|
|
|
|
0
|
if(ref $data->{$key} eq "HASH"){ |
367
|
0
|
|
|
|
|
0
|
$ret .= "\n".$self->save_cat($data->{$key}); |
368
|
|
|
|
|
|
|
}else{ |
369
|
0
|
|
|
|
|
0
|
$dat = $data->{$key}; |
370
|
0
|
|
|
|
|
0
|
$dat =~ s/^|,/\n/g; |
371
|
0
|
|
|
|
|
0
|
$dat =~ s/\n\n/\n/g; |
372
|
0
|
|
|
|
|
0
|
$dat =~ s/->\n|[0-9]\n//g; |
373
|
0
|
0
|
|
|
|
0
|
$ret .= "# ".($key=~/names|default|[a-z]/?$key:"names ".$key); |
374
|
0
|
|
|
|
|
0
|
$ret .= "\n ".$dat."\n"; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
} |
377
|
0
|
|
|
|
|
0
|
return $ret; |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
sub save_default { |
380
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
381
|
0
|
|
|
|
|
0
|
my $data = shift; |
382
|
0
|
|
|
|
|
0
|
my $line = shift; |
383
|
0
|
|
|
|
|
0
|
my $dat = {}; |
384
|
0
|
|
|
|
|
0
|
my @in = (); |
385
|
0
|
|
|
|
|
0
|
my $active=0; |
386
|
0
|
0
|
|
|
|
0
|
$line = $Structure unless($line); |
387
|
0
|
|
|
|
|
0
|
foreach(@{$data->{rows}->{"coordinate"}}){ |
|
0
|
|
|
|
|
0
|
|
388
|
0
|
0
|
|
|
|
0
|
if($_ eq $line){ $active=1; } |
|
0
|
|
|
|
|
0
|
|
389
|
0
|
0
|
|
|
|
0
|
if(1+$line eq $_){ $active=0; } |
|
0
|
|
|
|
|
0
|
|
390
|
0
|
0
|
|
|
|
0
|
if($active==1){ |
391
|
0
|
|
|
|
|
0
|
$_=~s/,//g; |
392
|
0
|
|
|
|
|
0
|
$_ = $self->trim($_); |
393
|
0
|
0
|
|
|
|
0
|
$dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
} |
396
|
0
|
|
|
|
|
0
|
foreach(@{$data->{rows}->{"search"}}){ |
|
0
|
|
|
|
|
0
|
|
397
|
0
|
0
|
|
|
|
0
|
if($_ eq $line){ $active=1; } |
|
0
|
|
|
|
|
0
|
|
398
|
0
|
0
|
|
|
|
0
|
if(1+$line eq $_){ $active=0; } |
|
0
|
|
|
|
|
0
|
|
399
|
0
|
0
|
|
|
|
0
|
if($active==1){ |
400
|
0
|
|
|
|
|
0
|
$_=~s/,//g; |
401
|
0
|
|
|
|
|
0
|
$_ = $self->trim($_); |
402
|
0
|
0
|
|
|
|
0
|
$dat->{names}->{$_}=$_ unless(defined($dat->{names}->{$_})); |
403
|
|
|
|
|
|
|
} |
404
|
|
|
|
|
|
|
} |
405
|
0
|
|
|
|
|
0
|
push @in , keys %{$dat->{names}}; |
|
0
|
|
|
|
|
0
|
|
406
|
0
|
|
|
|
|
0
|
push @in , values %{$data->{names}}; |
|
0
|
|
|
|
|
0
|
|
407
|
0
|
|
|
|
|
0
|
$dat->{names} = join(" ",@in); |
408
|
0
|
|
|
|
|
0
|
$dat->{names} =~ s/$line(.*?)\-\>(.*?) [1-9] /$1 $2/g; |
409
|
0
|
|
|
|
|
0
|
$dat->{names} =~ s/ / /g; |
410
|
0
|
|
|
|
|
0
|
my @file = grep{/$Structure/}map{File::Glob::bsd_glob( |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
411
|
|
|
|
|
|
|
File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; |
412
|
0
|
0
|
|
|
|
0
|
if(@file){ |
413
|
0
|
0
|
|
|
|
0
|
open(SELF,"+<$file[0]") || die $!; |
414
|
0
|
0
|
|
|
|
0
|
while(<SELF>){last if /^__DATA__/} |
|
0
|
|
|
|
|
0
|
|
415
|
0
|
|
|
|
|
0
|
truncate(SELF,tell SELF); |
416
|
0
|
|
|
|
|
0
|
print SELF $self->save_cat($dat); |
417
|
0
|
|
|
|
|
0
|
truncate(SELF,tell SELF); |
418
|
0
|
|
|
|
|
0
|
close SELF; |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
sub openData{ |
422
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
423
|
0
|
|
|
|
|
0
|
my @datax = (); |
424
|
0
|
0
|
|
|
|
0
|
if(<DATA>){ |
425
|
0
|
|
|
|
|
0
|
@datax = <DATA>; |
426
|
0
|
|
|
|
|
0
|
while(@datax){ |
427
|
0
|
|
|
|
|
0
|
chomp; |
428
|
0
|
0
|
|
|
|
0
|
if($_=~/^#\s*(\w+.*)$/) { |
429
|
0
|
|
|
|
|
0
|
@a=split(" ",$1); |
430
|
0
|
0
|
|
|
|
0
|
if($#a){ |
431
|
0
|
|
|
|
|
0
|
$data->{$a[0]}->{$a[1]}=""; |
432
|
|
|
|
|
|
|
}else{ |
433
|
0
|
|
|
|
|
0
|
$data->{$1}=""; |
434
|
|
|
|
|
|
|
} |
435
|
0
|
0
|
|
|
|
0
|
$item=$1 unless($#a); |
436
|
|
|
|
|
|
|
}else{ |
437
|
0
|
|
|
|
|
0
|
my @keys = split m!\s+|\s*/\s*!,$_; |
438
|
0
|
|
|
|
|
0
|
foreach(sort @keys){ |
439
|
0
|
0
|
|
|
|
0
|
if($#a){ |
440
|
0
|
0
|
|
|
|
0
|
$data->{$a[0]}->{$a[1]} .= " $_" unless($_ eq ""); |
441
|
|
|
|
|
|
|
}else{ |
442
|
0
|
0
|
|
|
|
0
|
$data->{$item} .= " $_" unless($_ eq ""); |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
}; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
} |
448
|
0
|
|
|
|
|
0
|
return $data; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
sub getBlank { |
451
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
452
|
0
|
|
|
|
|
0
|
my $structure = shift; |
453
|
0
|
|
|
|
|
0
|
my $data = shift; |
454
|
0
|
|
|
|
|
0
|
my $usage = ""; |
455
|
0
|
|
|
|
|
0
|
$usage = "#!/usr/bin/perl -W\n"; |
456
|
0
|
|
|
|
|
0
|
$usage .= << "EOC"; |
457
|
|
|
|
|
|
|
package AI::MicroStructure::$structure; |
458
|
|
|
|
|
|
|
use strict; |
459
|
|
|
|
|
|
|
use AI::MicroStructure::List; |
460
|
|
|
|
|
|
|
our \@ISA = qw( AI::MicroStructure::List ); |
461
|
|
|
|
|
|
|
our \@List = qw( \@{\$structures{\$structure}} ); |
462
|
|
|
|
|
|
|
__PACKAGE__->init(); |
463
|
|
|
|
|
|
|
1; |
464
|
|
|
|
|
|
|
EOC |
465
|
0
|
|
|
|
|
0
|
my $new = {}; |
466
|
0
|
|
|
|
|
0
|
foreach my $k |
467
|
0
|
|
|
|
|
0
|
(grep{!/^[0-9]/}map{$_=$self->trim($_)}@{$data->{rows}->{"search"}}){ |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
468
|
0
|
|
|
|
|
0
|
$k =~ s/[ ]/_/g; |
469
|
0
|
|
|
|
|
0
|
$k =~ s/[\(]|[\)]//g; |
470
|
0
|
0
|
|
|
|
0
|
next if($k=~/synonyms|hypernyms/); |
471
|
0
|
|
|
|
|
0
|
print $k; |
472
|
0
|
|
|
|
|
0
|
$new->{$k}=[map{$_=[map{$_=$self->trim($_)}split("\n|, ",$_)]} |
|
0
|
|
|
|
|
0
|
|
473
|
0
|
|
|
|
|
0
|
grep{!/synonyms|hypernyms/}split("sense~~~~~~~~~", |
|
0
|
|
|
|
|
0
|
|
474
|
|
|
|
|
|
|
lc `micro-wnet $k`)]; |
475
|
0
|
0
|
|
|
|
0
|
next unless(@{$new->{$k}}); |
|
0
|
|
|
|
|
0
|
|
476
|
|
|
|
|
|
|
# $new->{$k}=~s/Sense*\n(.*?)\n\n/$1/g; |
477
|
|
|
|
|
|
|
# @{$new->{$k}} = [split("\n|,",$new->{$k})]; |
478
|
0
|
|
|
|
|
0
|
$data->{rows}->{"ident"}->{md5_base64($new->{$k})} = $new->{$k}; |
479
|
|
|
|
|
|
|
} |
480
|
0
|
|
|
|
|
0
|
my $list = join("\n",sort keys %$new); |
481
|
|
|
|
|
|
|
# $list =~ s/_//g; |
482
|
0
|
|
|
|
|
0
|
$usage .= " |
483
|
|
|
|
|
|
|
__DATA__ |
484
|
|
|
|
|
|
|
# names |
485
|
|
|
|
|
|
|
".$list; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
sub save_new { |
488
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
489
|
0
|
|
|
|
|
0
|
my $StructureName = shift; |
490
|
0
|
|
|
|
|
0
|
my $data = shift; |
491
|
0
|
0
|
|
|
|
0
|
if($StructureName){ |
492
|
|
|
|
|
|
|
#$StructureName = lc $self->trim(`micro`) unless($StructureName); |
493
|
0
|
|
|
|
|
0
|
my $file = "$absstructdir/$StructureName.pm"; |
494
|
0
|
0
|
|
|
|
0
|
print `mkdir -p $absstructdir` unless(-d $absstructdir); |
495
|
0
|
|
|
|
|
0
|
my $fh; |
496
|
0
|
0
|
|
|
|
0
|
open($fh,">$file") || warn @{[$file,$!]}; |
|
0
|
|
|
|
|
0
|
|
497
|
0
|
|
|
|
|
0
|
print $fh $self->getBlank($StructureName,$data); |
498
|
0
|
|
|
|
|
0
|
close $fh; |
499
|
0
|
|
|
|
|
0
|
$Structure = $StructureName; |
500
|
0
|
|
|
|
|
0
|
push @CWD,$file; |
501
|
0
|
|
|
|
|
0
|
return 1; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
sub drop { |
505
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
506
|
0
|
|
|
|
|
0
|
my $StructureName = shift; |
507
|
0
|
|
|
|
|
0
|
my @file = grep{/$StructureName.pm/}map{File::Glob::bsd_glob( |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
508
|
|
|
|
|
|
|
File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD; |
509
|
0
|
|
|
|
|
0
|
my $fh = shift @file; |
510
|
0
|
0
|
|
|
|
0
|
if(`ls $fh`) |
511
|
|
|
|
|
|
|
{ |
512
|
0
|
|
|
|
|
0
|
print `rm $fh`; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
#push @CWD,$file[1]; |
515
|
0
|
|
|
|
|
0
|
return 1; |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
0
|
0
|
|
sub help{ |
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
END{ |
520
|
8
|
50
|
|
8
|
|
4591
|
if($init){} |
521
|
8
|
50
|
|
|
|
47
|
if($available){} |
522
|
8
|
50
|
|
|
|
32
|
if($lib){} |
523
|
8
|
50
|
|
|
|
31
|
if($list){ |
524
|
0
|
|
|
|
|
0
|
p @{[__PACKAGE__->getComponents]}; |
|
0
|
|
|
|
|
0
|
|
525
|
|
|
|
|
|
|
} |
526
|
8
|
50
|
|
|
|
28
|
if($use){} |
527
|
8
|
50
|
|
|
|
26
|
if($off){} |
528
|
8
|
50
|
|
|
|
32
|
if($switch){} |
529
|
8
|
50
|
|
|
|
26
|
if($mirror){} |
530
|
8
|
50
|
|
|
|
30
|
if($version){ |
531
|
0
|
|
|
|
|
0
|
printf($VERSION); |
532
|
0
|
|
|
|
|
0
|
exit(0); |
533
|
|
|
|
|
|
|
} |
534
|
8
|
50
|
|
|
|
29
|
if($help) { |
535
|
0
|
|
|
|
|
0
|
printf(__PACKAGE__->help()); |
536
|
0
|
|
|
|
|
0
|
exit(0); |
537
|
|
|
|
|
|
|
} |
538
|
8
|
50
|
|
|
|
32
|
if($drop == 1) { |
539
|
0
|
|
|
|
|
0
|
__PACKAGE__->drop($StructureName); |
540
|
0
|
|
|
|
|
0
|
exit 0; |
541
|
|
|
|
|
|
|
} |
542
|
8
|
50
|
|
|
|
29
|
if($new==1){ |
543
|
8
|
|
|
8
|
|
7261
|
use Term::ReadKey; |
|
8
|
|
|
|
|
63252
|
|
|
8
|
|
|
|
|
692
|
|
544
|
8
|
|
|
8
|
|
8264
|
use JSON; |
|
8
|
|
|
|
|
128477
|
|
|
8
|
|
|
|
|
49
|
|
545
|
0
|
|
|
|
|
0
|
my $data = decode_json(lc`micro-sense $StructureName words`); |
546
|
0
|
|
|
|
|
0
|
my $char; |
547
|
|
|
|
|
|
|
my $line; |
548
|
0
|
|
|
|
|
0
|
my $senses=@{$data->{"senses"}}; |
|
0
|
|
|
|
|
0
|
|
549
|
0
|
0
|
|
|
|
0
|
$senses= 0 unless($senses); |
550
|
0
|
0
|
|
|
|
0
|
if(!$verbose){ |
551
|
0
|
|
|
|
|
0
|
printf("\n |
552
|
|
|
|
|
|
|
\033[0;34m |
553
|
|
|
|
|
|
|
%s |
554
|
|
|
|
|
|
|
Type: the number you choose 1..$senses |
555
|
|
|
|
|
|
|
\033[0m",__PACKAGE__->usage($StructureName,$senses,$data)); |
556
|
|
|
|
|
|
|
} |
557
|
0
|
0
|
|
|
|
0
|
$line = 1 unless($senses != 1); |
558
|
0
|
0
|
|
|
|
0
|
if($verbose){ |
559
|
0
|
|
|
|
|
0
|
$line=1; |
560
|
|
|
|
|
|
|
} |
561
|
0
|
0
|
|
|
|
0
|
chomp($line = <STDIN>) unless($line); |
562
|
0
|
|
|
|
|
0
|
my $d = join("#",@{$data->{rows}->{search}}); |
|
0
|
|
|
|
|
0
|
|
563
|
0
|
|
|
|
|
0
|
my @d = grep{/^$line#/}split("sense~~~~~~~~~",$d); |
|
0
|
|
|
|
|
0
|
|
564
|
0
|
|
|
|
|
0
|
@{$data->{rows}->{"search"}}=split("#",join("",@d)); |
|
0
|
|
|
|
|
0
|
|
565
|
0
|
0
|
|
|
|
0
|
if($line>0){ |
566
|
0
|
|
|
|
|
0
|
__PACKAGE__->save_new($StructureName,$data,$line); |
567
|
0
|
|
|
|
|
0
|
exit 0; |
568
|
|
|
|
|
|
|
}else{ |
569
|
0
|
|
|
|
|
0
|
printf "your logic is today impaired !!!\n"; |
570
|
0
|
|
|
|
|
0
|
exit 0; |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
} |
573
|
8
|
50
|
|
|
|
71
|
if($write == 1) { |
574
|
0
|
|
|
|
|
0
|
__PACKAGE__->save_default(); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
sub usage { |
578
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
579
|
0
|
|
|
|
|
0
|
my $search = shift; |
580
|
0
|
|
|
|
|
0
|
my $senseNr = shift; |
581
|
0
|
|
|
|
|
0
|
my $data = shift; |
582
|
0
|
|
|
|
|
0
|
my $usage = << 'EOT'; |
583
|
|
|
|
|
|
|
.--'"""""--.>_ |
584
|
|
|
|
|
|
|
.-' o\\b.\o._o.`-. |
585
|
|
|
|
|
|
|
.-'.- ) \d888888888888b. |
586
|
|
|
|
|
|
|
/.' b Y8888888888888888b. |
587
|
|
|
|
|
|
|
.-'. 8888888888888888888888888b |
588
|
|
|
|
|
|
|
/ o888 Y Y8888888888888888888888b |
589
|
|
|
|
|
|
|
/ d888P/ /| Y"Y8888888888888888888b |
590
|
|
|
|
|
|
|
J d8888/| Y .o._. "Y8888888888888Y" \ |
591
|
|
|
|
|
|
|
|d Y888b|obd88888bo. """Y88888Y' .od8 |
592
|
|
|
|
|
|
|
Fdd 8888888888888888888bo._'|| d88888| |
593
|
|
|
|
|
|
|
Fd d 88\ Y8888Y "Y888888888b, d888888P |
594
|
|
|
|
|
|
|
d-b 8888b Y88P' """""Y888b8888P"| |
595
|
|
|
|
|
|
|
J 8\88888888P `m. """"" | |
596
|
|
|
|
|
|
|
|| `8888888P' "Ymm._ _J |
597
|
|
|
|
|
|
|
|\\ Y8888P ' .mmm.YM) .mMF"' |
598
|
|
|
|
|
|
|
| \\ Y888J ' < (@)>.- ` /MFm. | |
599
|
|
|
|
|
|
|
J \ `YY ""' :: MM @)>F |
600
|
|
|
|
|
|
|
L /) 88 : | ""\| |
601
|
|
|
|
|
|
|
| ( ( Yb . ' . | L |
602
|
|
|
|
|
|
|
\ bo 8b . . J | <0>_ |
603
|
|
|
|
|
|
|
\ "' . . . . L F <1>_ |
604
|
|
|
|
|
|
|
o._.:. . . \mm,__J/ / <2>_ |
605
|
|
|
|
|
|
|
Y8::'|. / `Y8P J <3>_ |
606
|
|
|
|
|
|
|
`|' J: . . ' . . | F <4>_ |
607
|
|
|
|
|
|
|
| L ' . _: | <5>_ |
608
|
|
|
|
|
|
|
| `: . .:oood8bdb. | 1>_ |
609
|
|
|
|
|
|
|
F `:. "-._ `" F 2>_ |
610
|
|
|
|
|
|
|
/ `::. """' / 3>_ |
611
|
|
|
|
|
|
|
/ `::. "" / 4>_ |
612
|
|
|
|
|
|
|
_.-d( `:::. F 5>_ |
613
|
|
|
|
|
|
|
-888b. `::::. . J 6>_ |
614
|
|
|
|
|
|
|
Y888888b. `::::::::::' 7>_ |
615
|
|
|
|
|
|
|
Y88888888bo. `::::::d 8>_ |
616
|
|
|
|
|
|
|
`"Y8888888888boo.._ `"dd88b. 9>_ |
617
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""" |
618
|
|
|
|
|
|
|
EOT |
619
|
0
|
|
|
|
|
0
|
$usage =~ s/<0>_/\033[0;32mThe word $search\033[255;34m/g; |
620
|
0
|
|
|
|
|
0
|
$usage =~ s/<1>_/\033[0;32mhas $senseNr concept's\033[255;34m/g; |
621
|
0
|
|
|
|
|
0
|
$usage =~ s/<2>_/\033[0;32mwe need to find out the which one\033[255;34m/g; |
622
|
0
|
|
|
|
|
0
|
$usage =~ s/<3>_/\033[0;32mto use for our new,\033[255;34m/g; |
623
|
0
|
|
|
|
|
0
|
$usage =~ s/<4>_/\033[0;32mmicro-structure,\033[255;34m/g; |
624
|
0
|
|
|
|
|
0
|
$usage =~ s/<5>_//g; |
625
|
0
|
|
|
|
|
0
|
my @row = (); |
626
|
0
|
|
|
|
|
0
|
my $ii=0; |
627
|
0
|
|
|
|
|
0
|
foreach my $sensnrx (sort keys %{$data->{"rows"}->{"senses"}}) |
|
0
|
|
|
|
|
0
|
|
628
|
|
|
|
|
|
|
{ |
629
|
0
|
|
|
|
|
0
|
my $row = $data->{"rows"}->{"senses"}->{$sensnrx}; |
630
|
0
|
|
|
|
|
0
|
my $txt=""; |
631
|
0
|
|
|
|
|
0
|
foreach(@{$row->{"basics"}}[1..2]){ |
|
0
|
|
|
|
|
0
|
|
632
|
0
|
0
|
|
|
|
0
|
next unless($_); |
633
|
0
|
|
|
|
|
0
|
$txt .= sprintf("\033[0;31m %s\033[255;34m",$_); |
634
|
|
|
|
|
|
|
} |
635
|
0
|
|
|
|
|
0
|
$txt .= sprintf("",$_); |
636
|
0
|
|
|
|
|
0
|
$usage =~ s/$sensnrx>_/($sensnrx):$txt/g; |
637
|
0
|
0
|
|
|
|
0
|
if($sensnrx>9){ |
638
|
0
|
|
|
|
|
0
|
$usage .= sprintf("\n(%d):%s",$sensnrx,$txt); |
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
} |
641
|
0
|
|
|
|
|
0
|
foreach my $ii (0..16){ |
642
|
0
|
|
|
|
|
0
|
$usage =~ s/$ii>_//g; |
643
|
|
|
|
|
|
|
} |
644
|
0
|
|
|
|
|
0
|
return $usage; |
645
|
|
|
|
|
|
|
} |
646
|
|
|
|
|
|
|
1; |
647
|
|
|
|
|
|
|
__END__ |
648
|
|
|
|
|
|
|
#print Dumper $micro; |
649
|
|
|
|
|
|
|
# ABSTRACT: AI::MicroStructure Creates Concepts for words |
650
|
|
|
|
|
|
|
=head1 NAME |
651
|
|
|
|
|
|
|
AI::MicroStructure |
652
|
|
|
|
|
|
|
=head1 DESCRIPTION |
653
|
|
|
|
|
|
|
Creates Concepts for words |
654
|
|
|
|
|
|
|
=head1 SYNOPSIS |
655
|
|
|
|
|
|
|
~$ micro new world |
656
|
|
|
|
|
|
|
~$ micro structures |
657
|
|
|
|
|
|
|
~$ micro any 2 |
658
|
|
|
|
|
|
|
~$ micro drop world |
659
|
|
|
|
|
|
|
~$ micro |
660
|
|
|
|
|
|
|
=head1 AUTHOR |
661
|
|
|
|
|
|
|
Hagen Geissler <santex@cpan.org> |
662
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
663
|
|
|
|
|
|
|
Hagen Geissler <santex@cpan.org> |
664
|
|
|
|
|
|
|
=head1 SUPPORT AND DOCUMENTATION |
665
|
|
|
|
|
|
|
[sample using concepts](http://active-memory.de:2323/nerd?param=perl#ajax/home) |
666
|
|
|
|
|
|
|
[PDF info on my works](https://github.com/santex/AI-MicroStructure) |
667
|
|
|
|
|
|
|
=head1 SEE ALSO |
668
|
|
|
|
|
|
|
AI-MicroStructure |
669
|
|
|
|
|
|
|
=cut |
670
|
|
|
|
|
|
|
__DATA__ |