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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
684651bd
Commit
684651bd
authored
Jun 30, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev-openalex' into dev-merge
parents
23892d1d
725c2ca4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
Core.hs
src/Gargantext/Core.hs
+15
-1
API.hs
src/Gargantext/Core/Text/Corpus/API.hs
+1
-1
OpenAlex.hs
src/Gargantext/Core/Text/Corpus/API/OpenAlex.hs
+7
-3
No files found.
src/Gargantext/Core.hs
View file @
684651bd
...
...
@@ -80,10 +80,24 @@ instance FromHttpApiData Lang
instance
ToHttpApiData
Lang
where
toUrlPiece
=
pack
.
show
instance
Hashable
Lang
instance
Arbitrary
Lang
where
arbitrary
=
arbitraryBoundedEnum
-- | https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
toISO639Lang
::
Lang
->
Maybe
Text
toISO639Lang
All
=
Nothing
toISO639Lang
DE
=
Just
"de"
toISO639Lang
EL
=
Just
"el"
toISO639Lang
EN
=
Just
"en"
toISO639Lang
ES
=
Just
"es"
toISO639Lang
FR
=
Just
"fr"
toISO639Lang
IT
=
Just
"it"
toISO639Lang
PL
=
Just
"pl"
toISO639Lang
PT
=
Just
"pt"
toISO639Lang
RU
=
Just
"ru"
toISO639Lang
UK
=
Just
"uk"
toISO639Lang
ZH
=
Just
"zh"
allLangs
::
[
Lang
]
allLangs
=
[
minBound
..
maxBound
]
...
...
src/Gargantext/Core/Text/Corpus/API.hs
View file @
684651bd
...
...
@@ -57,7 +57,7 @@ get externalAPI la q mPubmedAPIKey limit = do
Left
err
->
pure
$
Left
$
InvalidInputQuery
q
(
T
.
pack
err
)
Right
corpusQuery
->
case
externalAPI
of
OpenAlex
->
first
ExternalAPIError
<$>
OpenAlex
.
get
(
fromMaybe
""
Nothing
{- email -}
)
q
limit
OpenAlex
.
get
(
fromMaybe
""
Nothing
{- email -}
)
q
l
a
l
imit
PubMed
->
first
ExternalAPIError
<$>
PUBMED
.
get
(
fromMaybe
""
mPubmedAPIKey
)
corpusQuery
limit
--docs <- PUBMED.get q default_limit -- EN only by default
...
...
src/Gargantext/Core/Text/Corpus/API/OpenAlex.hs
View file @
684651bd
...
...
@@ -11,6 +11,7 @@ module Gargantext.Core.Text.Corpus.API.OpenAlex where
import
Conduit
import
qualified
Data.Text
as
T
import
Gargantext.Core
(
Lang
,
toISO639Lang
)
import
Gargantext.Core.Text.Corpus.Query
as
Corpus
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
Protolude
...
...
@@ -21,11 +22,14 @@ import Servant.Client (ClientError)
get
::
Text
->
Corpus
.
RawQuery
->
Lang
->
Maybe
Limit
->
IO
(
Either
ClientError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
_email
q
_l
=
do
eRes
<-
OA
.
fetchWorksC
Nothing
Nothing
$
Just
$
Corpus
.
getRawQuery
q
pure
$
(
\
(
len
,
docsC
)
->
(
len
,
docsC
.|
takeC
1000
.|
mapC
toDoc
))
<$>
eRes
get
_email
q
lang
mLimit
=
do
let
limit
=
getLimit
$
fromMaybe
10000
mLimit
let
mFilter
=
(
\
l
->
"language:"
<>
l
)
<$>
toISO639Lang
lang
eRes
<-
OA
.
fetchWorksC
Nothing
mFilter
$
Just
$
Corpus
.
getRawQuery
q
pure
$
(
\
(
len
,
docsC
)
->
(
len
,
docsC
.|
takeC
limit
.|
mapC
toDoc
))
<$>
eRes
toDoc
::
OA
.
Work
->
HyperdataDocument
toDoc
(
OA
.
Work
{
..
}
)
=
...
...
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