Last active
February 13, 2021 11:28
-
-
Save adzkar/bf4907f6dc6a033e4782da13c88aa8d9 to your computer and use it in GitHub Desktop.
Revisions
-
adzkar revised this gist
Feb 13, 2021 . 1 changed file with 25 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,40 @@ from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST, POST import json with open('contoh.json') as f: specs = json.load(f) x = "" for d in specs['aktivitas di lapangan']: x += f"{d}" print(x) query = """ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX myowl: <http://www.risetgroup.org/ontologies/recommendersystem/smartphone#> SELECT * WHERE { """ + x + """ } """ print(query) sparql = SPARQLWrapper("http://localhost:3030/phone/sparql") sparql.setHTTPAuth(DIGEST) sparql.setCredentials("admin", "admin") sparql.setMethod(POST) sparql.setQuery(query) sparql.setReturnFormat(JSON) results = sparql.query().convert() for result in results["results"]["bindings"]: print(result["s"]["value"]) -
adzkar created this gist
Feb 13, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST, POST sparql = SPARQLWrapper("http://localhost:3030/phone/sparql") sparql.setHTTPAuth(DIGEST) sparql.setCredentials("admin", "admin") sparql.setMethod(POST) sparql.setQuery(""" PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX myowl: <http://www.risetgroup.org/ontologies/recommendersystem/smartphone#> SELECT * WHERE { ?s myowl:hasSpec myowl:GPS_High. ?s myowl:hasSpec myowl:Ukuran_Layar_High. ?s myowl:hasSpec myowl:Kecepatan_Jaringan_High. } """) sparql.setReturnFormat(JSON) results = sparql.query().convert() print(results)