| 1 | #!/usr/bin/perl | ||
| 2 | package AI::MicroStructure::Tree; # or whatever you're doing | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use Class::Container; | ||
| 6 | use base qw(Tree::DAG_Node); | ||
| 7 | use Params::Validate qw(:types); | ||
| 8 | use Data::Dumper; | ||
| 9 | use AI::MicroStructure::Collection; | ||
| 10 | use AI::MicroStructure; | ||
| 11 | exit(0) unless(@ARGV); | ||
| 12 | my @themes = grep { !/^(?:any)/ } AI::MicroStructure->structures; | ||
| 13 | |||
| 14 | my $root = Tree::DAG_Node->new(); | ||
| 15 | $root->name("micro"); | ||
| 16 | |||
| 17 | my $set = {}; | ||
| 18 | |||
| 19 | foreach my $f (split( "\n",`micrownet $ARGV[0]`)){ | ||
| 20 | my @atr = split( "\n",`micrownet $f`); | ||
| 21 | $set->{$f} = $root->new_daughter(); | ||
| 22 | $set->{$f}->attributes->{name} = $f; | ||
| 23 | |||
| 24 | my $x=0; | ||
| 25 | foreach my $ar (@atr){ | ||
| 26 | next if ($ar=~/'/); | ||
| 27 | |||
| 28 | $ar=~s/ /_/g; | ||
| 29 | my @aatr = split( "\n",`micrownet $ar`); | ||
| 30 | |||
| 31 | |||
| 32 | next unless($#aatr>1); | ||
| 33 | if(!$set->{$f}->{$ar}){ | ||
| 34 | $set->{$f}->{$ar} = $set->{$f}->new_daughter(); | ||
| 35 | |||
| 36 | $set->{$f}->{$ar}->attributes->{count} = $#aatr; | ||
| 37 | # $set->{$f}->{$ar}->attributes->{elements} = join("#",@aatr); | ||
| 38 | $set->{$f}->{$ar}->attributes->{name} = $ar; | ||
| 39 | }else{ | ||
| 40 | $set->{$f}->{$ar}->attributes->{fuse} = $x++; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | } | ||
| 45 | print map("$_\n", @{$root->tree2string}); | ||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | 1; |