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
12 module Gargantext.Core.Ext.IMT where
14 import Data.Either (Either(..))
16 import Data.Text (Text, splitOn)
18 import qualified Data.Set as S
19 import qualified Data.List as DL
20 import qualified Data.Vector as DV
21 import qualified Data.Map as M
22 import qualified Prelude as Prelude
24 import Gargantext.Prelude
26 import Gargantext.Core.Text.Metrics.Utils as Utils
27 import Gargantext.Core.Text.Corpus.Parsers.CSV as CSV
29 data School = School { school_shortName :: Text
30 , school_longName :: Text
32 } deriving (Show, Read, Eq)
36 ("Mines Albi-Carmaux")
37 ("Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux")
41 ("EMA - École des Mines d'Alès")
45 ("Mines Douai EMD - École des Mines de Douai")
49 ("Mines Lille - École des Mines de Lille")
57 ("Mines Nantes - Mines Nantes")
65 ("IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire")
68 ("Mines Saint-Étienne")
69 ("Mines Saint-Étienne MSE - École des Mines de Saint-Étienne")
72 ("Télécom École de Management")
73 ("TEM - Télécom Ecole de Management")
76 ("IMT Business School")
77 ("IMT Business School")
85 ("TSP - Télécom SudParis")
97 ("MINES ParisTech - École nationale supérieure des mines de Paris")
101 mapIdSchool :: Map Text Text
102 mapIdSchool = M.fromList $ Gargantext.Prelude.map (\(School n _ i) -> (i,n)) schools
104 hal_data :: IO (Either Prelude.String (DV.Vector CsvHal))
106 r <- CSV.readCsvHal "doc/corpus_imt/Gargantext_Corpus.csv"
110 names = S.fromList $ Gargantext.Prelude.map (\s -> school_id s) schools
112 toSchoolName :: Text -> Text
113 toSchoolName t = case M.lookup t mapIdSchool of
117 publisBySchool :: DV.Vector CsvHal -> [(Maybe Text, Int)]
118 publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSchool, n))
119 $ DL.filter (\i -> S.member (fst i) names)
126 $ DV.map (\n -> splitOn ( ", ") (csvHal_instStructId_i n) )
127 $ DV.filter (\n -> csvHal_publication_year n == 2017) hal_data'