File: 02_astma.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 (68 lines) | stat: -rw-r--r-- 1,470 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
use TM::Materialized::AsTMa;

my $tm = new TM::Materialized::AsTMa (inline => '
sacklpicka (cat)
bn: Der Sacklpicka

rho (person)
oc (blog): http://kill.devc.at/

(owns)
owner: rho
owned: sacklpicka

(is-subclass-of)
subclass: person
superclass: mammal

(is-subclass-of)
subclass: cat
superclass: mammal

');

$tm->sync_in;

use Data::Dumper;

warn Dumper [ $tm->instances  ($tm->tids ('cat')) ];
warn Dumper [ $tm->instances  ($tm->tids ('mammal')) ];
warn Dumper [ $tm->instancesT ($tm->tids ('mammal')) ];

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

warn Dumper [ $tm->are_instances ($tm->tids ('cat', 'rho', 'sacklpicka', 'sacklpicka') ) ];

warn Dumper [ $tm->are_instances ($tm->tids ('mammal', 'rho', 'sacklpicka', 'sacklpicka') ) ];
#----------------------

use File::Slurp;
write_file( '/tmp/something.atm', "sacklpicka (cat)\n\n" ) ;

$tm = new TM::Materialized::AsTMa (file => '/tmp/something.atm');
$tm->sync_in;

$tm->internalize (rho);
$tm->assert (Assertion->new (
                             type => 'owns',
                             roles => [ 'owner', 'object' ],
                             players => [ 'rho', 'sacklpicka' ]));
#warn Dumper $tm;
$tm->sync_out;

#---------------------


$tm = new TM::Materialized::AsTMa (inline => '
%version 2.0

rho isa person and has name : "Robert Barta" .
rho has blog : http://kill.devc.at/ .

# much more is possible here

');
$tm->sync_in;

#warn Dumper $tm;