File: Summary.pm

package info (click to toggle)
libtm-perl 1.53-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,780 kB
  • ctags: 594
  • sloc: perl: 34,611; sh: 377; makefile: 50
file content (39 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package TM::Serializable::Summary;

use Class::Trait 'base';
use Class::Trait 'TM::Serializable';

use Data::Dumper;
use TM::Analysis;
use TM::PSI;

use TM::Index::Match;

sub serialize {
    my $self = shift;

    my $idx  = new TM::Index::Match ($self);

    my $info = TM::Analysis::statistics ($self, 'nr_toplets', 'nr_asserts');
    $info->{sub_topicmaps} = [ $self->instances ($self->tids (\ TM::PSI->TOPICMAP ))];
    $info->{untyped}       = TM::Analysis::orphanage ($self, 'untyped')->{untyped};

#    warn "info ".Dumper $info;

    my @infra = keys %{$TM::infrastructure->{mid2iid}};
    my %infra;
    @infra{ @infra } = (1) x @infra;

    $info->{non_infra_untyped} = {
                                   map { $_ => scalar $self->instancesT ($_) }
                                   grep (!$infra{$_}, @{ $info->{untyped} } )
                                   };
    delete $info->{untyped};                              # maybe show this later
    return Data::Dumper->Dump ([ $info ], ['summary' ]);
}

sub deserialize {
    die "cannot be done, entropy is not our friend here, this is just a placeholder";
}

1;