Commit 82ffefa1 authored by Yoelis Acourt's avatar Yoelis Acourt

feat: add _hd_from_country to hyperdata

parent 13457ca8
...@@ -215,6 +215,7 @@ hyperdataDocumentFromSearxResult l (SearxResult { _sr_content, _sr_engine, _sr_p ...@@ -215,6 +215,7 @@ hyperdataDocumentFromSearxResult l (SearxResult { _sr_content, _sr_engine, _sr_p
, _hd_doi = Nothing , _hd_doi = Nothing
, _hd_url = Nothing , _hd_url = Nothing
, _hd_page = Nothing , _hd_page = Nothing
, _hd_from_country = Nothing
, _hd_title = Just _sr_title , _hd_title = Just _sr_title
, _hd_authors = Nothing , _hd_authors = Nothing
, _hd_institutes = Nothing , _hd_institutes = Nothing
......
...@@ -73,6 +73,7 @@ documentUpload nId doc = do ...@@ -73,6 +73,7 @@ documentUpload nId doc = do
, _hd_doi = Nothing , _hd_doi = Nothing
, _hd_url = Nothing , _hd_url = Nothing
, _hd_page = Nothing , _hd_page = Nothing
, _hd_from_country = Nothing
, _hd_title = Just $ if view du_title doc == "" then T.take 50 (view du_abstract doc) else view du_title doc , _hd_title = Just $ if view du_title doc == "" then T.take 50 (view du_abstract doc) else view du_title doc
, _hd_authors = Just $ view du_authors doc , _hd_authors = Just $ view du_authors doc
, _hd_institutes = Nothing , _hd_institutes = Nothing
......
...@@ -148,6 +148,7 @@ hyperdataDocumentFromFrameWrite lang paragraphSize (node, contents) = ...@@ -148,6 +148,7 @@ hyperdataDocumentFromFrameWrite lang paragraphSize (node, contents) =
, _hd_url = Nothing , _hd_url = Nothing
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = Just t , _hd_title = Just t
, _hd_from_country = Nothing
, _hd_authors = Just authors' , _hd_authors = Just authors'
, _hd_institutes = Nothing , _hd_institutes = Nothing
, _hd_source = Just $ node ^. node_name , _hd_source = Just $ node ^. node_name
......
...@@ -113,6 +113,7 @@ toDoc l (Arxiv.Result { abstract ...@@ -113,6 +113,7 @@ toDoc l (Arxiv.Result { abstract
, _hd_source = Just $ Text.pack journal , _hd_source = Just $ Text.pack journal
, _hd_abstract = Just $ Text.pack abstract , _hd_abstract = Just $ Text.pack abstract
, _hd_publication_date = Just $ Text.pack publication_date , _hd_publication_date = Just $ Text.pack publication_date
, _hd_from_country = Nothing
, _hd_publication_year = fromIntegral <$> year , _hd_publication_year = fromIntegral <$> year
, _hd_publication_month = Nothing -- TODO parse publication_date , _hd_publication_month = Nothing -- TODO parse publication_date
, _hd_publication_day = Nothing , _hd_publication_day = Nothing
......
...@@ -50,6 +50,7 @@ toDoc lang (EPO.HyperdataDocument { .. }) = ...@@ -50,6 +50,7 @@ toDoc lang (EPO.HyperdataDocument { .. }) =
, _hd_url = Nothing , _hd_url = Nothing
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = Map.lookup lang titles , _hd_title = Map.lookup lang titles
, _hd_from_country = Nothing
, _hd_authors = authors_ , _hd_authors = authors_
, _hd_institutes = Nothing , _hd_institutes = Nothing
, _hd_source = Nothing , _hd_source = Nothing
......
...@@ -55,6 +55,7 @@ toDoc' la (HAL.Document { .. }) = do ...@@ -55,6 +55,7 @@ toDoc' la (HAL.Document { .. }) = do
, _hd_title = Just $ unwords _document_title , _hd_title = Just $ unwords _document_title
, _hd_authors = Just $ nonemptyIntercalate ", " _document_authors_names , _hd_authors = Just $ nonemptyIntercalate ", " _document_authors_names
, _hd_institutes = Just $ nonemptyIntercalate ", " $ zipWith (\affialition structId -> affialition <> " | " <> structId) _document_authors_affiliations $ map show _document_struct_id , _hd_institutes = Just $ nonemptyIntercalate ", " $ zipWith (\affialition structId -> affialition <> " | " <> structId) _document_authors_affiliations $ map show _document_struct_id
, _hd_from_country = Nothing
, _hd_source = Just $ maybe "Nothing" identity _document_source , _hd_source = Just $ maybe "Nothing" identity _document_source
, _hd_abstract = Just abstract , _hd_abstract = Just abstract
, _hd_publication_date = fmap show utctime , _hd_publication_date = fmap show utctime
......
...@@ -83,6 +83,7 @@ isidoreToDoc lang (IsidoreDoc t a d u s as) = do ...@@ -83,6 +83,7 @@ isidoreToDoc lang (IsidoreDoc t a d u s as) = do
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = Just $ cleanText $ langText t , _hd_title = Just $ cleanText $ langText t
, _hd_authors = creator2text <$> as , _hd_authors = creator2text <$> as
, _hd_from_country = Nothing
, _hd_institutes = Nothing , _hd_institutes = Nothing
, _hd_source = Just $ maybe "Nothing" (identity . _sourceName) s , _hd_source = Just $ maybe "Nothing" (identity . _sourceName) s
, _hd_abstract = cleanText . langText <$> a , _hd_abstract = cleanText . langText <$> a
......
...@@ -38,6 +38,7 @@ toDoc (OA.Work { .. } ) = ...@@ -38,6 +38,7 @@ toDoc (OA.Work { .. } ) =
, _hd_doi = doi , _hd_doi = doi
, _hd_url = url , _hd_url = url
, _hd_page = firstPage biblio , _hd_page = firstPage biblio
, _hd_from_country = Nothing
, _hd_title = title , _hd_title = title
, _hd_authors = authors authorships , _hd_authors = authors authorships
, _hd_institutes = institutes authorships , _hd_institutes = institutes authorships
......
...@@ -120,6 +120,7 @@ toDoc l (PubMedDoc.PubMed { pubmed_article = PubMedDoc.PubMedArticle t j as aus ...@@ -120,6 +120,7 @@ toDoc l (PubMedDoc.PubMed { pubmed_article = PubMedDoc.PubMedArticle t j as aus
, _hd_url = Nothing , _hd_url = Nothing
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = t , _hd_title = t
, _hd_from_country = Nothing
, _hd_authors = authors aus , _hd_authors = authors aus
, _hd_institutes = institutes aus , _hd_institutes = institutes aus
, _hd_source = j , _hd_source = j
......
...@@ -259,6 +259,7 @@ toDoc ff d = do ...@@ -259,6 +259,7 @@ toDoc ff d = do
, _hd_authors = lookup "authors" d , _hd_authors = lookup "authors" d
, _hd_institutes = lookup "institutes" d , _hd_institutes = lookup "institutes" d
, _hd_source = lookup "source" d , _hd_source = lookup "source" d
, _hd_from_country = Nothing
, _hd_abstract = lookup "abstract" d , _hd_abstract = lookup "abstract" d
, _hd_publication_date = fmap (DT.pack . show) utcTime , _hd_publication_date = fmap (DT.pack . show) utcTime
, _hd_publication_year = pub_year , _hd_publication_year = pub_year
......
...@@ -80,6 +80,7 @@ instance ToHyperdataDocument GrandDebatReference ...@@ -80,6 +80,7 @@ instance ToHyperdataDocument GrandDebatReference
, _hd_title = title , _hd_title = title
, _hd_authors = authorType , _hd_authors = authorType
, _hd_institutes = authorType , _hd_institutes = authorType
, _hd_from_country = Nothing
, _hd_source = authorZipCode , _hd_source = authorZipCode
, _hd_abstract = toAbstract <$> responses , _hd_abstract = toAbstract <$> responses
, _hd_publication_date = publishedAt , _hd_publication_date = publishedAt
......
...@@ -126,6 +126,7 @@ bind2doc l [ link', date, langDoc, authors, _source, publisher, title, abstract ...@@ -126,6 +126,7 @@ bind2doc l [ link', date, langDoc, authors, _source, publisher, title, abstract
, _hd_title = unbound l title , _hd_title = unbound l title
, _hd_authors = unbound l authors , _hd_authors = unbound l authors
, _hd_institutes = Nothing , _hd_institutes = Nothing
, _hd_from_country = Nothing
, _hd_source = unbound l publisher , _hd_source = unbound l publisher
, _hd_abstract = unbound l abstract , _hd_abstract = unbound l abstract
, _hd_publication_date = unbound l date , _hd_publication_date = unbound l date
......
...@@ -43,6 +43,7 @@ toDoc la (ISTEX.Document i t a ab d s) = do ...@@ -43,6 +43,7 @@ toDoc la (ISTEX.Document i t a ab d s) = do
, _hd_institutes = Just $ nonemptyIntercalate ", " (concatMap ISTEX._author_affiliations a) , _hd_institutes = Just $ nonemptyIntercalate ", " (concatMap ISTEX._author_affiliations a)
, _hd_source = Just $ nonemptyIntercalate ", " $ maybeToList $ join (ISTEX._source_title <$> s) , _hd_source = Just $ nonemptyIntercalate ", " $ maybeToList $ join (ISTEX._source_title <$> s)
, _hd_abstract = ab , _hd_abstract = ab
, _hd_from_country = Nothing
, _hd_publication_date = fmap (T.pack . show) utctime , _hd_publication_date = fmap (T.pack . show) utctime
, _hd_publication_year = pub_year , _hd_publication_year = pub_year
, _hd_publication_month = pub_month , _hd_publication_month = pub_month
......
...@@ -525,6 +525,7 @@ tsvHal2doc (TsvHal { .. }) = ...@@ -525,6 +525,7 @@ tsvHal2doc (TsvHal { .. }) =
, _hd_url = Just tsvHal_url , _hd_url = Just tsvHal_url
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = Just tsvHal_title , _hd_title = Just tsvHal_title
, _hd_from_country = Nothing
, _hd_authors = Just tsvHal_authors , _hd_authors = Just tsvHal_authors
, _hd_institutes = Just tsvHal_instStructId_i , _hd_institutes = Just tsvHal_instStructId_i
, _hd_source = Just tsvHal_source , _hd_source = Just tsvHal_source
...@@ -550,6 +551,7 @@ tsv2doc (TsvDoc { .. }) ...@@ -550,6 +551,7 @@ tsv2doc (TsvDoc { .. })
, _hd_page = Nothing , _hd_page = Nothing
, _hd_title = Just tsv_title , _hd_title = Just tsv_title
, _hd_authors = Just tsv_authors , _hd_authors = Just tsv_authors
, _hd_from_country = Nothing
, _hd_institutes = Nothing , _hd_institutes = Nothing
, _hd_source = Just tsv_source , _hd_source = Just tsv_source
, _hd_abstract = Just tsv_abstract , _hd_abstract = Just tsv_abstract
......
...@@ -33,6 +33,7 @@ data HyperdataDocument = HyperdataDocument { _hd_bdd :: !(Maybe T ...@@ -33,6 +33,7 @@ data HyperdataDocument = HyperdataDocument { _hd_bdd :: !(Maybe T
, _hd_publication_month :: !(Maybe Int) , _hd_publication_month :: !(Maybe Int)
, _hd_publication_day :: !(Maybe Int) , _hd_publication_day :: !(Maybe Int)
, _hd_publication_hour :: !(Maybe Int) , _hd_publication_hour :: !(Maybe Int)
, _hd_from_country :: !(Maybe Text)
, _hd_publication_minute :: !(Maybe Int) , _hd_publication_minute :: !(Maybe Int)
, _hd_publication_second :: !(Maybe Int) , _hd_publication_second :: !(Maybe Int)
, _hd_language_iso2 :: !(Maybe Text) , _hd_language_iso2 :: !(Maybe Text)
...@@ -50,7 +51,7 @@ instance HasText HyperdataDocument ...@@ -50,7 +51,7 @@ instance HasText HyperdataDocument
defaultHyperdataDocument :: HyperdataDocument defaultHyperdataDocument :: HyperdataDocument
defaultHyperdataDocument = case decode docExample of defaultHyperdataDocument = case decode docExample of
Just hp -> hp Just hp -> hp
Nothing -> HyperdataDocument Nothing Nothing Nothing -> HyperdataDocument Nothing Nothing Nothing
Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
...@@ -116,12 +117,13 @@ arbitraryHyperdataDocuments = ...@@ -116,12 +117,13 @@ arbitraryHyperdataDocuments =
, ("Science is magic" , "Closed Source review") , ("Science is magic" , "Closed Source review")
, ("Open science for all" , "No Time" ) , ("Open science for all" , "No Time" )
, ("Closed science for me" , "No Space" ) , ("Closed science for me" , "No Space" )
] :: [(Text, Text)]) ] :: [(Text, Text)])
where where
toHyperdataDocument' (t1,t2) = toHyperdataDocument' (t1,t2) =
HyperdataDocument Nothing Nothing Nothing Nothing (Just t1) HyperdataDocument Nothing Nothing Nothing Nothing (Just t1)
Nothing Nothing (Just t2) Nothing Nothing Nothing Nothing Nothing Nothing Nothing (Just t2) Nothing Nothing Nothing Nothing Nothing
Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
...@@ -137,7 +139,6 @@ instance ToSchema HyperdataDocument where ...@@ -137,7 +139,6 @@ instance ToSchema HyperdataDocument where
genericDeclareNamedSchema (unPrefixSwagger "_hd_") proxy genericDeclareNamedSchema (unPrefixSwagger "_hd_") proxy
& mapped.schema.description ?~ "Document Hyperdata" & mapped.schema.description ?~ "Document Hyperdata"
& mapped.schema.example ?~ toJSON defaultHyperdataDocument & mapped.schema.example ?~ toJSON defaultHyperdataDocument
{- {-
-- | For now HyperdataDocumentV3 is not exposed with the API -- | For now HyperdataDocumentV3 is not exposed with the API
instance ToSchema HyperdataDocumentV3 where instance ToSchema HyperdataDocumentV3 where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment