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
c8370f69
Commit
c8370f69
authored
Apr 15, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Missing file.
parent
3f46358d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
Main.hs
bin/gargantext-phylo/Main.hs
+71
-0
No files found.
bin/gargantext-phylo/Main.hs
0 → 100644
View file @
c8370f69
{-|
Module : Main.hs
Description : Gargantext starter binary with Phylo
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Phylo binaries
-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Strict #-}
module
Main
where
import
Data.Aeson
import
Data.ByteString.Lazy
(
writeFile
)
import
Data.Text
(
Text
)
import
GHC.Generics
import
Gargantext.Prelude
import
Gargantext.Text.List.CSV
(
csvGraphTermList
)
import
Gargantext.Text.Parsers.CSV
(
readCsv
,
csv_title
,
csv_abstract
,
csv_publication_year
)
import
Gargantext.Text.Terms.WithList
import
System.Environment
import
qualified
Data.Map
as
DM
import
qualified
Data.Vector
as
DV
------------------------------------------------------------------------
-- Format to produce the Phylo
data
TextsByYear
=
TextsByYear
{
year
::
Int
,
texts
::
[[
Text
]]
}
deriving
(
Show
,
Generic
)
instance
ToJSON
TextsByYear
------------------------------------------------------------------------
filterTerms
::
Patterns
->
(
a
,
[
Text
])
->
(
a
,
[[
Text
]])
filterTerms
patterns
(
year'
,
docs
)
=
(
year'
,
map
(
termsInText
patterns
)
docs
)
where
termsInText
::
Patterns
->
Text
->
[
Text
]
termsInText
pats
txt
=
extractTermsWithList'
pats
txt
main
::
IO
()
main
=
do
[
corpusFile
,
termListFile
,
outputFile
]
<-
getArgs
corpus
<-
DM
.
fromListWith
(
<>
)
.
DV
.
toList
.
DV
.
map
(
\
n
->
(
csv_publication_year
n
,
[(
csv_title
n
)
<>
" "
<>
(
csv_abstract
n
)]))
.
snd
<$>
readCsv
corpusFile
termList
<-
csvGraphTermList
termListFile
putStrLn
$
show
$
length
termList
let
patterns
=
buildPatterns
termList
let
corpusParsed
=
map
(
(
\
(
y
,
t
)
->
TextsByYear
y
t
)
.
filterTerms
patterns
)
(
DM
.
toList
corpus
)
-- TODO Phylo here
writeFile
outputFile
$
encode
corpusParsed
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