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
|
from pyrudof import Rudof, RudofConfig
rudof = Rudof(RudofConfig())
'''
rudof.read_data_str("""
prefix : <http://example.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
:timbl rdfs:label "Tim Berners Lee" ;
:employer :CERN {| :start "1984" ;
:end "1994" |}
{| :start "1980" ;
:end "1980" |} ;
:award :PA {| :time "2002" ;
:togetherWith :vint |} .
:vint rdfs:label "Vinton Cerf" .
""")
'''
rudof.read_data_str("""
prefix : <http://example.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
:timbl rdfs:label "Tim Berners Lee" .
_:r rdf:reifies <<( :timbl :employer :CERN )>> ;
:start "1984" ;
:end "1994" .
_:s rdf:reifies <<( :timbl :employer :CERN )>> ;
:start "1980" ;
:end "1980" .
_:t rdf:reifies <<( :timbl :employer :CERN )>> ;
:time "2002" ;
:togetherWith :vint .
:vint rdfs:label "Vinton Cerf" .
""")
results = rudof.run_query_str("""
prefix : <http://example.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?person ?employer ?start ?end WHERE {
?r rdf:reifies <<( ?person :employer ?employer )>> ;
:start ?start ;
:end ?end .
}
""")
print(results.show())
# print(rudof.node_info(":timbl"))
|