Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
eb8fdc68
Verified
Commit
eb8fdc68
authored
Mar 04, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hyperdata] some Arxiv/Pubmed refactoring
parent
3fe6eba0
Pipeline
#5694
passed with stages
in 106 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
Arxiv.hs
src/Gargantext/Core/Text/Corpus/API/Arxiv.hs
+4
-4
Pubmed.hs
src/Gargantext/Core/Text/Corpus/API/Pubmed.hs
+9
-12
No files found.
src/Gargantext/Core/Text/Corpus/API/Arxiv.hs
View file @
eb8fdc68
...
...
@@ -19,13 +19,13 @@ module Gargantext.Core.Text.Corpus.API.Arxiv
)
where
import
Arxiv
qualified
as
Arxiv
import
Conduit
import
Conduit
(
ConduitT
,
(
.|
),
mapC
,
takeC
)
import
Data.Text
(
unpack
)
import
Data.Text
qualified
as
Text
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text.Corpus.Query
as
Corpus
import
Gargantext.Core.Types
(
Term
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata
.Document
(
HyperdataDocument
(
..
)
)
import
Gargantext.Prelude
hiding
(
get
)
import
Network.Api.Arxiv
qualified
as
Ax
...
...
@@ -46,7 +46,7 @@ convertQuery q = mkQuery (interpretQuery q transformAST)
transformAST
ast
=
case
ast
of
BAnd
sub
(
BConst
(
Negative
term
))
-- The second term become positive, so that it can be translated.
->
Ax
.
AndNot
<$>
(
transformAST
sub
)
<*>
transformAST
(
BConst
(
Positive
term
))
->
Ax
.
AndNot
<$>
transformAST
sub
<*>
transformAST
(
BConst
(
Positive
term
))
BAnd
term1
(
BNot
term2
)
->
Ax
.
AndNot
<$>
transformAST
term1
<*>
transformAST
term2
BAnd
sub1
sub2
...
...
@@ -88,7 +88,7 @@ toDoc l (Arxiv.Result { abstract
,
authors
=
aus
--, categories
,
doi
,
id
--
, id
,
journal
--, primaryCategory
,
publication_date
...
...
src/Gargantext/Core/Text/Corpus/API/Pubmed.hs
View file @
eb8fdc68
...
...
@@ -20,13 +20,13 @@ module Gargantext.Core.Text.Corpus.API.Pubmed
)
where
import
Conduit
import
Conduit
(
ConduitT
,
(
.|
),
mapC
,
takeC
)
import
Data.Text
qualified
as
Text
import
Data.Text.Encoding
qualified
as
TE
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text.Corpus.Query
as
Corpus
import
Gargantext.Core.Types
(
Term
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata
.Document
(
HyperdataDocument
(
..
)
)
import
Gargantext.Prelude
hiding
(
get
)
import
Network.HTTP.Types.URI
(
EscapeItem
(
..
),
renderQueryPartialEscape
)
import
PUBMED
qualified
as
PubMed
...
...
@@ -64,7 +64,7 @@ convertQuery q = ESearch (interpretQuery q transformAST)
transformAST
ast
=
case
ast
of
BAnd
sub
(
BConst
(
Negative
term
))
-- The second term become positive, so that it can be translated.
->
(
transformAST
sub
)
<>
[
QN
"+AND+NOT+"
]
<>
transformAST
(
BConst
(
Positive
term
))
->
transformAST
sub
<>
[
QN
"+AND+NOT+"
]
<>
transformAST
(
BConst
(
Positive
term
))
BAnd
term1
(
BNot
term2
)
->
transformAST
term1
<>
[
QN
"+AND+NOT+"
]
<>
transformAST
term2
BAnd
sub1
sub2
...
...
@@ -108,8 +108,7 @@ get apiKey q l = do
-- <$> PubMed.getMetadataWithC q l
toDoc
::
Lang
->
PubMedDoc
.
PubMed
->
HyperdataDocument
toDoc
l
(
PubMedDoc
.
PubMed
{
pubmed_id
,
pubmed_article
=
PubMedDoc
.
PubMedArticle
t
j
as
aus
toDoc
l
(
PubMedDoc
.
PubMed
{
pubmed_article
=
PubMedDoc
.
PubMedArticle
t
j
as
aus
,
pubmed_date
=
PubMedDoc
.
PubMedDate
a
y
m
d
}
)
=
HyperdataDocument
{
_hd_bdd
=
Just
"PubMed"
,
_hd_doi
=
Nothing
...
...
@@ -133,16 +132,14 @@ toDoc l (PubMedDoc.PubMed { pubmed_id
where
authors
::
[
PubMedDoc
.
Author
]
->
Maybe
Text
authors
[]
=
Nothing
authors
au
=
Just
$
(
Text
.
intercalate
", "
)
$
catMaybes
$
map
(
\
n
->
PubMedDoc
.
foreName
n
<>
Just
" "
<>
PubMedDoc
.
lastName
n
)
au
authors
au
=
Just
$
Text
.
intercalate
", "
$
mapMaybe
(
\
n
->
PubMedDoc
.
foreName
n
<>
Just
" "
<>
PubMedDoc
.
lastName
n
)
au
institutes
::
[
PubMedDoc
.
Author
]
->
Maybe
Text
institutes
[]
=
Nothing
institutes
au
=
Just
$
(
Text
.
intercalate
", "
)
$
(
map
(
Text
.
replace
", "
" - "
))
$
catMaybes
$
map
PubMedDoc
.
affiliation
au
institutes
au
=
Just
$
Text
.
intercalate
", "
$
map
(
Text
.
replace
", "
" - "
)
$
mapMaybe
PubMedDoc
.
affiliation
au
abstract
::
[
Text
]
->
Maybe
Text
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment