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 #-}
12 {-# LANGUAGE OverloadedStrings #-}
14 module Gargantext.Ext.IMT where
16 import Gargantext.Prelude
17 import Data.Text (Text, splitOn)
20 import qualified Data.Set as S
21 import qualified Data.List as DL
22 import qualified Data.Vector as DV
23 import qualified Data.Map as M
25 import Gargantext.Text.Metrics.Freq as F
26 import Gargantext.Text.Parsers.CSV as CSV
28 data School = School { school_shortName :: Text
29 , school_longName :: Text
31 } deriving (Show, Read, Eq)
35 ("Mines Albi-Carmaux")
36 ("Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux")
40 ("EMA - École des Mines d'Alès")
44 ("Mines Douai EMD - École des Mines de Douai")
48 ("Mines Lille - École des Mines de Lille")
56 ("Mines Nantes - Mines Nantes")
64 ("IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire")
67 ("Mines Saint-Étienne")
68 ("Mines Saint-Étienne MSE - École des Mines de Saint-Étienne")
71 ("Télécom École de Management")
72 ("TEM - Télécom Ecole de Management")
75 ("IMT Business School")
76 ("IMT Business School")
84 ("TSP - Télécom SudParis")
96 ("MINES ParisTech - École nationale supérieure des mines de Paris")
100 mapIdSchool :: Map Text Text
101 mapIdSchool = M.fromList $ Gargantext.Prelude.map (\(School n _ i) -> (i,n)) schools
103 hal_data :: IO (DV.Vector CsvHal)
104 hal_data = snd <$> CSV.readHal "doc/corpus_imt/Gargantext_Corpus.csv"
107 names = S.fromList $ Gargantext.Prelude.map (\s -> school_id s) schools
109 toSchoolName :: Text -> Text
110 toSchoolName t = case M.lookup t mapIdSchool of
114 publisBySchool :: DV.Vector CsvHal -> [(Maybe Text, Int)]
115 publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSchool, n))
116 $ DL.filter (\i -> S.member (fst i) names)
123 $ DV.map (\n -> splitOn ( ", ") (csvHal_instStructId_i n) )
124 $ DV.filter (\n -> csvHal_publication_year n == 2017) hal_data'