This file is indexed.

/usr/share/perl5/TM/Tau/Filter/Analyze.pm is in libtm-perl 1.56-7.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package TM::Tau::Filter::Analyze;

# register
$TM::Tau::filters{'http://psi.tm.bond.edu.au/queries/1.0/analyze'} = scalar __PACKAGE__;

use TM;

use TM::Tau::Filter;
use base qw(TM::Tau::Filter);

use Data::Dumper;

=pod

=head1 NAME

TM::Tau::Filter::Analyze - Topic Maps, Analysis Filter

=head1 SYNOPSIS

   # get a map
   my $tm = ... some map (or another filter)
   # build a filter expression
   my $an = new TM::Tau::Filter::Analyze (left => $tm);

   # this will calculate a map which carries the analysis result
   $an->sync_in; 

   # print all metrics, the values are occurrences
   warn $an->instances ($an->mids ('metric));

=head1 DESCRIPTION

This package implements an analysis filter. See L<TM::Tau::Filter> how
to use filters.

=head2 Ontology

The underlying ontology will develop. You can bootstrap yourself by
looking for C<metric> in the map. All instances have occurrences with
(integer) values.

B<NOTE>: This may change.

=cut

sub transform {
    my $self    = shift;
    my $map     = shift;
    my $baseuri = shift;

    use TM::Analysis;
    my $analysis = TM::Analysis::statistics ($map);
#warn Dumper $analysis;
    my $tm = new TM (baseuri => $baseuri);
    $tm->assert (
		 map { Assertion->new (type => 'isa',        roles => [ 'class', 'instance' ], players => [ 'metric', $_ ]),
		       Assertion->new (type => 'occurrence', roles => [ 'value', 'thing' ],    players => [ new TM::Literal ($analysis->{$_}) , $_ ]) }
                 keys %$analysis                                      # create topics for all of this
		 );
    return $tm;
}

=pod

=head1 SEE ALSO

L<TM::Tau::Filter>

=head1 AUTHOR INFORMATION

Copyright 200[5-6], Robert Barta <drrho@cpan.org>, All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
http://www.perl.com/perl/misc/Artistic.html

=cut

our $VERSION = 0.2;
our $REVISION = '$Id: Analyze.pm,v 1.4 2006/11/26 22:01:32 rho Exp $';

1;


__END__

metric

nr_....

docs

sub new {
    my $class = shift;
    return bless {@_}, $class;
}

sub sync_in {
    my $self = shift;

    die __PACKAGE__ . ": operand for filter is missing" unless $self->{operand};
#warn __PACKAGE__ . ": triggering operand syncin";
    $self->{operand}->sync_in;

    # applying the operator on the store
    #
    $self->{result} = { 
	measure => {
	    nr_topics => 23,
	    nr_assertions => 42 
	    }
    };
}

sub store {
    my $self = shift;

#warn "ANALYZE store";
    my $ms = new TM::Store (psis => $TM::PSI::topicmaps); # BaseURI?
    # create topics for all of this
    foreach my $k (keys %{$self->{result}}) {
	foreach my $v (keys %{$self->{result}->{$k}}) {
	    $ms->assert ([undef, undef, 'isa',                 TM::Store->ASSOC,    [ 'class', 'instance' ],            [ $k, $v ] ]);
	    $ms->assert ([undef, undef, 'has-basename',        TM::Store->BASENAME, [ 'basename', 'thing' ],            [ \ 'AAA', $v ] ]);
	    $ms->assert ([undef, undef, 'has-data-occurrence', TM::Store->OCCDATA,  [ 'has-data-occurrence', 'thing' ], [ \ "$self->{result}->{$k}->{$v}" , $v ] ]);
	}
    }
#warn "ANALYZE store ". Dumper $ms;
    return $ms;
}

sub sync_out {
    my $self = shift;

#warn __PACKAGE__ . ": syncing out analyze";
    if ($self->{url} eq 'io:stdout') {
	use Data::Dumper;
	use TM::Utils;
	TM::Utils::put_content ($self->{url}, Dumper $self->{result});
    } elsif ($self->{url} eq 'io:stdin') {
	# nothing
    } elsif ($self->{url} eq 'null:') {
	# nothing
    } else {
	use TM::Utils;
	TM::Utils::put_content ($self->{url}, TM::Utils::xmlify_hash ($self->{result}));
    }
}

sub DESTROY {
    my $self = shift;
#warn __PACKAGE__ . ": DESTROY";
    $self->sync_out;
}


__END__

__DATA__

# Ontology

nr_toplets (measure)
bn: Nr of toplets
in: <some value>

nr_maplets (measure)
bn: Nr of maplets

nr_types (measure)

nr_assoc_types (measure)

nr_basename_types (measure)

nr_occdata_types (measure)

nr_occref_types (measure)

nr_scopes (measure)

map_size (measure)
in: <some value> in bytes