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
22 import Data.Either (Either(..))
24 import Gargantext.API.Admin.Orchestrator.Types (ExternalAPIs(..), externalAPIs)
25 import Gargantext.Core (Lang(..))
26 import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..))
27 import Gargantext.Prelude
28 import qualified Gargantext.Core.Text.Corpus.API.Arxiv as Arxiv
29 import qualified Gargantext.Core.Text.Corpus.API.Hal as HAL
30 import qualified Gargantext.Core.Text.Corpus.API.Isidore as ISIDORE
31 import qualified Gargantext.Core.Text.Corpus.API.Istex as ISTEX
32 import qualified Gargantext.Core.Text.Corpus.API.Pubmed as PUBMED
33 import Servant.Client (ClientError)
35 -- | Get External API metadata main function
40 -- -> IO [HyperdataDocument]
41 -> IO (Either ClientError (Maybe Integer, ConduitT () HyperdataDocument IO ()))
42 get PubMed _la q limit = PUBMED.get q limit
43 --docs <- PUBMED.get q default_limit -- EN only by default
44 --pure (Just $ fromIntegral $ length docs, yieldMany docs)
45 get Arxiv la q limit = Arxiv.get la q (fromIntegral <$> limit)
46 get HAL la q limit = HAL.getC la q limit
47 get IsTex la q limit = do
48 docs <- ISTEX.get la q limit
49 pure $ Right (Just $ fromIntegral $ length docs, yieldMany docs)
50 get Isidore la q limit = do
51 docs <- ISIDORE.get la (fromIntegral <$> limit) (Just q) Nothing
52 pure $ Right (Just $ fromIntegral $ length docs, yieldMany docs)
53 get _ _ _ _ = undefined
55 -- | Some Sugar for the documentation
56 type Query = PUBMED.Query
57 type Limit = PUBMED.Limit