Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon_data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Franck Dary
macaon_data
Commits
258180d3
Commit
258180d3
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
conllu2latex now hides empty cells depending on strategy
parent
74e65fd4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/conllu2latex.py
+35
-14
35 additions, 14 deletions
scripts/conllu2latex.py
with
35 additions
and
14 deletions
scripts/conllu2latex.py
+
35
−
14
View file @
258180d3
...
...
@@ -95,7 +95,11 @@ def getLayout(sentence, text) :
################################################################################
def
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
nodes
,
reduce
,
breakSize
,
hsep
=
True
)
:
def
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
nodes
,
reduce
,
breakSize
,
mask
=
[
None
,
None
],
hsep
=
True
)
:
if
mask
[
0
]
not
in
[
None
,
"
incr
"
,
"
seq
"
]
:
print
(
"
ERROR : invalid mask
'
%s
'"
%
mask
,
file
=
sys
.
stderr
)
exit
(
1
)
maxNbLetters
=
45
...
...
@@ -123,6 +127,19 @@ def produceTabular(sentence, ranges, text, columns, nodes, reduce, breakSize, hs
else
:
value
=
sentence
[
j
][
i
]
value
=
value
.
replace
(
'
_
'
,
'
\_
'
)
valueEmpty
=
"
\
"
*
len
(
value
)
if
mask
[
0
]
==
"
seq
"
:
if
i
>
mask
[
1
][
0
]
:
value
=
valueEmpty
if
i
==
mask
[
1
][
0
]
and
j
>
mask
[
1
][
1
]
:
value
=
valueEmpty
if
mask
[
0
]
==
"
incr
"
:
if
columns
[
i
]
==
"
HEAD
"
and
int
(
value
)
>=
mask
[
1
][
1
]
:
value
=
valueEmpty
if
j
>
mask
[
1
][
1
]
:
value
=
valueEmpty
if
j
==
mask
[
1
][
1
]
and
i
>
mask
[
1
][
0
]
:
value
=
valueEmpty
values
=
value
.
split
(
'
|
'
)
for
k
in
range
(
len
(
values
))
:
...
...
@@ -191,10 +208,10 @@ def getNodes(firstNodeIndex, nbLines, nbCols) :
def
drawCenterRect
(
centerNode
)
:
lineConf
=
"
color=blue, dashed, opacity=0.4, line width=0.8mm
"
center1
=
"
($(%d.north e
a
st)
!0.5!(%d.north west
)$)
"
%
(
centerNode
-
1
,
centerNode
)
center2
=
"
($(%d.north east)
!0.5!(%d.north west
)$)
"
%
(
centerNode
,
centerNode
+
1
)
center3
=
"
($
%s-
(%d.
north)+(%d.south)$)
"
%
(
center2
,
centerNode
,
centerNode
)
center4
=
"
($
%s-
(%d.
north)+(%d.south)$)
"
%
(
center1
,
centerNode
,
centerNode
)
center1
=
"
($(%d.north
w
est)
-(0.1,0
)$)
"
%
centerNode
center2
=
"
($(%d.north east)
+(0.1,0
)$)
"
%
centerNode
center3
=
"
($(%d.
south east)+(0.1,0.0)-(0.0,0.04)$)
"
%
centerNode
center4
=
"
($(%d.
south west)-(0.1,0.0)-(0.0,0.04)$)
"
%
centerNode
print
(
"
\draw[%s] %s -- %s -- %s -- %s -- cycle;
"
%
(
lineConf
,
center1
,
center2
,
center3
,
center4
))
################################################################################
...
...
@@ -216,10 +233,10 @@ def drawTextAbove(node, txt) :
def
drawRectanglePalo
(
firstNodeIndex
,
nbLines
,
nbCols
)
:
centerNode
,
centerLine
,
centerLineEnd
,
bottomLine
,
bottomLineEnd
,
_
=
getNodes
(
firstNodeIndex
,
nbLines
,
nbCols
)
pt1
=
"
(%d.north west)
"
%
centerLine
pt2
=
"
($(%d.
north east)!0.5!(%d.north
west)$)
"
%
(
centerNode
-
1
,
center
Nod
e
)
pt3
=
"
($%s-(%d.north)+(%d.south)$)
"
%
(
pt2
,
centerNode
,
centerNode
)
pt4
=
"
($%s
-(%d.north)+(%d.south)$)
"
%
(
"
($(%d.north east)!0.5!(%d.north west)$)
"
%
(
centerNode
,
centerNode
+
1
)
,
centerNode
,
centerNode
)
pt5
=
"
($%s-(%d)+(%d)$)
"
%
(
pt4
,
centerLine
End
,
bottomLine
End
)
pt2
=
"
($
%s+
(%d.
east)-(%d.
west)$)
"
%
(
pt1
,
centerNode
-
1
,
center
Lin
e
)
pt3
=
"
($%s-(%d.north)+(%d.south)$)
"
%
(
pt2
,
centerNode
-
1
,
centerNode
-
1
)
pt4
=
"
($%s
+(%d.east)-(%d.west)$)
"
%
(
pt3
,
centerNode
,
centerNode
)
pt5
=
"
($%s-(%d)+(%d)$)
"
%
(
pt4
,
centerLine
,
bottomLine
)
pt6
=
"
($%s-(%d)+(%d)-(%d.north)+(%d.south)$)
"
%
(
pt1
,
centerLine
,
bottomLine
,
centerLine
,
centerLine
)
print
(
r
"
\begin{tikzpicture}[overlay]
"
)
...
...
@@ -316,17 +333,21 @@ def drawFeatures(sentence, ranges, text, columns) :
print
(
r
"
\tikzstyle{every picture}+=[remember picture,baseline]
"
)
print
(
r
"
\tikzstyle{every node}+=[inner sep=0pt,anchor=base]
"
)
nbLines
=
len
(
sentence
[
0
])
nbCols
=
len
(
sentence
)
center
=
(
nbLines
//
2
,
nbCols
//
2
)
print
(
r
"
\begin{figure}
"
)
print
(
"
\\
tabcolsep=0.10mm
"
)
print
(
r
"
\resizebox{\textwidth}{!}{
"
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
hsep
=
""
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
mask
=
(
"
seq
"
,
center
),
hsep
=
""
)
print
(
r
"
\quad
"
,
end
=
""
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
hsep
=
""
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
mask
=
(
"
seq
"
,
center
),
hsep
=
""
)
print
(
r
"
\quad
"
,
end
=
""
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
hsep
=
""
)
produceTabular
(
sentence
,
ranges
,
text
,
columns
,
True
,
True
,
"
0.1
"
,
mask
=
(
"
incr
"
,
center
),
hsep
=
""
)
print
(
""
)
nbLines
=
len
(
sentence
[
0
])
nbCols
=
len
(
sentence
)
drawRectanglePalo
(
1
,
nbLines
,
nbCols
)
drawRectangleFulo
(
nbLines
*
nbCols
+
1
,
nbLines
,
nbCols
)
drawRectanglePahi
(
2
*
nbLines
*
nbCols
+
1
,
nbLines
,
nbCols
)
...
...
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