2 Module : Gargantext.Text.Corpus.API.Pubmed
3 Description : Pubmed API connection
4 Copyright : (c) CNRS, 2017
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 module Gargantext.Text.Corpus.API.Pubmed
17 import Data.Text (Text)
18 import Gargantext.Prelude
19 import Gargantext.Core (Lang(..))
20 import Gargantext.Database.Admin.Types.Node (HyperdataDocument(..))
21 import qualified Data.Text as Text
23 import qualified PUBMED as PubMed
24 import qualified PUBMED.Parser as PubMedDoc
28 type Limit = PubMed.Limit
30 get :: Query -> Maybe Limit -> IO [HyperdataDocument]
31 get q l = either (\e -> panic $ "CRAWL: PubMed" <> e) (map (toDoc EN)) <$> PubMed.getMetadataWith q l
33 toDoc :: Lang -> PubMedDoc.PubMed -> HyperdataDocument
34 toDoc l (PubMedDoc.PubMed (PubMedDoc.PubMedArticle t j as aus)
35 (PubMedDoc.PubMedDate a y m d)
36 ) = HyperdataDocument (Just "PubMed")
47 (Just $ Text.pack $ show a)
48 (Just $ fromIntegral y)
54 (Just $ (Text.pack . show) l)
56 authors :: Maybe [PubMedDoc.Author] -> Maybe Text
57 authors aus' = case aus' of
59 Just au -> Just $ (Text.intercalate ", ") $ catMaybes $ map PubMedDoc.foreName au
61 abstract :: Maybe [Text] -> Maybe Text
62 abstract as' = fmap (Text.intercalate ", ") as'