Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unlAnt
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
UNL
unlAnt
Commits
1333c7ad
Commit
1333c7ad
authored
3 years ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
Dot Graph Generation (simple graph)
parent
508975d3
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
asd/unl.py
+21
-1
21 additions, 1 deletion
asd/unl.py
parse.py
+6
-0
6 additions, 0 deletions
parse.py
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
with
31 additions
and
1 deletion
.gitignore
+
3
−
0
View file @
1333c7ad
...
...
@@ -4,3 +4,6 @@
devtemp*.py
.project
*.ttl.tbc
output/*
*env/*
This diff is collapsed.
Click to expand it.
asd/unl.py
+
21
−
1
View file @
1333c7ad
...
...
@@ -11,7 +11,7 @@
# Importing required modules
#==============================================================================
# None
import
pydot
#==============================================================================
...
...
@@ -42,6 +42,14 @@ class Graph:
res
+=
"
)
"
return
res
def
to_dot_graph
(
self
):
graph
=
pydot
.
Dot
(
"
My_Graph
"
,
graph_type
=
"
graph
"
,
bgcolor
=
"
yellow
"
)
for
link
in
self
.
link_list
:
graph
.
add_node
(
link
.
uw1
.
to_dot_node
())
graph
.
add_node
(
link
.
uw2
.
to_dot_node
())
graph
.
add_edge
(
link
.
to_dot_edge
())
return
graph
class
Link
:
"""
link := Link(relation, uw, uw)
"""
...
...
@@ -57,6 +65,12 @@ class Link:
res
+=
self
.
uw2
.
to_string
()
+
"
)
"
return
res
def
to_dot_edge
(
self
):
n1_name
=
self
.
uw1
.
to_dot_node
().
get_name
()
n2_name
=
self
.
uw2
.
to_dot_node
().
get_name
()
edge
=
pydot
.
Edge
(
n1_name
,
n2_name
,
color
=
"
blue
"
)
return
edge
class
Relation
:
"""
relation := Relation(id)
"""
...
...
@@ -89,6 +103,12 @@ class UniversalWord:
res
+=
"
.@
"
+
attr
.
to_string
()
return
res
def
to_dot_node
(
self
):
node_name
=
self
.
headword
.
to_string
()
# TODO: à revoir pour id unique
node_label
=
self
.
headword
.
to_string
()
node
=
pydot
.
Node
(
node_name
,
label
=
node_label
)
return
node
class
Headword
:
"""
headword := Headword(id)
"""
...
...
This diff is collapsed.
Click to expand it.
parse.py
+
6
−
0
View file @
1333c7ad
...
...
@@ -146,6 +146,12 @@ def main(argv):
unl
=
parse_unl
(
InputStream
(
unl_part
))
print
(
"
----- UNL string:
\n
"
+
unl
.
to_string
())
# -- Generate dot file
unl_dot_graph
=
unl
.
to_dot_graph
()
print
(
"
----- DOT string:
\n
"
+
unl_dot_graph
.
to_string
())
unl_dot_graph
.
write_raw
(
"
output/output_raw.dot
"
)
unl_dot_graph
.
write_png
(
"
output/output.png
"
)
if
__name__
==
'
__main__
'
:
main
(
sys
.
argv
)
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
0
View file @
1333c7ad
antlr4-python3-runtime
==4.9.3
pydot
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