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 { school_shortName = "Mines Albi-Carmaux"
37 , school_longName = "Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux"
38 , school_id = "469216" }
40 { school_shortName = "Mines Alès"
41 , school_longName = "EMA - École des Mines d'Alès"
42 , school_id = "6279" }
44 { school_shortName = "Mines Douai"
45 , school_longName = "Mines Douai EMD - École des Mines de Douai"
46 , school_id = "224096" }
48 { school_shortName = "Mines Lille"
49 , school_longName = "Mines Lille - École des Mines de Lille"
50 , school_id = "144103" }
52 { school_shortName = "IMT Lille Douai"
53 , school_longName = "IMT Lille Douai"
54 , school_id = "497330" }
56 { school_shortName = "Mines Nantes"
57 , school_longName = "Mines Nantes - Mines Nantes"
58 , school_id = "84538" }
60 { school_shortName = "Télécom Bretagne"
61 , school_longName = "Télécom Bretagne"
62 , school_id = "301262" }
64 { school_shortName = "IMT Atlantique"
65 , school_longName = "IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire"
66 , school_id = "481355" }
68 { school_shortName = "Mines Saint-Étienne"
69 , school_longName = "Mines Saint-Étienne MSE - École des Mines de Saint-Étienne"
70 , school_id = "29212" }
72 { school_shortName = "Télécom École de Management"
73 , school_longName = "TEM - Télécom Ecole de Management"
74 , school_id = "301442" }
76 { school_shortName = "IMT Business School"
77 , school_longName = "IMT Business School"
78 , school_id = "542824" }
80 { school_shortName = "Télécom ParisTech"
81 , school_longName = "Télécom ParisTech"
82 , school_id = "300362" }
84 { school_shortName = "Télécom SudParis"
85 , school_longName = "TSP - Télécom SudParis"
86 , school_id = "352124" }
88 { school_shortName = "ARMINES"
89 , school_longName = "ARMINES"
90 , school_id = "300362" }
92 { school_shortName = "Eurecom"
93 , school_longName = "Eurecom"
94 , school_id = "421532" }
96 { school_shortName = "Mines ParisTech"
97 , school_longName = "MINES ParisTech - École nationale supérieure des mines de Paris"
98 , school_id = "301492" }
101 mapIdSchool :: Map Text Text
102 mapIdSchool = M.fromList $ Gargantext.Prelude.map
103 (\(School { school_shortName, school_id }) -> (school_id, school_shortName)) schools
105 hal_data :: IO (Either Prelude.String (DV.Vector CsvHal))
107 r <- CSV.readCsvHal "doc/corpus_imt/Gargantext_Corpus.csv"
111 names = S.fromList $ Gargantext.Prelude.map (\s -> school_id s) schools
113 toSchoolName :: Text -> Text
114 toSchoolName t = case M.lookup t mapIdSchool of
118 publisBySchool :: DV.Vector CsvHal -> [(Maybe Text, Int)]
119 publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSchool, n))
120 $ DL.filter (\i -> S.member (fst i) names)
127 $ DV.map (\n -> splitOn ( ", ") (csvHal_instStructId_i n) )
128 $ DV.filter (\n -> csvHal_publication_year n == 2017) hal_data'