The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

TM::Analysis - Topic Maps, analysis functions

SYNOPSIS

  use TM::Materialized::AsTMa;
  my $tm = new TM::Materialized::AsTMa (file => 'test.atm');
  $tm->sync_in;

  Class::Trait->apply ($tm, 'TM::Analysis');

  print Dumper $tm->clusters;

  print Dumper $tm->statistics;

DESCRIPTION

This package contains some topic map analysis functionality.

INTERFACE

clusters

$hashref = clusters ($tm)

computes the islands of topics. It figures out which topics are connected via associations and - in case they are - will collate them into clusters. The result is a hash reference to a hash containing list references of topic ids organized in a cluster.

In default mode, this function only regards topics to be in the same cluster if topics play roles in one and the same maplet. The role topics themselves or the type or the scope are ignored.

You can change this behaviour by passing in options like

  use_scope => 1

  use_roles => 1

  use_type  => 1

Obviously, with use_scope => 1 you will let a lot of topics collapse into one cluster as most maplets usually are in the unconstrained scope.

NOTE: This is yet a somewhat expensive operation.

statistics

This (currently quite limited) function computes a reference to hash containing the following fields:

nr_midlets

Nr of midlets in the map. This includes ALL midlets for topics and also those for assertions.

nr_maplets

Nr of assertions in the map.

nr_clusters

Nr of clusters according to the cluster function elsewhere in this document.

orphanage

This computes all topics which have either no supertype and also those which have no type. Without further parameters, it returns a hash reference with the following fields:

untyped

Holds a list reference to all topic ids which have no type.

empty

Holds a list reference to all topic ids which have no instance.

unclassified

Holds a list reference to all topic ids which have no superclass.

unspecified

Holds a list reference to all topic ids which have no subclass.

Optionally, a list of the identifiers above can be passed in so that only that particular information is actually returned (some speedup):

   my $o = TM::Analysis::orphanage ($tm, 'untyped');

SEE ALSO

TM

COPYRIGHT AND LICENSE

Copyright 200[3-6] by Robert Barta, <drrho@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.