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.
The process to resolve overlapping toplets into one must be triggered explicitly calling consolidate:
# 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:
$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.
The user is also in charge to control on which basis toplets are merged. Of course, the usual suspects
are turned on by default. But there is also a way to switch them off, or switch on the most evil
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:
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.