Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Macao Legacy
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MACAO
Macao Legacy
Commits
b3565f79
Commit
b3565f79
authored
May 24, 2024
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Code formatting
parent
b5c0e2fe
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Basilisk/MACAO/macao_12/extracted/extract.py
+8
-9
8 additions, 9 deletions
Basilisk/MACAO/macao_12/extracted/extract.py
Basilisk/MACAO/macao_12/extracted/extract_mosetp.py
+3
-1
3 additions, 1 deletion
Basilisk/MACAO/macao_12/extracted/extract_mosetp.py
with
11 additions
and
10 deletions
Basilisk/MACAO/macao_12/extracted/extract.py
+
8
−
9
View file @
b3565f79
...
...
@@ -12,8 +12,7 @@ import extract_mosetp
def
dump_graph
(
g
:
Graph
):
"""
Print all triples in the graph
"""
"""
Print all triples in the graph
"""
for
subj
,
pred
,
obj
in
g
:
print
(
subj
,
pred
,
obj
)
...
...
@@ -31,26 +30,26 @@ def export_graph(g: Graph):
imports
=
BNode
()
g
.
add
((
imports
,
RDF
.
type
,
OWL
.
Ontology
))
g
.
add
((
imports
,
OWL
.
imports
,
URIRef
(
NS
)))
g
.
serialize
(
OUT_FILE
,
'
turtle
'
,
base
=
NS
)
g
.
serialize
(
OUT_FILE
,
"
turtle
"
,
base
=
NS
)
print
(
f
"
Exported
{
len
(
g
)
}
triples to
{
OUT_FILE
}
.
"
)
def
ns_find
(
elem
:
etree
.
ElementBase
,
query
:
str
):
"""
Wrapper for lxml
'
s `find()` function that automatically uses the default
namespace for all unprefixed tag names.
"""
return
elem
.
find
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
def
ns_findall
(
elem
:
etree
.
ElementBase
,
query
:
str
):
"""
Wrapper for lxml
'
s `findall()` function that automatically uses the default
namespace for all unprefixed tag names.
"""
return
elem
.
findall
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
def
ns_localname
(
elem
:
etree
.
ElementBase
)
->
str
:
"""
Get an element
'
s local name, stripping the namespace.
"""
"""
Get an element
'
s local name, stripping the namespace.
"""
return
etree
.
QName
(
elem
).
localname
...
...
This diff is collapsed.
Click to expand it.
Basilisk/MACAO/macao_12/extracted/extract_mosetp.py
+
3
−
1
View file @
b3565f79
...
...
@@ -46,7 +46,9 @@ def parse_mosetp(graph: Graph, filepath: str, id: str):
regex
=
re
.
compile
(
r
'
.*new PageContenu\(
"
(.*)
"
,
"
(.*)
"
,
"
(.*)
"
,
""
\);
'
)
# The lines we need are fairly basic, grep is much faster
# than a Python HTML parser to filter them
cmd
=
subprocess
.
run
([
"
grep
"
,
"
new PageContenu(
"
,
filepath
],
capture_output
=
True
,
encoding
=
"
utf-8
"
)
cmd
=
subprocess
.
run
(
[
"
grep
"
,
"
new PageContenu(
"
,
filepath
],
capture_output
=
True
,
encoding
=
"
utf-8
"
)
if
cmd
.
returncode
==
0
:
# Match regex on each line
for
index
,
line
in
enumerate
(
cmd
.
stdout
.
splitlines
()):
...
...
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