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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Christian Merten
haskell-gargantext
Commits
ee1d0dc6
Verified
Commit
ee1d0dc6
authored
Aug 08, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[openalex] implement iso639 in it's api call
parent
bf98b6c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
Core.hs
src/Gargantext/Core.hs
+5
-0
API.hs
src/Gargantext/Core/Text/Corpus/API.hs
+1
-1
OpenAlex.hs
src/Gargantext/Core/Text/Corpus/API/OpenAlex.hs
+4
-3
No files found.
src/Gargantext/Core.hs
View file @
ee1d0dc6
...
...
@@ -112,6 +112,11 @@ toISO639 All = Nothing
toISO639EN
::
Lang
->
ISO639
.
ISO639_1
toISO639EN
l
=
fromMaybe
ISO639
.
EN
$
toISO639
l
iso639ToText
::
ISO639
.
ISO639_1
->
Text
iso639ToText
la
=
pack
[
a
,
b
]
where
(
a
,
b
)
=
ISO639
.
toChars
la
-- | https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
toISO639Lang
::
Lang
->
Maybe
Text
toISO639Lang
All
=
Nothing
...
...
src/Gargantext/Core/Text/Corpus/API.hs
View file @
ee1d0dc6
...
...
@@ -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
la
limit
OpenAlex
.
get
(
fromMaybe
""
Nothing
{- email -}
)
q
(
toISO639
la
)
limit
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 @
ee1d0dc6
...
...
@@ -10,8 +10,9 @@ Portability : POSIX
module
Gargantext.Core.Text.Corpus.API.OpenAlex
where
import
Conduit
import
Data.LanguageCodes
qualified
as
ISO639
import
qualified
Data.Text
as
T
import
Gargantext.Core
(
Lang
,
toISO639Lang
)
import
Gargantext.Core
(
iso639ToText
)
import
Gargantext.Core.Text.Corpus.Query
as
Corpus
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
Protolude
...
...
@@ -22,12 +23,12 @@ import Servant.Client (ClientError)
get
::
Text
->
Corpus
.
RawQuery
->
Lang
->
Maybe
ISO639
.
ISO639_1
->
Maybe
Limit
->
IO
(
Either
ClientError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
_email
q
lang
mLimit
=
do
let
limit
=
getLimit
$
fromMaybe
1000
mLimit
let
mFilter
=
(
\
l
->
"language:"
<>
l
)
<$>
toISO639Lang
lang
let
mFilter
=
(
\
l
->
"language:"
<>
iso639ToText
l
)
<$>
lang
eRes
<-
OA
.
fetchWorksC
Nothing
mFilter
$
Just
$
Corpus
.
getRawQuery
q
pure
$
(
\
(
len
,
docsC
)
->
(
len
,
docsC
.|
takeC
limit
.|
mapC
toDoc
))
<$>
eRes
...
...
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