Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schaertl_andreas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
supervision
schaertl_andreas
Commits
4506a587
Commit
4506a587
authored
4 years ago
by
Andreas Schärtl
Browse files
Options
Downloads
Patches
Plain Diff
used predicates: add seperator script
parent
8963fc33
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
experimental/ulo/seperate.py
+58
-0
58 additions, 0 deletions
experimental/ulo/seperate.py
with
58 additions
and
0 deletions
experimental/ulo/seperate.py
0 → 100755
+
58
−
0
View file @
4506a587
#! /usr/bin/env python3
#
# generate-table.py
#
# Given CSV data passed on stdin with two columns (number of
# occurences, URI), split up the lines in those that have at least one
# occurence and those that do not.
#
from
typing
import
Tuple
import
csv
import
sys
def
shorten_predicate
(
uri
:
str
)
->
str
:
ULO_NAMESPACE
=
'
https://mathhub.info/ulo#
'
DCTERMS_NAMESPACE
=
'
http://purl.org/dc/terms/
'
uri
=
uri
.
replace
(
ULO_NAMESPACE
,
'
ulo:
'
)
uri
=
uri
.
replace
(
DCTERMS_NAMESPACE
,
'
dcterms:
'
)
return
uri
def
main
():
occupied
=
[]
unoccupied
=
[]
for
row
in
csv
.
reader
(
sys
.
stdin
):
if
row
:
predicate
=
shorten_predicate
(
row
[
1
])
occurence
=
int
(
row
[
0
])
if
occurence
==
0
:
unoccupied
.
append
(
predicate
)
else
:
occupied
.
append
(
predicate
)
print
(
'
--------------- OCCUPIED ---------------
'
)
for
pred
in
occupied
:
print
(
pred
)
print
(
'
\n
------------ UNOCCUPIED ------------
'
)
for
pred
in
unoccupied
:
print
(
pred
)
print
(
'
\n
------------ STATS ------------
'
)
print
(
'
#occupied %d
'
%
len
(
occupied
))
print
(
'
#unoccupied %d
'
%
len
(
unoccupied
))
if
__name__
==
'
__main__
'
:
try
:
main
()
except
(
KeyboardInterrupt
,
SystemExit
,
BrokenPipeError
):
pass
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