1 {-# LANGUAGE DeriveAnyClass #-}
4 Module : Gargantext.API
5 Description : Server API
6 Copyright : (c) CNRS, 2017-Present
7 License : AGPL + CECILL v3
8 Maintainer : team@gargantext.org
9 Stability : experimental
14 module Gargantext.Core.Ext.IMT where
16 import Data.Either (Either(..))
18 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
24 import qualified Prelude
26 import Data.Morpheus.Types (GQLType)
27 import GHC.Generics (Generic)
29 import Gargantext.Prelude
31 import Gargantext.Core.Text.Metrics.Utils as Utils
32 import Gargantext.Core.Text.Corpus.Parsers.CSV as CSV
34 data School = School { school_shortName :: Text
35 , school_longName :: Text
37 } deriving (Generic, GQLType, Show, Read, Eq)
42 { school_shortName = "ARMINES"
43 , school_longName = "ARMINES"
44 , school_id = "300104" }
46 { school_shortName = "Eurecom"
47 , school_longName = "Eurecom"
48 , school_id = "421532" }
50 { school_shortName = "IMT Atlantique"
51 , school_longName = "IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire"
52 , school_id = "481355" }
54 { school_shortName = "IMT Business School"
55 , school_longName = "IMT Business School"
56 , school_id = "542824" }
58 { school_shortName = "IMT Lille Douai"
59 , school_longName = "IMT Lille Douai"
60 , school_id = "497330" }
62 { school_shortName = "IP Paris - Institut Polytechnique de Paris"
63 , school_longName = "IP Paris - Institut Polytechnique de Paris"
64 , school_id = "563936" }
66 { school_shortName = "Mines Albi-Carmaux"
67 , school_longName = "Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux"
68 , school_id = "469216" }
70 { school_shortName = "Mines Alès"
71 , school_longName = "EMA - École des Mines d'Alès"
72 , school_id = "6279" }
74 { school_shortName = "Mines Douai"
75 , school_longName = "Mines Douai EMD - École des Mines de Douai"
76 , school_id = "224096" }
78 { school_shortName = "Mines Lille"
79 , school_longName = "Mines Lille - École des Mines de Lille"
80 , school_id = "144103" }
82 { school_shortName = "Mines Nantes"
83 , school_longName = "Mines Nantes - Mines Nantes"
84 , school_id = "84538" }
86 { school_shortName = "Mines ParisTech"
87 , school_longName = "MINES ParisTech - École nationale supérieure des mines de Paris"
88 , school_id = "301492" }
90 { school_shortName = "Mines Saint-Étienne"
91 , school_longName = "Mines Saint-Étienne MSE - École des Mines de Saint-Étienne"
92 , school_id = "29212" }
94 { school_shortName = "Télécom Bretagne"
95 , school_longName = "Télécom Bretagne"
96 , school_id = "301262" }
98 { school_shortName = "Télécom École de Management"
99 , school_longName = "TEM - Télécom Ecole de Management"
100 , school_id = "301442" }
102 { school_shortName = "Télécom ParisTech"
103 , school_longName = "Télécom ParisTech"
104 , school_id = "300362" }
106 { school_shortName = "Télécom SudParis"
107 , school_longName = "TSP - Télécom SudParis"
108 , school_id = "352124" }
111 mapIdSchool :: Map Text Text
112 mapIdSchool = M.fromList $ Gargantext.Prelude.map
113 (\(School { school_shortName, school_id }) -> (school_id, school_shortName)) schools
115 hal_data :: IO (Either Prelude.String (DV.Vector CsvHal))
117 r <- CSV.readCsvHal "doc/corpus_imt/Gargantext_Corpus.csv"
121 names = S.fromList $ Gargantext.Prelude.map (\s -> school_id s) schools
123 toSchoolName :: Text -> Text
124 toSchoolName t = case M.lookup t mapIdSchool of
128 publisBySchool :: DV.Vector CsvHal -> [(Maybe Text, Int)]
129 publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSchool, n))
130 $ DL.filter (\i -> S.member (fst i) names)
137 $ DV.map (\n -> splitOn ( ", ") (csvHal_instStructId_i n) )
138 $ DV.filter (\n -> csvHal_publication_year n == 2017) hal_data'