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
63c08d18
Commit
63c08d18
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add script to make output from TXM useable
parent
34835a05
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/textometry/scoresByDomain.hs
+50
-0
50 additions, 0 deletions
scripts/textometry/scoresByDomain.hs
with
50 additions
and
0 deletions
scripts/textometry/scoresByDomain.hs
0 → 100755
+
50
−
0
View file @
63c08d18
#!/
usr
/
bin
/
env
-
S
runhaskell
--ghc-arg="-Wall" --ghc-arg="-i lib"
{-# LANGUAGE OverloadedStrings #-}
import
Data.Text
as
Text
(
Text
,
cons
,
drop
,
dropEnd
,
intercalate
,
isPrefixOf
,
length
,
lines
,
replace
,
snoc
,
splitOn
)
import
Data.Text.IO
as
Text
(
getLine
,
interact
,
putStrLn
)
import
System.Exit
(
die
)
data
ColumnSelector
=
ColumnSelector
{
position
::
Int
,
name
::
Text
}
deriving
Show
newtype
Header
=
Header
[
ColumnSelector
]
deriving
Show
getColumns
::
Text
->
[
Text
]
getColumns
=
splitOn
"
\t
"
getHeader
::
[
Text
]
->
IO
Header
getHeader
[]
=
die
"no columns"
getHeader
(
first
:
otherColumns
)
=
pure
$
Header
(
ColumnSelector
0
first
:
foldr
keepScores
[]
(
zip
[
1
..
]
otherColumns
))
where
keepScores
(
position
,
name
)
tmp
|
score
`
isPrefixOf
`
name
=
ColumnSelector
{
position
,
name
=
Text
.
drop
(
Text
.
length
score
)
$
dropEnd
1
name
}
:
tmp
|
otherwise
=
tmp
score
=
"score_:"
toTsv
::
[
Text
]
->
Text
toTsv
[]
=
""
toTsv
(
first
:
otherColumns
)
=
intercalate
"
\t
"
(
escape
first
:
otherColumns
)
where
escape
s
=
'"'
`
cons
`
replace
"
\"
"
"
\"\"
"
s
`
snoc
`
'"'
filterLine
::
[
Int
]
->
Text
->
Text
filterLine
positions
=
toTsv
.
extract
.
getColumns
where
extract
columns
=
(
columns
!!
)
<$>
positions
main
::
IO
()
main
=
do
Header
header
<-
getHeader
.
getColumns
=<<
Text
.
getLine
Text
.
putStrLn
.
toTsv
$
name
<$>
header
Text
.
interact
(
textUnlines
.
map
(
filterLine
$
position
<$>
header
)
.
Text
.
lines
)
where
textUnlines
=
Text
.
intercalate
"
\n
"
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