Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
e42af082
Commit
e42af082
authored
Dec 5, 2021
by
Cornelia Michlits
Browse files
Options
Downloads
Patches
Plain Diff
104 ontology - adjust rdflib version
Former-commit-id:
3c55b0e9
parent
92d380ed
No related branches found
No related tags found
1 merge request
!42
Fixed the query service tests
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
fda-units-service/list.py
+25
-6
25 additions, 6 deletions
fda-units-service/list.py
fda-units-service/requirements.txt
+1
-1
1 addition, 1 deletion
fda-units-service/requirements.txt
with
26 additions
and
7 deletions
fda-units-service/list.py
+
25
−
6
View file @
e42af082
...
@@ -15,7 +15,9 @@ g.parse('onto/om-2.ttl', format='turtle')
...
@@ -15,7 +15,9 @@ g.parse('onto/om-2.ttl', format='turtle')
om
=
rdflib
.
Namespace
(
'
http://www.ontology-of-units-of-measure.org/resource/om-2/
'
)
om
=
rdflib
.
Namespace
(
'
http://www.ontology-of-units-of-measure.org/resource/om-2/
'
)
rdf_schema
=
rdflib
.
Namespace
(
'
http://www.w3.org/2000/01/rdf-schema#
'
)
rdf_schema
=
rdflib
.
Namespace
(
'
http://www.w3.org/2000/01/rdf-schema#
'
)
def
list_units
(
string
):
r
=
{}
def
list_units
(
string
,
offset
=
0
):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9]+$
'
,
string
)):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9]+$
'
,
string
)):
l_query
=
"""
l_query
=
"""
SELECT ?symbol ?name ?comment
SELECT ?symbol ?name ?comment
...
@@ -24,9 +26,26 @@ def list_units(string):
...
@@ -24,9 +26,26 @@ def list_units(string):
?unit <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?unit <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?unit <http://www.w3.org/2000/01/rdf-schema#comment> ?comment .
?unit <http://www.w3.org/2000/01/rdf-schema#comment> ?comment .
FILTER regex(str(?unit),
\"
"""
+
string
+
"""
\"
,
"
i
"
)
FILTER regex(str(?unit),
\"
"""
+
string
+
"""
\"
,
"
i
"
)
} LIMIT 10
"""
} LIMIT 10
OFFSET
"""
+
str
(
offset
)
qres
=
g
.
query
(
l_query
)
qres
=
g
.
query
(
l_query
)
units
=
list
()
for
row
in
qres
:
units
.
append
({
"
symbol
"
:
str
(
row
.
symbol
),
"
name
"
:
str
(
row
.
name
),
"
comment
"
:
str
(
row
.
comment
)})
return
units
else
:
return
None
def
get_uri
(
name
):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9]+$
'
,
name
)):
uri_query
=
"""
SELECT ?uri
WHERE {
?uri <http://www.w3.org/2000/01/rdf-schema#label> ?o .
FILTER (str(?o)=
\"
"""
+
name
+
"""
\"
)
} LIMIT 1
"""
qres
=
g
.
query
(
uri_query
)
for
row
in
qres
:
for
row
in
qres
:
print
(
f
"
{
row
.
symbol
}
|
{
row
.
name
}
|
{
row
.
comment
}
"
)
return
{
"
URI
"
:
row
.
uri
}
else
:
else
:
return
'
not alphanumeric
'
return
None
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
fda-units-service/requirements.txt
+
1
−
1
View file @
e42af082
...
@@ -3,4 +3,4 @@ flasgger==0.9.5
...
@@ -3,4 +3,4 @@ flasgger==0.9.5
py-eureka-client==0.9.1
py-eureka-client==0.9.1
docker==5.0.0
docker==5.0.0
gevent==21.8.0
gevent==21.8.0
rdflib==6.0.
1
rdflib==6.0.
2
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