Perl TM 1.47 Maintenance Release
Since the last release there have been a few smaller additions, such as
- a simple entropy computation in TM::Analysis, and
- an neighborhood functionality into TM::Graph.
Both I need for the map visualisation toolchain.
I also fixed some problems when using maps with the MLDBM backend. Most of these concerned the memory usage.
The biggest feature addition, however, is JTM support (via JSON and YAML) which az has contributed just recently. This reminds me, that we still need someone to give the CTM parser more love to match the now to-be-standard.
The package arrived now at the CPAN. See the Changelog for details.
- rho's blog
- Login to post comments
- Printer-friendly version

I get an Error when convertig
Hello!
I ran across a problem with TM package.
When converting an astma2.0 topic map to xtm, I get an error at the Serializable ("TM::Serializable::XTM").
The Error is:
"Use of uninitialized value in string eq at /usr/local/share/perl/5.10.0/TM/Serializable/XTM.pm line 601 during global destruction."
At the end of the post I included my testcode.
Is there any solution to this?
I think it is vital to convert astma to xtm files.
Thanks for any help.
Stephan
---
##CODE:
use TM::Materialized::AsTMa;
use TM::Tau;
use Data::Dumper;
use File::Slurp;
## adapted from http://cpansearch.perl.org/src/DRRHO/TM-1.49/examples/02_astma.pl
$astmacode= '
%version 2.0
rho isa person and has name : "Robert Barta" .
rho has blog : http://kill.devc.at/ .
## much more is possible here
';
write_file( '/tmp/test.atm', $astmacode ) ;
$tm = new TM::Materialized::AsTMa (file => '/tmp/test.atm');
$tm->sync_in;
print Dumper $tm; ## works!
## from http://search.cpan.org/~drrho/TM/lib/TM/Tau.pm
## convert between different formats
$tm = new TM::Tau ('file:/tmp/test.atm > file:/tmp/test.xtm');
## results in the ERROR:
## Use of uninitialized value in string eq at
## /usr/local/share/perl/5.10.0/TM/Serializable/XTM.pm line 601 during global destruction.
Re: I get an Error when convertig
Stephan
When your Perl program is already in global destruction, the Perl interpreter will already have eaten up parts of your data structures. So the serialization is dealing with a deconstructed data structure, and fails.
What you should (not only here, but generally) is to scope your variables. Like here:
my $tm = new TM::Tau ('file:/tmp/test.atm > file:/tmp/test.xtm');
Or even better here:
use TM::Tau;
my $tm = new TM::Tau ('file:/tmp/test.atm > file:/tmp/test.xtm');
}
The error should disappear.
Since we are here, I should mention that working with files is always cumbersome. And often slow. If you want to avoid state (i.e. files), you can also keep everything in memory:
my $tm = new TM::Materialized::AsTMa (inline => <<ASTMA) -> sync_in;
%version 2.0
rho isa person and has name : "Robert Barta" .
rho has blog : http://kill.devc.at/ .
ASTMA
This will inline the astma stream and then immediately afterwards parse the stream into the object.
To serialize it into, say, XTM, you simply attach a trait
print $tm->serialize;
and then write a stream to STDOUT.
astma 2.0 associations?
sounds like I did a real beginner mistake...
Robert, one question:
How do I write an association in astma 2.0?
I tried a lot, but couldn't find a solution.
my code is:
use TM::Materialized::AsTMa;
my $tm = new TM::Materialized::AsTMa (inline => <<ASTMA) -> sync_in;
%version 2.0
rho isa person and has name : "Robert Barta" .
rho has blog : http://kill.devc.at/ .
## much more is possible here
ringo-starr isa person .
drums isa instrument .
(plays-instrument)
player : ringo-starr
instrument : drums
ASTMA
## the error is:
Syntax error: Found LPAREN but expected DOT at yapp/astma2-fact.yp line 693.
I looked at the following websites for before posting:
http://astma.it.bond.edu.au/astma=-spec-2.0r1.0.dbk?section=8
http://www.semagia.com/tmp/CTM%20UseCase%20Solutions.html
Re: astma 2.0 associations
The best place to learn what is possible, is to consult the test file
The grammar of the implemented language is in
but it is a bit cryptic to read (Yacc syntax).
player : ringo-starr
instrument : drums
This is AsTMa 1.0 syntax. In 2.x you should do
player : ringo-starr
instrument : drums
or alternatively
Well, that's CTM, not AsTMa. Whole different animal.
thank you for the hints
I need to learn a lot, because I can hardly follow the examples in "t/045astma2fact.t" yet.
thank you for the hints
regards
Re: thank you for the hints
AsTMa 2.0 never was "finished" in the sense that there was a full language tutorial. It was a testbed for moving away from the highly structured format into one more like a natural language.
The best approximation is probably Lars Heuer's talk:
http://www.topicmaps.com/tm2007/barta-heuer.pdf
But it was clear to me at that time that AsTMa must be combined with the query and the ontology language to arrive at some useful combination.
update and note on TM::Bulk
Today I am writing a short update and regarding a note on TM::Bulk with 'associations'.
I programmed a small REST server (or 'rest approximation') with the TM module.
It works like a charm. Nice is the combination of the tm-rest-server with a XProc rest-server (XProc= xslt pipelines).
The topic map server gives back xml wich is transformed via the XProc-rest-server in anything else, e.g. html.
It might not be a solution for everyone (it uses xml!) but it does the job for me.
Regarding 'TM::Bulk' with 'associations':
I found out that $tm->vortex() honors 'associations'.
I looked at the source code at:
http://cpansearch.perl.org/src/DRRHO/TM-1.50/lib/TM/Bulk.pm
However the documentation for 'TM::Bulk' doesn't mention that (and that it's possible to get a hash for the associations).
So my guess is that either the documentation is not up to date, or it's because there are currently no test cases for associations (in TM::Bulk) and therfore it's not in the documentation.
Regards,
Stephan
ps: If anyone is interested in the code:
##Asma-Testcase:
yyy << xxx ( role1 : aaa bbb , role2 : ccc )
## dump result for the vortex
my $vortex = $tm->vortex($local_id,
{
'topic' => [ 'topic' ],
'associations' => [ 'associations' ],
'roles' => [ 'roles', 0, 10 ] },
);
print Dumper $vortex;
##result:
$VAR1 = {
'topic' => [
'tm://nirvana/ccc',
undef,
[]
],
'roles' => [
'tm://nirvana/yyy'
],
'associations' => [
[
'tm://nirvana/xxx',
'us',
'tm://nirvana/role2',
{
'tm://nirvana/role1' => [
'tm://nirvana/aaa',
'tm://nirvana/bbb'
]
}
]
]
}
Regarding 'TM::Bulk' with 'associations':
That's right. No test cases yet, because it is experimental. You may want to use it on your own risk :-)
Re: TM REST server
Nice. So one can ask for a, say, topic and gets back an XML representation?
Did you use an XML server (like AxKit) for it?