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
edd4441a
Commit
edd4441a
authored
9 months ago
by
David Rouquet
Browse files
Options
Downloads
Patches
Plain Diff
1st attempt : clean up audio <script> tags
parent
c0b2b8df
No related branches found
No related tags found
2 merge requests
!4
Main
,
!3
Daxid html2md
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tetras_extraction/script/src/transform.py
+23
-0
23 additions, 0 deletions
tetras_extraction/script/src/transform.py
with
23 additions
and
0 deletions
tetras_extraction/script/src/transform.py
+
23
−
0
View file @
edd4441a
from
rdflib
import
OWL
,
RDF
,
Graph
from
lxml
import
html
from
common
import
*
...
...
@@ -29,6 +30,26 @@ def construct_while(g: Graph, query: str):
pass
# 1st attempt : clean up audio <script> tags
def
transform_html
(
graph
:
Graph
):
for
t
in
graph
.
triples
((
None
,
NS
[
'
description
'
],
None
)):
desc_str
=
t
[
2
]
tree
=
html
.
fragment_fromstring
(
desc_str
)
for
script
in
tree
.
findall
(
"
.//script
"
):
# `HtmlElement.drop_tree()` removes an element along with its
# children and text, however it has an interesting feature :
# the tail text is not removed, but instead joined to the previous
# sibling or parent automatically.
# This means that when we want to replace an element with string,
# we only need to prepend the string to the tail, and it will be
# inserted in the right place
script
.
tail
=
script
.
text
+
script
.
tail
script
.
drop_tree
()
pass
def
main
():
# Load graph
graph
=
Graph
()
...
...
@@ -36,6 +57,8 @@ def main():
graph
.
parse
(
RDF_SCHEMA_FILE
)
graph
.
parse
(
RDF_CONTENT_FILE
)
transform_html
(
graph
)
# Apply property 'subClassOf' transitively, except on the "fake" class
# hierarchy based on MacaoRoot
log
.
info
(
"
Adding transitive subclasses...
"
)
...
...
This diff is collapsed.
Click to expand it.
David Rouquet
@daxid
mentioned in issue
#26 (closed)
·
9 months ago
mentioned in issue
#26 (closed)
mentioned in issue #26
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