File: 01_low_level.pl

package info (click to toggle)
libtm-perl 1.56-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,692 kB
  • ctags: 1,084
  • sloc: perl: 35,266; makefile: 48
file content (82 lines) | stat: -rw-r--r-- 2,051 bytes parent folder | download | duplicates (5)
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
use TM;
my $tm = new TM ();    # create an empty map

use Data::Dumper;
#warn Dumper $tm;

$tm->internalize ('pony' => \ 'http://en.wikipedia.org/wiki/Pony');

warn Dumper [ $tm->toplets (\ '+all -infrastructure') ];

my ($t) = $tm->toplets ('tm://nirvana/pony');
warn Dumper $t->[TM->INDICATORS];


my $a = Assertion->new (kind    => TM->ASSOC,
                        type    => 'isa',
                        roles   => [ 'instance', 'class' ],
                        players => [ 'sacklpicka', 'cat' ]);
$tm->assert ($a);

use TM::Literal;
$tm->assert (Assertion->new (kind    => TM->NAME,
			     type    => 'name',
			     scope   => 'en',
			     roles   => [ 'thing', 'value' ],
			     players => [ 'sacklpicka', 
                                          new TM::Literal ('Der Sacklpicka') ]),
	     Assertion->new (kind    => TM->OCC,
			     type    => 'occurrence',
			     scope   => 'us',
			     roles   => [ 'thing', 'value' ],
			     players => [ 'sacklpicka', 
                                          new TM::Literal ('http://devc.at', 
                                                           TM::Literal->URI) ])
	     );

my @cats;

@cats = $tm->match_forall (
			      type => 'isa',
			      roles   => [ 'instance', 'class' ],
			      players => [ undef,      'cat' ]
			      );

@cats = $tm->match_forall (type => 'isa',
			   class => $tm->tids ('cat'));

warn Dumper \@cats;
warn Dumper [ map { $tm->get_players ($_, 'instance') } @cats ];

warn Dumper [
	     map { $_->[0] }
	     map { $tm->get_players ($_, 'value') }
	     grep { $_->[TM->KIND] == TM->OCC }
	     $tm->match_forall ('topic' => $tm->tids ('sacklpicka'),
				'char' => '1')
	     ];

warn Dumper [
	     map { $tm->get_x_players ($_, 'thing') }
	     $tm->match_forall ('value' => new TM::Literal ('Der Sacklpicka'),
				'char' => '1')
	     ];

#warn Dumper $tm;

warn "I knew it"
    if $tm->is_a ($tm->tids ('sacklpicka', 'cat'));

warn "Not sure about that"
    unless $tm->is_subclass ($tm->tids ('cat', 'thing'));

__END__





__END__