-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39f05c3
commit d962cee
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ns = "http://datashapes.org/py/tests/rules/rectangle.test#" | ||
|
||
|
||
def compute_area(_this): | ||
width = get_property(_this, "width") | ||
height = get_property(_this, "height") | ||
area = py_tf.literal(int(width.getLex()) * int(height.getLex()), width.getDatatype()) | ||
area_property = py_tf.namedNode(ns + "area") | ||
return [ [_this, area_property, area] ] | ||
|
||
|
||
def get_property(_this, name): | ||
it = _data.find(_this, py_tf.namedNode(ns + name), None) | ||
result = it.next().getObject() | ||
it.close() | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# baseURI: http://datashapes.org/py/tests/rules/rectangle.test | ||
# imports: http://datashapes.org/dash | ||
# prefix: ex | ||
|
||
@prefix dash: <http://datashapes.org/dash#> . | ||
@prefix ex: <http://datashapes.org/py/tests/rules/rectangle.test#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
||
<http://datashapes.org/py/tests/rules/rectangle.test> | ||
rdf:type owl:Ontology ; | ||
rdfs:label "Test of rectangle" ; | ||
owl:imports <http://datashapes.org/dash> ; | ||
. | ||
ex:ExampleRectangle | ||
rdf:type ex:Rectangle ; | ||
ex:height 8 ; | ||
ex:width 7 ; | ||
. | ||
ex:InferencingTestCase | ||
rdf:type dash:InferencingTestCase ; | ||
dash:expectedResult [ | ||
rdf:object 56 ; | ||
rdf:predicate ex:area ; | ||
rdf:subject ex:ExampleRectangle ; | ||
] ; | ||
. | ||
ex:Rectangle | ||
rdf:type rdfs:Class ; | ||
rdfs:subClassOf rdfs:Resource ; | ||
. | ||
ex:RectangleShape | ||
rdf:type sh:NodeShape ; | ||
sh:rule [ | ||
rdf:type sh:PyRule ; | ||
sh:pyFunctionName "compute_area" ; | ||
sh:pyLibrary [ | ||
sh:pyLibraryURL "http://datashapes.org/py/tests/rules/rectangle.py"^^xsd:anyURI ; | ||
] ; | ||
] ; | ||
sh:targetClass ex:Rectangle ; | ||
. |