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
86423b95
Commit
86423b95
authored
3 years ago
by
Cornelia Michlits
Browse files
Options
Downloads
Patches
Plain Diff
#104 add list.py
parent
0db3fef5
No related branches found
No related tags found
4 merge requests
!81
New stable release
,
!43
Merge dev to master
,
!33
Draft: merge dev to master
,
!32
Add units-service to dev
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fda-units-service/list.py
+32
-0
32 additions, 0 deletions
fda-units-service/list.py
with
32 additions
and
0 deletions
fda-units-service/list.py
0 → 100644
+
32
−
0
View file @
86423b95
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 4 11:37:19 2021
@author: Cornelia Michlits
"""
import
rdflib
import
re
g
=
rdflib
.
Graph
()
g
.
namespace_manager
.
bind
(
'
om
'
,
'
http://www.ontology-of-units-of-measure.org/resource/om-2/
'
)
g
.
parse
(
'
onto/om-2.ttl
'
,
format
=
'
turtle
'
)
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#
'
)
def
list_units
(
string
):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9]+$
'
,
string
)):
l_query
=
"""
SELECT ?symbol ?name ?comment
WHERE {
?unit om:symbol ?symbol .
?unit <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?unit <http://www.w3.org/2000/01/rdf-schema#comment> ?comment .
FILTER regex(str(?unit),
\"
"""
+
string
+
"""
\"
,
"
i
"
)
} LIMIT 10
"""
qres
=
g
.
query
(
l_query
)
for
row
in
qres
:
print
(
f
"
{
row
.
symbol
}
|
{
row
.
name
}
|
{
row
.
comment
}
"
)
else
:
return
'
not alphanumeric
'
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Cornelia Michlits
@cornelia.michlits
mentioned in commit
163dafae
·
3 years ago
mentioned in commit
163dafae
mentioned in commit 163dafae5a21e37d8c60c78737db88bc2d5963c7
Toggle commit list
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