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
669b56e6
Commit
669b56e6
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add script to split train and test coming from prodigy
parent
1c0964af
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/ML/split.hs
+33
-0
33 additions, 0 deletions
scripts/ML/split.hs
with
33 additions
and
0 deletions
scripts/ML/split.hs
0 → 100755
+
33
−
0
View file @
669b56e6
#!/
usr
/
bin
/
env
-
S
runhaskell
--ghc-arg="-Wall" --ghc-arg="-i lib" --ghc-arg="-fprint-potential-instances"
import
Data.Text
as
Text
(
Text
)
import
Data.Text.IO
as
Text
(
getContents
,
writeFile
)
import
System.Environment
(
getArgs
)
import
System.Script
(
syntax
,
try
)
import
Text.Filter
(
Editable
(
..
))
import
Text.Read
(
readEither
)
parseRatio
::
String
->
Either
String
Float
parseRatio
input
=
asFloat
>>=
checkBounds
where
checkBounds
float
|
float
>=
0
&&
float
<
1
=
pure
float
|
otherwise
=
Left
"Ratio must represent a number between 0 and 1"
asFloat
=
case
reverse
input
of
'%'
:
f
->
(
/
100
)
<$>
readEither
(
reverse
f
)
_
->
readEither
input
split
::
Float
->
[
Text
]
->
([
Text
],
[
Text
])
split
ratio
texts
=
splitAt
cutLine
texts
where
cutLine
=
round
.
(
ratio
*
)
.
fromIntegral
$
length
texts
main
::
IO
()
main
=
getArgs
>>=
run
where
run
[
trainRatio
,
trainPath
,
testPath
]
=
do
ratio
<-
try
(
pure
$
parseRatio
trainRatio
)
(
train
,
test
)
<-
split
ratio
.
enter
<$>
Text
.
getContents
Text
.
writeFile
trainPath
$
leave
train
Text
.
writeFile
testPath
$
leave
test
run
_
=
syntax
"TRAIN_RATIO TRAIN_PATH TEST_PATH"
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