How to resolve Predicate is not allowed (closed shape) validation error - validation

I am using https://shacl.org/playground/
I have the following Shape Graph:
#prefix hr: <http://learningsparql.com/ns/humanResources#> .
#prefix d: <http://learningsparql.com/ns/data#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
hr:ClassShape
a sh:NodeShape ;
sh:targetSubjectsOf rdf:type;
sh:or (
[
sh:path rdf:type ;
sh:nodeKind sh:IRI ;
sh:hasValue rdfs:Class;
]
[
sh:path rdf:type ;
sh:nodeKind sh:IRI ;
sh:hasValue rdf:Property;
]
);
sh:closed true ;
.
I have the following Data Graph
#prefix hr: <http://learningsparql.com/ns/humanResources#> .
#prefix d: <http://learningsparql.com/ns/data#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
#### Regular RDFS modeling ####
hr:Employee a rdfs:Class .
hr:Another a rdfs:Class .
hr:name
rdf:type rdf:Property ; .
hr:hireDate
rdf:type rdf:Property ; .
hr:jobGrade
rdf:type rdf:Property ; .
I want to verify that every node which declares a rdf:type has a value of either rdfs:Class or rdf:Property.
I am getting the following validation errors:
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape hr:ClassShape ;
sh:focusNode hr:Employee ;
sh:resultPath rdf:type ;
sh:value rdfs:Class ;
sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape hr:ClassShape ;
sh:focusNode hr:Another ;
sh:resultPath rdf:type ;
sh:value rdfs:Class ;
sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape hr:ClassShape ;
sh:focusNode hr:name ;
sh:resultPath rdf:type ;
sh:value rdf:Property ;
sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape hr:ClassShape ;
sh:focusNode hr:hireDate ;
sh:resultPath rdf:type ;
sh:value rdf:Property ;
sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape hr:ClassShape ;
sh:focusNode hr:jobGrade ;
sh:resultPath rdf:type ;
sh:value rdf:Property ;
sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
I am not sure why or what I need to do to resolve them. I believe all of the validation errors are related, so the solution to one should provide the solution to the rest.
What should my Shape file look like?

You confused the OR-statement, here is a working example following the SHACL docs on sh:or
#prefix hr: <http://learningsparql.com/ns/humanResources#> .
#prefix d: <http://learningsparql.com/ns/data#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
hr:ClassShape
a sh:NodeShape ;
sh:targetSubjectsOf rdf:type;
sh:property [
sh:path rdf:type ;
sh:nodeKind sh:IRI ;
sh:or (
[sh:hasValue rdfs:Class;]
[sh:hasValue rdf:Property;]
)
];
sh:closed true ;
.

sh:closed only looks at directly declared properties of the shape. So it should work if you state
hr:ClassShape
sh:property [
sh:path rdf:type ;
] ;
sh:closed true ;
...
Closed shapes do not consider sh:or or other complex structures, see the details at
https://www.w3.org/TR/shacl/#ClosedConstraintComponent

Related

Repository settings for maximum read performance

I'm setting up a demo with a database that contains around 150 million triples and wanted to confirm with you what repo settings I should change to maximize the performance of read queries. The only two things I have changed in the attached template so far were:
owlim:entity-index-size "155000000" ;
owlim:entity-id-size "32" ;
Any recommendations for updates, as well?
Please find the config template below.
Thanks.
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
#prefix rep: <http://www.openrdf.org/config/repository#>.
#prefix sr: <http://www.openrdf.org/config/repository/sail#>.
#prefix sail: <http://www.openrdf.org/config/sail#>.
#prefix owlim: <http://www.ontotext.com/trree/owlim#>.
[] a rep:Repository ;
rep:repositoryID "Northwind" ;
rdfs:label "Northwind sample database" ;
rep:repositoryImpl [
rep:repositoryType "graphdb:FreeSailRepository" ;
sr:sailImpl [
sail:sailType "graphdb:FreeSail" ;
owlim:owlim-license "" ;
owlim:base-URL "http://example.org/graphdb#" ;
owlim:defaultNS "" ;
owlim:entity-index-size "155000000" ;
owlim:entity-id-size "32" ;
owlim:imports "" ;
owlim:repository-type "file-repository" ;
owlim:ruleset "owl-horst-optimized" ;
owlim:storage-folder "storage" ;
owlim:enable-context-index "false" ;
owlim:cache-memory "80m" ;
owlim:tuple-index-memory "80m" ;
owlim:enablePredicateList "false" ;
owlim:predicate-memory "0%" ;
owlim:fts-memory "0%" ;
owlim:ftsIndexPolicy "never" ;
owlim:ftsLiteralsOnly "true" ;
owlim:in-memory-literal-properties "false" ;
owlim:enable-literal-index "true" ;
owlim:index-compression-ratio "-1" ;
owlim:check-for-inconsistencies "false" ;
owlim:disable-sameAs "false" ;
owlim:enable-optimization "true" ;
owlim:transaction-mode "safe" ;
owlim:transaction-isolation "true" ;
owlim:query-timeout "1800" ;
owlim:query-limit-results "0" ;
owlim:throw-QueryEvaluationException-on-timeout "false" ;
owlim:useShutdownHooks "true" ;
owlim:read-only "false" ;
owlim:nonInterpretablePredicates "http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig" ;
]
].

How to get last default gateway from a windows command file

In This Question a script is presented to capture the last default gateway. (Another solution is shown to capture the first gateway, but I want the last one.
The script is:
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "Default"') do set ip=%%b
set ip=%ip:~2%
echo.
echo The Gateway is: %ip%
echo.
Given this ipconfig input (some details removed for privacy):
Ethernet adapter Ethernet 2:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 10.1.251.148
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 0.0.0.0
Ethernet adapter Npcap Loopback Adapter:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::****:a19b:****:bf4%15
Autoconfiguration IPv4 Address. . : 169.254.11.244
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : ev***.li****.io
Link-local IPv6 Address . . . . . : fe80::a**:c4**:c**1:dfa3%14
IPv4 Address. . . . . . . . . . . : 10.100.17.34
Subnet Mask . . . . . . . . . . . : 255.255.248.0
Default Gateway . . . . . . . . . : 10.100.16.1
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
c:\>
The output result is:
c:\>for /F "tokens=1-2 delims=:" %a in ('ipconfig|find "Default"') do set ip=%b
c:\>set ip= 0.0.0.0
c:\>set ip=
c:\>set ip= 10.100.16.1
c:\>set ip=0.100.16.1
c:\>echo.
c:\>echo The Gateway is: 0.100.16.1
The Gateway is: 0.100.16.1
c:\>echo.
As the for loop iterates, it has the correct gateway address on the third iteration, but then a fourth iteration overwrites it with and incorrect value with the first digit truncated. I'm not sure why there is a fourth iteration since the word Default is present three times.
Why does this happen?

DB2-400 MCH-1210 'receiver too small to hold result' in module QQQQUERY subroutine BUILDAP

Occasionaly we get the following message
from module QQQQUERY in procedure BUILDAP.
MCH1210 Receiver value too small to hold result.
Van module . . . . . . . . : QQQQUERY
Van procedure . . . . . . . : BUILDAP
Instructie . . . . . . . . : 24041
Naar module . . . . . . . . : QQQQUERY
Naar procedure . . . . . . : BUILDAP
Instructie . . . . . . . . : 24041
Bericht . . . . : Receiver value too small to hold result.
Extra log info
MCH1210 Escape 40 11/04/18 10:33:28,661097 QQQQUERY QSYS *STMT QQQQUERY QSYS *STMT
Van module . . . . . . . . : QQQQUERY
Van procedure . . . . . . . : BUILDAP
Instructie . . . . . . . . : 24041
Naar module . . . . . . . . : QQQQUERY
Naar procedure . . . . . . : BUILDAP
Instructie . . . . . . . . : 24041
Bericht . . . . : Receiver value too small to hold result.
CPF4204 Escape 50 11/04/18 10:33:28,697990 QQQQUERY QSYS *STMT LOGGING2 SOARETPGM *STMT
Van module . . . . . . . . : QQQQUERY
Van procedure . . . . . . . : QQQQUERY
Instructie . . . . . . . . : 34332
Naar module . . . . . . . . : LOGGING2
Naar procedure . . . . . . : LOGGING2
Instructie . . . . . . . . : 1000001
Bericht . . . . : Er is een interne storing opgetreden in de queryprocessor.
Oorzaak . . . . : er is een systeemfout opgetreden in het programma van de
queryprocessor. Het nummer van het querydefinitiesjabloon (QDT) is 0.
Recovery . . . : raadpleeg de berichten van lager niveau. Verbeter
eventuele fouten en geef de opdracht opnieuw op. Als het probleem zich
opnieuw voordoet, meldt u het probleem met de opdracht ANZPRB (Problemen
analyseren).
RNX1216 Escape 99 11/04/18 10:33:28,828323 QRNXIE QSYS *STMT LOGGING2 SOARETPGM *STMT
Van module . . . . . . . . : QRNXMSG
Van procedure . . . . . . . : SignalException
Instructie . . . . . . . . : 21
Naar module . . . . . . . . : LOGGING2
Naar procedure . . . . . . : LOGGING2
Instructie . . . . . . . . : 1000001
Bericht . . . . : Error message CPF4204 appeared during OPEN for file
FALOGBL0.
Cause . . . . . : RPG procedure LOGGING2 in program SOARETPGM/LOGGING2
received the message CPF4204 while performing an implicit OPEN operation on
file FALOGBL0. The actual file is FALOGBL0. Recovery . . . : Check the
job log for a complete description of message CPF4204, and contact the
person responsible for program maintenance. If the file has a device type of
SPECIAL, there may be no message in the job log.
RNQ1216 Kopie afzender 99 11/04/18 10:33:28,838222 QRNXIE QSYS *STMT QRNXIE QSYS *STMT
Van module . . . . . . . . : QRNXMSG
Van procedure . . . . . . . : InqMsg
Instructie . . . . . . . . : 8
Naar module . . . . . . . . : QRNXMSG
Naar procedure . . . . . . : InqMsg
Instructie . . . . . . . . : 8
Bericht . . . . : Error message CPF4204 appeared during OPEN for file
FALOGBL0 (C S D F).
Cause . . . . . : RPG procedure LOGGING2 in program SOARETPGM/LOGGING2
received the message CPF4204 while performing an implicit OPEN operation on
file FALOGBL0. The actual file is FALOGBL0. Recovery . . . : Check the
job log for a complete description of message CPF4204, and contact the
person responsible for program maintenance. If the file has a device type of
SPECIAL, there may be no message in the job log. Possible choices for
replying to message . . . . . . . . . . . . . . . : D – Obtain RPG
formatted printout of system storage. S – Obtain printout of system
storage. F – Obtain full formatted printout of system storage. C – Cancel.
And this occurs in a triggerprogram that we use for logging changes.
The triggertime is *after and event is *update & *insert & *delete.
The problem occurs when starting the program and ultimatly gives a CPF4204 msg during opening the logical which contains the logged data.
It has occurred on several files we log.
Any suggestions where to look?
Tx

Signal reach in matrix algorithm

I found an algorithm problem and I've been thinking a possible solution to it but I just can think about the "intuitive" one, let's see if someone can lend me a hand.
The problem is the following, we have a n*m matrix in which we have empty spaces represented by . and walls represented by %. We can place a "router" (represented by R) in any place (i,j) inside the matrix with a range of n steps/cells . Consider that a step can only be up/down/left/right.
Which is the most efficient way to check the range of the router?
Example (n=4)
. . . . . . . . . .
. . % % . . . . . .
. . % . . . % . . .
. . . . R . % . . .
. . % . . . % . . .
. . % . . . . . . .
Soltion (# marks signal reach)
. . . # # # . . . .
. . % % # # # . . .
. # % # # # % . . .
# # # # R # % . . .
. # % # # # % . . .
. . % # # # # . . .
I've been investigating and found the Flood Fill algorithm, I guess I could use it with an extra parameter to check the steps I've already used recursively. Do any of you know any algorithm that could more efficient?
If you'd like to write some code feel free to use any language you want. Thank you beforehand guys!
I think the best approach is to use BFS. You basically use a queue to visit the nodes layer by layer.
Using BFS it will visit the cells like this (consider R as (0,0)):
t = 0 - Queue = {(0,0)}
For each element in query, visit north, east, west, south if not
visited and not wall
For (0, 0) -> Visit (1, 0), (0, 1), (-1, 0), (0, -1)
. . . . . . . . . .
. . % % . . . . . .
. . % . . . % . . .
. . . . R . % . . .
. . % . . . % . . .
. . % . . . . . . .
t = 1 Queue = {(1, 0), (0, 1), (-1, 0), (0, -1)}
For each element in query, visit north, east, west, south if not visited and not wall
For (1, 0) -> Visit (2, 0), (1, 1), (1, -1)
For (0, 1) -> Visit (0, 2), (-1, 1)
For (-1, 0) -> Visit (-1, 0), (-2, 0)
For (0, -1) -> Visit (-1, -1), (0, -2)
. . . . . . . . . .
. . % % . . . . . .
. . % . # . % . . .
. . . # R # % . . .
. . % . # . % . . .
. . % . . . . . . .
t = 2 and so on
. . . . . . . . . .
. . % % # . . . . .
. . % # # # % . . .
. . # # R # % . . .
. . % # # # % . . .
. . % . # . . . . .
t = 3
. . . . # . . . . .
. . % % # # . . . .
. . % # # # % . . .
. # # # R # % . . .
. . % # # # % . . .
. . % # # # . . . .

Golang static identifier resolution

I'm attempting to do some static analysis on function calls in a Go project using the go/parse, go/token and go/ast modules, but I can't figure out how to determine the type of a given ast.Ident object.
For instance if parse something like this:
textToContain := bytes.NewBuffer([]byte{})
// lots of other code
text := textToContain.String() // <- I care about this function call
(this is parsed from here: file)
EDIT: It took a lot of code to parse this so I didn't post it here, but you can find it as a gist at: https://gist.github.com/EricChiang/6735340c5fa3d2de2b73
I get the following code printed using the ast.Print function
0 *ast.CallExpr {
1 . Fun: *ast.SelectorExpr {
2 . . X: *ast.Ident {
4 . . . Name: "textToContain"
5 . . . Obj: *ast.Object {
6 . . . . Kind: var
7 . . . . Name: "textToContain"
8 . . . . Decl: *ast.AssignStmt {
9 . . . . . Lhs: []ast.Expr (len = 1) {
10 . . . . . . 0: *ast.Ident {
12 . . . . . . . Name: "textToContain"
13 . . . . . . . Obj: *(obj # 5)
14 . . . . . . }
15 . . . . . }
17 . . . . . Tok: :=
18 . . . . . Rhs: []ast.Expr (len = 1) {
19 . . . . . . 0: *ast.CallExpr {
20 . . . . . . . Fun: *ast.SelectorExpr {
21 . . . . . . . . X: *ast.Ident {
23 . . . . . . . . . Name: "bytes"
24 . . . . . . . . }
25 . . . . . . . . Sel: *ast.Ident {
27 . . . . . . . . . Name: "NewBuffer"
28 . . . . . . . . }
29 . . . . . . . }
31 . . . . . . . Args: []ast.Expr (len = 1) {
32 . . . . . . . . 0: *ast.CompositeLit {
33 . . . . . . . . . Type: *ast.ArrayType {
35 . . . . . . . . . . Elt: *ast.Ident {
37 . . . . . . . . . . . Name: "byte"
38 . . . . . . . . . . }
39 . . . . . . . . . }
42 . . . . . . . . }
43 . . . . . . . }
44 . . . . . . . Ellipsis: -
46 . . . . . . }
47 . . . . . }
48 . . . . }
49 . . . }
50 . . }
51 . . Sel: *ast.Ident {
53 . . . Name: "String"
54 . . }
55 . }
57 . Ellipsis: -
59 }
But I can't see where I could infer the type of textToContain
I know a bunch of tools that can do this, for instance this example from the go blog, but I think I'm going in the wrong direction.
3of3 is right; you need the type checker, which is golang.org/x/tools/go/types. In general, the type of an expression depends on type information for the transitive closure of import dependencies, so you will probably want to use the golang.org/x/tools/go/loader package (which I maintain), which takes care of many challenging details for you. Its stdlib_test.go may be a useful starting point.
Once you've identified the expression of interest, you can find its type in one of the mappings within the types.Info structure for the AST's package.
In this case, the expression is a referring identifier (*ast.Ident) so look in the Uses mapping to find the types.Object (named entity) to which it refers---a local variable (*types.Var) in this case. For expressions other than identifiers, the Types mapping will tell you its type.

Resources