Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
6296b828
Unverified
Commit
6296b828
authored
Jul 04, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mapConcurrentlyChunked
parent
65281c78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
Main.hs
bin/gargantext-cli/Main.hs
+14
-7
package.yaml
package.yaml
+1
-0
No files found.
bin/gargantext-cli/Main.hs
View file @
6296b828
...
...
@@ -32,10 +32,13 @@ import qualified Data.IntMap as DM
import
Data.Map
(
Map
)
import
Data.Text
(
Text
)
import
Data.List
(
cycle
)
import
Data.List
(
cycle
,
concat
)
import
Data.List.Split
(
chunksOf
)
import
System.IO
(
hPutStr
,
hFlush
,
stderr
)
import
System.Environment
import
Control.Concurrent.Async
as
CCA
(
mapConcurrently
)
import
Control.Concurrent
(
getNumCapabilities
)
import
Prelude
((
>>
))
import
Gargantext.Prelude
import
Gargantext.Core
...
...
@@ -58,18 +61,22 @@ mapMP f xs = do
liftIO
$
hFlush
stderr
f
x
mapConcurrentlyChunked
::
(
a
->
IO
b
)
->
[
a
]
->
IO
[
b
]
mapConcurrentlyChunked
f
ts
=
do
n
<-
getNumCapabilities
concat
<$>
mapConcurrently
(
mapM
f
)
(
chunksOf
n
ts
)
filterTermsAndCooc
::
TermType
Lang
->
(
Int
,
[
Text
])
->
IO
(
Map
(
Terms
,
Terms
)
Coocs
)
filterTermsAndCooc
patterns
(
year
,
ts
)
=
do
putStrLn
$
"start filterTermsAndCooc "
<>
show
year
r
<-
coocOn
identity
<$>
mapM
(
terms
patterns
)
ts
putStrLn
$
"stop filterTermsAndCooc "
<>
show
year
log
"start"
r
<-
coocOn
identity
<$>
mapM
(
\
x
->
{-log "work" >>-}
terms
patterns
x
)
ts
log
"stop"
pure
r
where
log
m
=
putStrLn
$
"filterTermsAndCooc: "
<>
m
<>
" "
<>
show
year
--main :: IO [()]
main
=
do
...
...
@@ -92,6 +99,6 @@ main = do
let
corpus'
=
DMaybe
.
catMaybes
$
map
(
\
k
->
DM
.
lookup
k
corpus
)
years
r
<-
mapConcurrently
(
filterTermsAndCooc
patterns
)
(
zip
years
corpus'
)
r
<-
mapConcurrently
Chunked
(
filterTermsAndCooc
patterns
)
(
zip
years
corpus'
)
putStrLn
$
show
r
--writeFile outputFile cooc
package.yaml
View file @
6296b828
...
...
@@ -168,6 +168,7 @@ executables:
-
cassava
-
ini
-
optparse-generic
-
split
-
unordered-containers
-
full-text-search
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment