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
717f2f25
Commit
717f2f25
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.lis-lab.fr/franck.dary/macaon_data
parents
5b6f9194
cd9d2a56
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/compileCrossValid.py
+59
-0
59 additions, 0 deletions
scripts/compileCrossValid.py
with
59 additions
and
0 deletions
scripts/compileCrossValid.py
0 → 100755
+
59
−
0
View file @
717f2f25
#! /usr/bin/env python3
import
sys
import
os
################################################################################
def
printUsageAndExit
()
:
print
(
"
USAGE : %s bin/ predOutputDir/ goldOutputDir/
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
exit
(
1
)
################################################################################
def
getModelModelIndexFilename
(
d
,
f
)
:
model
=
"
.
"
.
join
(
d
[
0
].
split
(
'
.
'
)[:
-
1
]).
split
(
'
/
'
)[
-
1
]
modelIndex
=
int
(
model
.
split
(
'
_
'
)[
-
1
])
model
=
"
_
"
.
join
(
model
.
split
(
'
_
'
)[:
-
1
])
filename
=
d
[
0
]
+
"
/
"
+
f
return
model
,
modelIndex
,
filename
################################################################################
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
!=
4
:
printUsageAndExit
()
binDir
=
sys
.
argv
[
1
]
outputDir
=
sys
.
argv
[
2
]
goldOutputDir
=
sys
.
argv
[
3
]
filesByModel
=
{}
for
d
in
os
.
walk
(
binDir
)
:
for
f
in
d
[
2
]
:
if
"
predicted_eval
"
in
f
:
model
,
index
,
filename
=
getModelModelIndexFilename
(
d
,
f
)
if
model
not
in
filesByModel
:
filesByModel
[
model
]
=
[]
while
len
(
filesByModel
[
model
])
<=
index
:
filesByModel
[
model
].
append
([
""
,
""
])
filesByModel
[
model
][
index
][
0
]
=
filename
if
"
test.conllu
"
in
f
:
model
,
index
,
filename
=
getModelModelIndexFilename
(
d
,
f
)
if
model
not
in
filesByModel
:
filesByModel
[
model
]
=
[]
while
len
(
filesByModel
[
model
])
<=
index
:
filesByModel
[
model
].
append
([
""
,
""
])
filesByModel
[
model
][
index
][
1
]
=
filename
with
open
(
goldOutputDir
+
"
/corpus.conllu
"
,
"
w
"
)
as
out
:
for
f
in
filesByModel
[
list
(
filesByModel
.
keys
())[
0
]]
:
for
line
in
open
(
f
[
1
],
"
r
"
)
:
print
(
line
,
end
=
""
,
file
=
out
)
for
model
in
filesByModel
:
outDir
=
outputDir
+
"
/
"
+
model
os
.
makedirs
(
outDir
,
exist_ok
=
True
)
with
open
(
outDir
+
"
/corpus.conllu
"
,
"
w
"
)
as
out
:
for
f
in
filesByModel
[
model
]
:
for
line
in
open
(
f
[
0
],
"
r
"
)
:
print
(
line
,
end
=
""
,
file
=
out
)
################################################################################
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