2 Module : Gargantext.API
3 Description : Server API
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
11 {-# LANGUAGE NoImplicitPrelude #-}
13 module Gargantext.Ext.IMT where
15 import Gargantext.Prelude
16 import Data.Text (Text, pack, splitOn)
19 import qualified Data.Set as S
20 import qualified Data.List as DL
21 import qualified Data.Vector as DV
22 import qualified Data.Map as M
24 import Gargantext.Text.Metrics.Freq as F
25 import Gargantext.Text.Parsers.CSV as CSV
27 data School = School { school_shortName :: Text
28 , school_longName :: Text
30 } deriving (Show, Read, Eq)
34 (pack "Mines Albi-Carmaux")
35 (pack "Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux")
39 (pack "EMA - École des Mines d'Alès")
44 (pack "Mines Douai EMD - École des Mines de Douai")
49 (pack "Mines Nantes - Mines Nantes")
53 -- (pack "Mines ParisTech")
54 -- (pack "MINES ParisTech - École nationale supérieure des mines de Paris")
58 (pack "Mines Saint-Étienne")
59 (pack "Mines Saint-Étienne MSE - École des Mines de Saint-Étienne")
63 (pack "Télécom Bretagne")
64 (pack "Télécom Bretagne")
68 (pack "Télécom École de Management")
69 (pack "TEM - Télécom Ecole de Management")
73 (pack "Télécom ParisTech")
74 (pack "Télécom ParisTech")
78 (pack "Télécom SudParis")
79 (pack "TSP - Télécom SudParis")
83 (pack "IMT Atlantique")
84 (pack "IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire")
88 mapIdSchool :: Map Text Text
89 mapIdSchool = M.fromList $ Gargantext.Prelude.map (\(School n _ i) -> (i,n)) schools
91 hal_data :: IO (DV.Vector CsvHal)
92 hal_data = snd <$> CSV.readHal "doc/corpus_imt/Gargantext_Corpus.csv"
95 names = S.fromList $ Gargantext.Prelude.map (\s -> school_id s) schools
98 publisBySchool :: DV.Vector CsvHal -> [(Maybe Text, Int)]
99 publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSchool, n))
100 $ DL.filter (\i -> S.member (fst i) names)
107 $ DV.map (\n -> splitOn (pack ", ") (csvHal_instStructId_i n) )
108 $ DV.filter (\n -> csvHal_publication_year n == 2017) hal_data'