Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
XML-Tech
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdler
XML-Tech
Commits
68a6f7b5
Commit
68a6f7b5
authored
7 years ago
by
Your Name
Browse files
Options
Downloads
Patches
Plain Diff
sparql support
parent
f88e1c4b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Sparql.py
+89
-0
89 additions, 0 deletions
Sparql.py
__pycache__/Sparql.cpython-35.pyc
+0
-0
0 additions, 0 deletions
__pycache__/Sparql.cpython-35.pyc
api.py
+1
-0
1 addition, 0 deletions
api.py
with
90 additions
and
0 deletions
Sparql.py
0 → 100644
+
89
−
0
View file @
68a6f7b5
from
SPARQLWrapper
import
SPARQLWrapper
,
JSON
from
flask
import
jsonify
sparql
=
SPARQLWrapper
(
"
http://dbpedia.org/sparql
"
)
#Bekommt den Namen des Kuenstlers
#Gibt einen Tupel (Name, Geschlecht, Geburtsdatum, Todesdatum, Beschreibung) zurueck
def
sendSparqlQuery
(
name
):
if
"
(
"
in
name
:
name
=
name
.
split
(
"
(
"
)[
0
]
print
(
"
Name :
"
+
name
+
"
:
"
)
results
=
send
(
name
)
print
(
"
Empfange
"
)
test
=
results
[
'
results
'
][
'
bindings
'
]
print
(
len
(
test
))
if
(
len
(
test
)
>=
1
):
tests
=
test
for
test
in
tests
:
name
=
test
[
'
name
'
][
'
value
'
]
gender
=
test
[
'
gender
'
][
'
value
'
]
birth
=
test
[
'
birth
'
][
'
value
'
]
death
=
test
[
'
death
'
][
'
value
'
]
description
=
test
[
'
description
'
][
'
value
'
]
return
(
name
,
gender
,
birth
,
death
,
description
)
else
:
return
(
"
No Information
"
,
"
No Information
"
,
"
No Information
"
,
"
No Information
"
,
"
No Information
"
)
def
send
(
name
):
print
(
"
Bearbeite
"
)
print
(
"""
PREFIX owl: <http://www.w3.org/2002/07/owl#>
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#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbo: <http://dbpedia.org/ontology/>#
select ?person ?name ?birth ?description where {
?person a dbo:Person ;
foaf:name ?name ;
dbo:birthDate ?birth ;
dbo:abstract ?description
filter langMatches(lang(?description),
'
en
'
)
FILTER regex(str(?name),
"""
+
"
\"
"
+
name
+
"
\"
"
+
"""
)
}
order by ?person
"""
)
sparql
.
setQuery
(
"""
PREFIX owl: <http://www.w3.org/2002/07/owl#>
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#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbo: <http://dbpedia.org/ontology/>#
select ?person ?name ?gender ?birth ?death ?description where {
?person a dbo:Person ;
foaf:name ?name ;
foaf:gender ?gender;
dbo:birthDate ?birth ;
dbo:deathDate ?death;
dbo:abstract ?description
filter langMatches(lang(?description),
'
en
'
)
FILTER regex(str(?name),
"""
+
"
\"
"
+
name
+
"
\"
"
+
"""
)
}
order by ?person
"""
)
sparql
.
setReturnFormat
(
JSON
)
return
sparql
.
query
().
convert
()
This diff is collapsed.
Click to expand it.
__pycache__/Sparql.cpython-35.pyc
0 → 100644
+
0
−
0
View file @
68a6f7b5
File added
This diff is collapsed.
Click to expand it.
api.py
+
1
−
0
View file @
68a6f7b5
from
flask
import
Flask
,
request
,
jsonify
,
make_response
,
g
,
render_template
from
flask_cors
import
CORS
import
BaseXClient
from
Sparql
import
sendSparqlQuery
import
threading
import
xml.etree.ElementTree
as
ET
import
xml.dom.minidom
as
dom
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment