2 Module : Gargantext.Core.Text.Corpus.API
3 Description : All crawlers of Gargantext in one file.
4 Copyright : (c) CNRS, 2017
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 module Gargantext.Core.Text.Corpus.API
21 import Data.Either (Either(..))
23 import Gargantext.API.Admin.Orchestrator.Types (ExternalAPIs(..), externalAPIs)
24 import Gargantext.Core (Lang(..))
25 import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..))
26 import Gargantext.Prelude
27 import qualified Gargantext.Core.Text.Corpus.API.Arxiv as Arxiv
28 import qualified Gargantext.Core.Text.Corpus.API.Hal as HAL
29 import qualified Gargantext.Core.Text.Corpus.API.Isidore as ISIDORE
30 import qualified Gargantext.Core.Text.Corpus.API.Istex as ISTEX
31 import qualified Gargantext.Core.Text.Corpus.API.Pubmed as PUBMED
32 import Servant.Client (ClientError)
34 -- | Get External API metadata main function
39 -- -> IO [HyperdataDocument]
40 -> IO (Either ClientError (Maybe Integer, ConduitT () HyperdataDocument IO ()))
41 get PubMed { mAPIKey = mAPIKey } _la q limit = PUBMED.get mAPIKey q limit
42 --docs <- PUBMED.get q default_limit -- EN only by default
43 --pure (Just $ fromIntegral $ length docs, yieldMany docs)
44 get Arxiv la q limit = Arxiv.get la q (fromIntegral <$> limit)
45 get HAL la q limit = HAL.getC la q limit
46 get IsTex la q limit = do
47 docs <- ISTEX.get la q limit
48 pure $ Right (Just $ fromIntegral $ length docs, yieldMany docs)
49 get Isidore la q limit = do
50 docs <- ISIDORE.get la (fromIntegral <$> limit) (Just q) Nothing
51 pure $ Right (Just $ fromIntegral $ length docs, yieldMany docs)
52 get externalApi _ _ _ = panic $ "[G.C.T.Corpus.API] This options are note taken into account: " <> (cs $ show externalApi)
54 -- | Some Sugar for the documentation
55 type Query = PUBMED.Query
56 type Limit = PUBMED.Limit