Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Corpus Making Tool
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
corpus
Corpus Making Tool
Commits
96afc912
Commit
96afc912
authored
2 years ago
by
David Rouquet
Browse files
Options
Downloads
Patches
Plain Diff
add svg output
parent
864101f7
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
config.sample.ini
+1
-0
1 addition, 0 deletions
config.sample.ini
convert_text_to_amr.py
+19
-2
19 additions, 2 deletions
convert_text_to_amr.py
with
20 additions
and
2 deletions
config.sample.ini
+
1
−
0
View file @
96afc912
...
...
@@ -10,6 +10,7 @@ SENTENCE_SUFFIX = .sentence.txt
PENMAN_AMR_GRAPH_SUFFIX
=
.stog.amr.penman
DOT_AMR_GRAPH_SUFFIX
=
.stog.amr.dot
PNG_AMR_GRAPH_SUFFIX
=
.stog.amr.png
SVG_AMR_GRAPH_SUFFIX
=
.stog.amr.svg
AMR_RDF_SUFFIX
=
.stog.amr.nt
AMR_TTL_SUFFIX
=
.stog.amr.ttl
...
...
This diff is collapsed.
Click to expand it.
convert_text_to_amr.py
+
19
−
2
View file @
96afc912
...
...
@@ -44,6 +44,7 @@ SENTENCE_SUFFIX = config['PARAM']['SENTENCE_SUFFIX']
PENMAN_AMR_GRAPH_SUFFIX
=
config
[
'
PARAM
'
][
'
PENMAN_AMR_GRAPH_SUFFIX
'
]
DOT_AMR_GRAPH_SUFFIX
=
config
[
'
PARAM
'
][
'
DOT_AMR_GRAPH_SUFFIX
'
]
PNG_AMR_GRAPH_SUFFIX
=
config
[
'
PARAM
'
][
'
PNG_AMR_GRAPH_SUFFIX
'
]
SVG_AMR_GRAPH_SUFFIX
=
config
[
'
PARAM
'
][
'
SVG_AMR_GRAPH_SUFFIX
'
]
AMR_RDF_SUFFIX
=
config
[
'
PARAM
'
][
'
AMR_RDF_SUFFIX
'
]
AMR_TTL_SUFFIX
=
config
[
'
PARAM
'
][
'
AMR_TTL_SUFFIX
'
]
...
...
@@ -95,6 +96,11 @@ def get_png_amr_graph_output_filepath(data):
data_file_name
=
data
[
"
data_ref
"
]
+
PNG_AMR_GRAPH_SUFFIX
return
data_dir
+
data_file_name
def
get_svg_amr_graph_output_filepath
(
data
):
data_dir
=
get_output_data_dir
(
data
[
"
output_data_dir
"
])
data_file_name
=
data
[
"
data_ref
"
]
+
SVG_AMR_GRAPH_SUFFIX
return
data_dir
+
data_file_name
def
get_amr_rdf_triple_output_filepath
(
data
):
data_dir
=
get_output_data_dir
(
data
[
"
output_data_dir
"
])
data_file_name
=
data
[
"
data_ref
"
]
+
AMR_RDF_SUFFIX
...
...
@@ -238,19 +244,30 @@ def generate_dot_amr_graph(data):
graph
=
data
[
"
graph
"
]
try
:
# -- generating dot/png files using AMRLib and GraphViz
dot_fn
=
get_dot_amr_graph_output_filepath
(
data
)
# -- generating dot/png files using AMRLib and GraphViz
format
=
'
png
'
print
(
"
----- AMR Graph file (dot):
"
+
dot_fn
)
plot
=
AMRPlot
(
dot_fn
,
format
)
plot
.
build_from_graph
(
graph
)
plot
.
graph
.
render
()
render_fn
=
dot_fn
+
'
.
'
+
format
# -- renaming PNG file
good_png_fn
=
get_png_amr_graph_output_filepath
(
data
)
print
(
"
----- AMR Graph file (png):
"
+
good_png_fn
)
os
.
rename
(
render_fn
,
good_png_fn
)
# -- generating dot/svg files using AMRLib and GraphViz
format
=
'
svg
'
print
(
"
----- AMR Graph file (dot):
"
+
dot_fn
)
plot
=
AMRPlot
(
dot_fn
,
format
)
plot
.
build_from_graph
(
graph
)
plot
.
graph
.
render
()
render_fn
=
dot_fn
+
'
.
'
+
format
# -- renaming SVG file
good_svg_fn
=
get_svg_amr_graph_output_filepath
(
data
)
print
(
"
----- AMR Graph file (svg):
"
+
good_svg_fn
)
os
.
rename
(
render_fn
,
good_svg_fn
)
except
:
logger
.
warning
(
'
Exception when trying to plot
'
)
# -- TODO
traceback
.
print_exc
()
...
...
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