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
4cf05a96
Commit
4cf05a96
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add a script to make a JSONL corpus for prodigy out of paragraphs
parent
cb234457
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/ML/prodigy-corpus.hs
+34
-0
34 additions, 0 deletions
scripts/ML/prodigy-corpus.hs
with
34 additions
and
0 deletions
scripts/ML/prodigy-corpus.hs
0 → 100755
+
34
−
0
View file @
4cf05a96
#!/
usr
/
bin
/
env
-
S
runhaskell
--ghc-arg="-Wall" --ghc-arg="-i lib"
{-# LANGUAGE DeriveGeneric #-}
import
Data.Aeson
(
ToJSON
(
..
),
defaultOptions
,
encode
,
genericToEncoding
)
import
Data.ByteString.Lazy.Char8
as
ByteString
(
putStrLn
)
import
Data.Text
(
Text
)
import
Data.Text.IO
as
Text
(
readFile
)
import
GEODE.Metadata
(
readNamedTsv
)
import
GEODE.Metadata.File
(
relativePath
)
import
GEODE.Metadata.PrimaryKey.Paragraph
(
ParagraphPK
)
import
GHC.Generics
(
Generic
)
import
System.Environment
(
getArgs
)
import
System.FilePath
((
</>
))
import
System.Script
(
syntax
,
try
)
data
Paragraph
=
Paragraph
{
text
::
Text
,
meta
::
ParagraphPK
}
deriving
Generic
instance
ToJSON
Paragraph
where
toEncoding
=
genericToEncoding
defaultOptions
loadParagraph
::
FilePath
->
ParagraphPK
->
IO
Paragraph
loadParagraph
source
meta
=
do
text
<-
Text
.
readFile
(
source
</>
relativePath
meta
"txt"
)
pure
$
Paragraph
{
text
,
meta
}
main
::
IO
()
main
=
getArgs
>>=
run
where
run
[
inputMeta
,
source
]
=
try
(
readNamedTsv
inputMeta
)
>>=
mapM_
(
prodigyText
source
)
run
_
=
syntax
"INPUT_METADATA SOURCE_DIRECTORY"
prodigyText
source
pK
=
loadParagraph
source
pK
>>=
ByteString
.
putStrLn
.
encode
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