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
3de41e7a
Commit
3de41e7a
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
conllu2horizontal replace every number by 42 and every digit by 0
parent
42de4d6d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/conllu2horizontal.py
+19
-4
19 additions, 4 deletions
scripts/conllu2horizontal.py
with
19 additions
and
4 deletions
scripts/conllu2horizontal.py
+
19
−
4
View file @
3de41e7a
...
@@ -3,6 +3,15 @@
...
@@ -3,6 +3,15 @@
import
sys
import
sys
from
readMCD
import
readMCD
from
readMCD
import
readMCD
def
isNumber
(
s
)
:
hasDigit
=
False
for
c
in
s
:
if
c
.
isdigit
()
:
hasDigit
=
True
if
c
.
isalpha
()
:
return
False
return
hasDigit
def
printUsageAndExit
()
:
def
printUsageAndExit
()
:
print
(
"
USAGE : %s file.conllu (columnName | LETTERS)
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
print
(
"
USAGE : %s file.conllu (columnName | LETTERS)
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
@@ -36,7 +45,10 @@ if __name__ == "__main__" :
...
@@ -36,7 +45,10 @@ if __name__ == "__main__" :
print
(
"
ERROR : column %s not found in line
'
%s
'"
%
(
index
,
line
.
strip
()))
print
(
"
ERROR : column %s not found in line
'
%s
'"
%
(
index
,
line
.
strip
()))
exit
(
1
)
exit
(
1
)
print
(
splited
[
index
].
replace
(
"
"
,
"
◌
"
),
end
=
"
"
)
value
=
splited
[
index
].
replace
(
"
"
,
"
◌
"
)
if
isNumber
(
splited
[
index
].
replace
(
"
"
,
""
).
strip
())
:
value
=
42
print
(
value
,
end
=
"
"
)
else
:
else
:
for
line
in
open
(
sys
.
argv
[
1
],
"
r
"
)
:
for
line
in
open
(
sys
.
argv
[
1
],
"
r
"
)
:
if
line
.
startswith
(
"
#
"
)
:
if
line
.
startswith
(
"
#
"
)
:
...
@@ -45,6 +57,9 @@ if __name__ == "__main__" :
...
@@ -45,6 +57,9 @@ if __name__ == "__main__" :
col2index
,
index2col
=
readMCD
(
splited
[
-
1
].
strip
())
col2index
,
index2col
=
readMCD
(
splited
[
-
1
].
strip
())
splited
=
line
.
split
(
"
text =
"
)
splited
=
line
.
split
(
"
text =
"
)
if
len
(
splited
)
>
1
:
if
len
(
splited
)
>
1
:
text
=
splited
[
-
1
].
replace
(
"
\n
"
,
"
"
).
replace
(
"
"
,
"
◌
"
)
text
=
list
(
splited
[
-
1
].
replace
(
"
\n
"
,
"
"
).
replace
(
"
"
,
"
◌
"
))
print
(
"
"
.
join
(
list
(
text
)))
for
elem
in
text
:
if
isNumber
(
str
(
elem
))
:
elem
=
'
0
'
print
(
elem
,
end
=
"
"
)
print
(
""
)
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