Perl TM Tutorial: Pah, Merging (Part VI)

(Followup to part V)

What I resent about some TM introductions is that they depict merging semantics as if it had anything to do with two or more maps being combined.

Well, it hasn't.

Anyone who has written a deserializer, i.e. software which reads a map in a certain notation (XTM, CTM, LTM, AsTMa, ...) to build a topic map instance knows that merging should be done at the end of the deserialization of this single map.

Or maybe not.

The Perl TM package actually puts the developer in charge when merging semantics should be applied. Or whether it should be applied at all.

User-Controlled Timing

The process to resolve overlapping toplets into one must be triggered explicitly calling consolidate:

my $tm = new ....   # get the map

# some time later, when necessary

If you think through merging then you understand that this can be a potentially expensive operation, so control is preferable over a blind let's just do it whenever we feel like it approach.

That way you can actually enrich your map over several steps and have the consolidation only at the end:

my $tm = new ....;       # get the map

$tm->internalize (....); # modify it maybe
$tm->add ($tm2);         # and maybe even add another map

$tm->consolidate;        # spend time here

The method add only adds all toplets and assertions; it obviously does not trigger consolidate.

User-Controlled Modalities

The user is also in charge to control on which basis toplets are merged. Of course, the usual suspects

  • Indicator_based_Merging
  • Subject_based_Merging

are turned on by default. But there is also a way to switch them off, or switch on the most evil

  • TNC_based_Merging

TNC stands for topic name constraint and it makes two toplets mergeable if they share at least one name in the same scope. Sure, it is walking on thin ice. But some people like the thrill.

These merging constraints can be defined when the map is created:

my $tm = new TM (consistency =>
                       [ TM->TNC_based_Merging,
                         TM->Subject_based_Merging ]);

but there is also a read/write accessor cleverly named consistency.


The method consolidate not only is meant to perform the merging. It is also planned to clean up the map (removing superfluous stuff), but I never had the need to invest time. Subtle hints to send chocolate follow ...

Work supported by the Austrian Research Centers.

Posted In