eyeleng 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ PREFIX : <https://eyereasoner.github.io/ns#>
2
+
3
+ # =================================
4
+ # Cat Koko
5
+ # SRL translation of cat-koko.n3
6
+ # =================================
7
+ #
8
+ # The N3 version contains a rule whose conclusion contains two rules:
9
+ #
10
+ # { :Koko a :Animal } => {
11
+ # { :Koko a :Animal } => { _:x a :Cat } .
12
+ # { :Koko a :Animal } => { _:x a :BritishShortHair } .
13
+ # }.
14
+ #
15
+ # SRL does not have N3 formula terms or rule terms in rule heads.
16
+ # So this SRL version translates the operational effect directly:
17
+ #
18
+ # if :Koko is an :Animal, derive one fresh :Cat;
19
+ # if :Koko is an :Animal, derive one fresh :BritishShortHair.
20
+ #
21
+ # The two blank nodes are intentionally different. In the N3 source, the two
22
+ # _:x labels occur in different quoted formula scopes, so they do not denote
23
+ # the same blank node.
24
+
25
+ DATA {
26
+ :Koko a :Animal .
27
+ }
28
+
29
+ RULE { _:cat a :Cat }
30
+ WHERE {
31
+ :Koko a :Animal .
32
+ }
33
+
34
+ RULE { _:bsh a :BritishShortHair }
35
+ WHERE {
36
+ :Koko a :Animal .
37
+ }
38
+
39
+ # Translation of:
40
+ #
41
+ # ?X a :Cat .
42
+ # ?Y a :BritishShortHair .
43
+ # ?X log:notEqualTo ?Y.
44
+ #
45
+ # SRL uses a FILTER for the inequality test.
46
+
47
+ RULE { :test :is true }
48
+ WHERE {
49
+ ?X a :Cat .
50
+ ?Y a :BritishShortHair .
51
+ FILTER(?X != ?Y)
52
+ }
@@ -0,0 +1,83 @@
1
+ PREFIX : <http://example/graph-term-list/>
2
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
3
+
4
+ # Emulating N3 graph terms as closed RDF list values.
5
+ #
6
+ # In Notation3, a graph term is a quoted graph/formula used as a term:
7
+ #
8
+ # { :alice :knows :bob. :bob :knows :carol }
9
+ #
10
+ # The important point is that the quoted graph is closed. It is not an open
11
+ # container to which rules should add more statements.
12
+ #
13
+ # Therefore this SRL encoding does NOT use:
14
+ #
15
+ # :g1 :statement <<(...)>> .
16
+ #
17
+ # because that is too easy to misuse as an extensible membership relation.
18
+ #
19
+ # Instead, the graph term points to one RDF list value. The list is the quoted
20
+ # graph term representation, and its items are RDF 1.2 quoted triples.
21
+
22
+ DATA {
23
+ :g1 a :GraphTerm ;
24
+ :quotedTriples (
25
+ <<(:alice :knows :bob)>>
26
+ <<(:bob :knows :carol)>>
27
+ ) .
28
+
29
+ :g2 a :GraphTerm ;
30
+ :quotedTriples (
31
+ <<(:alice :likes :tea)>>
32
+ ) .
33
+
34
+ # Example of using the graph term as a term:
35
+ # this says that :note1 is about the closed quoted graph :g1.
36
+ :note1 :aboutGraphTerm :g1 .
37
+ }
38
+
39
+ # Helper index over the RDF list cells.
40
+ # This reads the closed list value; it does not add to or replace the list.
41
+ RULE { ?g :listCell ?cell }
42
+ WHERE {
43
+ ?g :quotedTriples ?cell .
44
+ }
45
+
46
+ RULE { ?g :listCell ?rest }
47
+ WHERE {
48
+ ?g :listCell ?cell .
49
+ ?cell rdf:rest ?rest .
50
+ }
51
+
52
+ # Test rule: classify a graph term if its closed list contains a quoted
53
+ # triple with predicate :knows. The result is metadata ABOUT the graph term.
54
+ RULE { ?g a :SocialGraphTerm }
55
+ WHERE {
56
+ ?g a :GraphTerm ;
57
+ :listCell ?cell .
58
+ ?cell rdf:first <<(?s :knows ?o)>> .
59
+ }
60
+
61
+ # Another safe test: derive who is mentioned by the closed graph term.
62
+ RULE { ?g :mentions ?s }
63
+ WHERE {
64
+ ?g a :GraphTerm ;
65
+ :listCell ?cell .
66
+ ?cell rdf:first <<(?s ?p ?o)>> .
67
+ }
68
+
69
+ RULE { ?g :mentions ?o }
70
+ WHERE {
71
+ ?g a :GraphTerm ;
72
+ :listCell ?cell .
73
+ ?cell rdf:first <<(?s ?p ?o)>> .
74
+ }
75
+
76
+ # Expected derived facts include:
77
+ #
78
+ # :g1 a :SocialGraphTerm .
79
+ # :g1 :mentions :alice, :bob, :carol .
80
+ # :g2 :mentions :alice, :tea .
81
+ #
82
+ # No rule derives rdf:first, rdf:rest, or :quotedTriples, so the graph-term
83
+ # list remains closed.
@@ -0,0 +1,3 @@
1
+ _:bsh a :BritishShortHair .
2
+ _:cat a :Cat .
3
+ :test :is true .
@@ -1,4 +1,4 @@
1
1
  :test :first 1 .
2
- :test :second _:b1 .
2
+ :test :second _:b3 .
3
3
  :test :secondProperty :q .
4
4
  :test :thirdFirst 2 .
@@ -0,0 +1,11 @@
1
+ :g1 :listCell _:b1 .
2
+ :g1 :listCell _:b2 .
3
+ :g1 :listCell rdf:nil .
4
+ :g1 :mentions :alice .
5
+ :g1 :mentions :bob .
6
+ :g1 :mentions :carol .
7
+ :g1 a :SocialGraphTerm .
8
+ :g2 :listCell _:b3 .
9
+ :g2 :listCell rdf:nil .
10
+ :g2 :mentions :alice .
11
+ :g2 :mentions :tea .
@@ -0,0 +1,3 @@
1
+ <urn:eyeleng:message-log:03ead54e#m001> :mentionsSensor :s1 .
2
+ <urn:eyeleng:message-log:03ead54e#m002> :isHeartbeat true .
3
+ <urn:eyeleng:message-log:03ead54e#m003> :mentionsSensor :s2 .
@@ -0,0 +1,15 @@
1
+ PREFIX : <http://example/messages#>
2
+ PREFIX eymsg: <https://eyereasoner.github.io/eyeling/vocab/message#>
3
+
4
+ IMPORTS <./rdf-messages.trig>
5
+
6
+ RULE { ?envelope :mentionsSensor ?sensor }
7
+ WHERE {
8
+ ?envelope eymsg:payloadGraph ?payload .
9
+ ?payload eymsg:payloadTriple <<(?reading :sensor ?sensor)>> .
10
+ }
11
+
12
+ RULE { ?envelope :isHeartbeat true }
13
+ WHERE {
14
+ ?envelope eymsg:payloadKind eymsg:empty .
15
+ }
@@ -0,0 +1,12 @@
1
+ VERSION "1.2-messages"
2
+ PREFIX : <http://example/messages#>
3
+
4
+ _:reading :sensor :s1 ; :value 21 .
5
+
6
+ MESSAGE
7
+
8
+ # Empty heartbeat message.
9
+
10
+ MESSAGE
11
+
12
+ _:reading :sensor :s2 ; :value 22 .