eyeling 1.24.27 → 1.24.28
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.
- package/examples/odrl-dpv-ehds-risk-ranked.n3 +4 -4
- package/examples/odrl-dpv-healthcare-risk-ranked.n3 +4 -4
- package/examples/odrl-dpv-risk-ranked.n3 +4 -4
- package/examples/odrl-risk-mitigation.n3 +5 -5
- package/examples/odrl-risk.n3 +3 -3
- package/examples/output/odrl-dpv-ehds-risk-ranked.md +35 -14
- package/examples/output/odrl-dpv-healthcare-risk-ranked.md +27 -11
- package/examples/output/odrl-dpv-risk-ranked.md +37 -15
- package/examples/output/odrl-risk-mitigation.md +64 -17
- package/examples/output/odrl-risk.md +33 -5
- package/examples/output/transitive-closure.n3 +2699 -0
- package/examples/transitive-closure.n3 +144 -0
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
@prefix : <http://example.org/closure#>.
|
|
2
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
3
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
4
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
5
|
+
|
|
6
|
+
# C-core transitive-closure demonstration, translated to N3.
|
|
7
|
+
#
|
|
8
|
+
# Generate a chain of nodes, derive direct links, then materialize
|
|
9
|
+
# all transitive reachability pairs.
|
|
10
|
+
|
|
11
|
+
:report :nodes 70.
|
|
12
|
+
|
|
13
|
+
# Generate the integer range 1..Max.
|
|
14
|
+
:range :has 1.
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
:range :has ?N.
|
|
18
|
+
:report :nodes ?Max.
|
|
19
|
+
?N math:lessThan ?Max.
|
|
20
|
+
(?N 1) math:sum ?Next.
|
|
21
|
+
}
|
|
22
|
+
=>
|
|
23
|
+
{
|
|
24
|
+
:range :has ?Next.
|
|
25
|
+
}.
|
|
26
|
+
|
|
27
|
+
# Turn each number into a node IRI:
|
|
28
|
+
# 1 -> :n1
|
|
29
|
+
# 2 -> :n2
|
|
30
|
+
# ...
|
|
31
|
+
{
|
|
32
|
+
:range :has ?N.
|
|
33
|
+
("http://example.org/closure#n" ?N) string:concatenation ?NodeText.
|
|
34
|
+
?Node log:uri ?NodeText.
|
|
35
|
+
}
|
|
36
|
+
=>
|
|
37
|
+
{
|
|
38
|
+
?N :node ?Node.
|
|
39
|
+
}.
|
|
40
|
+
|
|
41
|
+
# Successor numbers.
|
|
42
|
+
{
|
|
43
|
+
:range :has ?N.
|
|
44
|
+
:report :nodes ?Max.
|
|
45
|
+
?N math:lessThan ?Max.
|
|
46
|
+
(?N 1) math:sum ?Next.
|
|
47
|
+
}
|
|
48
|
+
=>
|
|
49
|
+
{
|
|
50
|
+
?N :nextNumber ?Next.
|
|
51
|
+
}.
|
|
52
|
+
|
|
53
|
+
# Direct chain links.
|
|
54
|
+
{
|
|
55
|
+
?N :node ?From.
|
|
56
|
+
?N :nextNumber ?Next.
|
|
57
|
+
?Next :node ?To.
|
|
58
|
+
}
|
|
59
|
+
=>
|
|
60
|
+
{
|
|
61
|
+
?From :link ?To.
|
|
62
|
+
}.
|
|
63
|
+
|
|
64
|
+
# Reachability: base case.
|
|
65
|
+
{
|
|
66
|
+
?From :link ?To.
|
|
67
|
+
}
|
|
68
|
+
=>
|
|
69
|
+
{
|
|
70
|
+
?From :reaches ?To.
|
|
71
|
+
}.
|
|
72
|
+
|
|
73
|
+
# Reachability: transitive case.
|
|
74
|
+
{
|
|
75
|
+
?From :link ?Via.
|
|
76
|
+
?Via :reaches ?To.
|
|
77
|
+
}
|
|
78
|
+
=>
|
|
79
|
+
{
|
|
80
|
+
?From :reaches ?To.
|
|
81
|
+
}.
|
|
82
|
+
|
|
83
|
+
# Report direct links: Max - 1.
|
|
84
|
+
{
|
|
85
|
+
:report :nodes ?Max.
|
|
86
|
+
(?Max 1) math:difference ?Links.
|
|
87
|
+
}
|
|
88
|
+
=>
|
|
89
|
+
{
|
|
90
|
+
:report :directLinks ?Links.
|
|
91
|
+
}.
|
|
92
|
+
|
|
93
|
+
# Report reachable pairs: Max * (Max - 1) / 2.
|
|
94
|
+
{
|
|
95
|
+
:report :nodes ?Max.
|
|
96
|
+
(?Max 1) math:difference ?Previous.
|
|
97
|
+
(?Max ?Previous) math:product ?TwicePairs.
|
|
98
|
+
(?TwicePairs 2) math:quotient ?Pairs.
|
|
99
|
+
}
|
|
100
|
+
=>
|
|
101
|
+
{
|
|
102
|
+
:report :reachablePairs ?Pairs.
|
|
103
|
+
}.
|
|
104
|
+
|
|
105
|
+
# Expected materialized triples:
|
|
106
|
+
# reachable pairs + direct links + 8 report/test triples
|
|
107
|
+
{
|
|
108
|
+
:report :nodes ?Max.
|
|
109
|
+
(?Max 1) math:difference ?Links.
|
|
110
|
+
(?Max ?Links) math:product ?TwicePairs.
|
|
111
|
+
(?TwicePairs 2) math:quotient ?Pairs.
|
|
112
|
+
(?Pairs ?Links) math:sum ?GraphTriples.
|
|
113
|
+
(?GraphTriples 8) math:sum ?Total.
|
|
114
|
+
}
|
|
115
|
+
=>
|
|
116
|
+
{
|
|
117
|
+
:report :expectedMaterializedTriples ?Total.
|
|
118
|
+
}.
|
|
119
|
+
|
|
120
|
+
:report :firstNode :n1.
|
|
121
|
+
|
|
122
|
+
{
|
|
123
|
+
:report :nodes ?Max.
|
|
124
|
+
("http://example.org/closure#n" ?Max) string:concatenation ?LastText.
|
|
125
|
+
?Last log:uri ?LastText.
|
|
126
|
+
}
|
|
127
|
+
=>
|
|
128
|
+
{
|
|
129
|
+
:report :lastNode ?Last.
|
|
130
|
+
}.
|
|
131
|
+
|
|
132
|
+
:report :message "Recursive closure from a tiny source: this is the C core hot path.".
|
|
133
|
+
|
|
134
|
+
# Test triple: n1 reaches the generated last node.
|
|
135
|
+
{
|
|
136
|
+
:report :nodes ?Max.
|
|
137
|
+
("http://example.org/closure#n" ?Max) string:concatenation ?LastText.
|
|
138
|
+
?Last log:uri ?LastText.
|
|
139
|
+
:n1 :reaches ?Last.
|
|
140
|
+
}
|
|
141
|
+
=>
|
|
142
|
+
{
|
|
143
|
+
:test :is true.
|
|
144
|
+
}.
|