Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
outillage
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Alice Brenon
outillage
Commits
cbb53ca3
Commit
cbb53ca3
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add a script to retrieve a Simple train set from a Multi one
parent
7ccb5f7e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/ML/Corpus.py
+3
-2
3 additions, 2 deletions
scripts/ML/Corpus.py
scripts/ML/simpleTrainOfMulti.py
+26
-0
26 additions, 0 deletions
scripts/ML/simpleTrainOfMulti.py
with
29 additions
and
2 deletions
scripts/ML/Corpus.py
+
3
−
2
View file @
cbb53ca3
...
@@ -57,14 +57,15 @@ class TSVIndexed(Corpus):
...
@@ -57,14 +57,15 @@ class TSVIndexed(Corpus):
d
[
self
.
column_name
]
=
self
.
content
(
key
,
row
).
strip
()
+
'
\n
'
d
[
self
.
column_name
]
=
self
.
content
(
key
,
row
).
strip
()
+
'
\n
'
return
d
return
d
def
get_all
(
self
,
projector
=
None
):
def
get_all
(
self
,
projector
=
None
,
where
=
None
):
if
projector
is
None
:
if
projector
is
None
:
projector
=
self
.
full
projector
=
self
.
full
elif
type
(
projector
)
==
str
and
projector
in
self
.
projectors
:
elif
type
(
projector
)
==
str
and
projector
in
self
.
projectors
:
projector
=
self
.
__getattribute__
(
projector
)
projector
=
self
.
__getattribute__
(
projector
)
self
.
load
()
self
.
load
()
for
row
in
self
.
data
.
iterrows
():
for
row
in
self
.
data
.
iterrows
():
yield
projector
(
*
row
)
if
where
is
None
or
where
(
*
row
):
yield
projector
(
*
row
)
class
SelfContained
(
TSVIndexed
):
class
SelfContained
(
TSVIndexed
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
scripts/ML/simpleTrainOfMulti.py
0 → 100755
+
26
−
0
View file @
cbb53ca3
#!/usr/bin/env python3
from
Corpus
import
Directory
,
SelfContained
from
GEODE
import
fromKey
,
toKey
import
GEODE.discursive
as
discursive
from
prodigyAcceptedJSONLToTSV
import
acceptedToTSV
from
sys
import
argv
def
isAccepted
(
key
,
row
):
return
row
[
'
answer
'
]
==
'
accept
'
def
withLabel
(
corpus
,
label
):
return
lambda
key
,
row
:
dict
(
**
corpus
.
full
(
key
,
row
)
,
paragraphFunction
=
label
)
def
simpleTrainOfMulti
(
multiDirectory
,
outputTSV
):
annotations
=
[]
for
className
in
discursive
.
functions
:
corpus
=
Directory
(
multiDirectory
,
tsv_filename
=
className
)
p
=
withLabel
(
corpus
,
className
)
annotations
+=
list
(
corpus
.
get_all
(
projector
=
p
,
where
=
isAccepted
))
output
=
SelfContained
(
outputTSV
)
output
.
save
(
sorted
(
annotations
,
key
=
toKey
))
if
__name__
==
'
__main__
'
:
simpleTrainOfMulti
(
argv
[
1
],
argv
[
2
])
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