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
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
6cbc1f5e
Commit
6cbc1f5e
authored
5 years ago
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] External API structure of code.
parent
67e1e32d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
166 additions
and
45 deletions
+166
-45
package.yaml
package.yaml
+2
-0
API.hs
src/Gargantext/Text/Corpus/API.hs
+38
-45
Hal.hs
src/Gargantext/Text/Corpus/API/Hal.hs
+30
-0
Istex.hs
src/Gargantext/Text/Corpus/API/Istex.hs
+31
-0
Pubmed.hs
src/Gargantext/Text/Corpus/API/Pubmed.hs
+65
-0
No files found.
package.yaml
View file @
6cbc1f5e
...
...
@@ -100,6 +100,7 @@ library:
-
crawlerPubMed
-
crawlerIsidore
-
crawlerHAL
-
crawlerISTEX
-
data-time-segment
-
deepseq
-
directory
...
...
@@ -204,6 +205,7 @@ library:
-
zip
-
zlib
# - utc
# API external connections
executables
:
gargantext-server
:
...
...
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Corpus/API.hs
View file @
6cbc1f5e
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE InstanceSigs #-}
module
Gargantext.Text.Corpus.API
where
...
...
@@ -19,26 +20,52 @@ module Gargantext.Text.Corpus.API
import
GHC.Generics
(
Generic
)
import
Data.Aeson
import
Data.Maybe
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck
(
elements
)
import
Data.Swagger
import
qualified
Data.Text
as
Text
import
qualified
PUBMED
as
PubMed
import
qualified
PUBMED.Parser
as
Doc
--import qualified Gargantext.Text.Corpus.API.Isidore as Isidore
import
qualified
Gargantext.Text.Corpus.API.Pubmed
as
PUBMED
import
qualified
Gargantext.Text.Corpus.API.Isidore
as
ISIDORE
import
qualified
Gargantext.Text.Corpus.API.Hal
as
HAL
import
qualified
Gargantext.Text.Corpus.API.Istex
as
ISTEX
-- | Main Types
data
ExternalAPIs
=
All
|
PubMed
|
HAL
-- | IsTex
|
IsidoreQuery
|
IsidoreAuth
|
Hal_EN
|
Hal_FR
|
IsTex_EN
|
IsTex_FR
|
Isidore_EN
|
Isidore_FR
-- | IsidoreAuth
deriving
(
Show
,
Eq
,
Enum
,
Bounded
,
Generic
)
-- | Get External API metadata main function
get
::
ExternalAPIs
->
Query
->
Maybe
Limit
->
IO
[
HyperdataDocument
]
get
All
_
_
=
undefined
get
PubMed
q
l
=
PUBMED
.
get
q
l
get
Hal_EN
q
l
=
HAL
.
get
EN
q
l
get
Hal_FR
q
l
=
HAL
.
get
FR
q
l
get
IsTex_EN
q
l
=
ISTEX
.
get
EN
q
l
get
IsTex_FR
q
l
=
ISTEX
.
get
FR
q
l
get
Isidore_EN
q
l
=
ISIDORE
.
get
EN
(
fromIntegral
<$>
l
)
(
Just
q
)
Nothing
get
Isidore_FR
q
l
=
ISIDORE
.
get
FR
(
fromIntegral
<$>
l
)
(
Just
q
)
Nothing
-- | Main Instances
instance
FromJSON
ExternalAPIs
instance
ToJSON
ExternalAPIs
...
...
@@ -51,41 +78,7 @@ instance Arbitrary ExternalAPIs
instance
ToSchema
ExternalAPIs
type
Query
=
Text
type
Limit
=
PubMed
.
Limit
get
::
ExternalAPIs
->
Query
->
Maybe
Limit
->
IO
[
HyperdataDocument
]
get
PubMed
q
l
=
either
(
\
e
->
panic
$
"CRAWL: PubMed"
<>
e
)
(
map
(
toDoc
EN
))
<$>
PubMed
.
getMetadataWith
q
l
get
_
_
_
=
undefined
toDoc
::
Lang
->
Doc
.
PubMed
->
HyperdataDocument
toDoc
l
(
Doc
.
PubMed
(
Doc
.
PubMedArticle
t
j
as
aus
)
(
Doc
.
PubMedDate
a
y
m
d
)
)
=
HyperdataDocument
(
Just
"PubMed"
)
Nothing
Nothing
Nothing
Nothing
Nothing
t
(
authors
aus
)
Nothing
j
(
abstract
as
)
(
Just
$
Text
.
pack
$
show
a
)
(
Just
$
fromIntegral
y
)
(
Just
m
)
(
Just
d
)
Nothing
Nothing
Nothing
(
Just
$
(
Text
.
pack
.
show
)
l
)
where
authors
::
Maybe
[
Doc
.
Author
]
->
Maybe
Text
authors
aus'
=
case
aus'
of
Nothing
->
Nothing
Just
au
->
Just
$
(
Text
.
intercalate
", "
)
$
catMaybes
$
map
Doc
.
foreName
au
abstract
::
Maybe
[
Text
]
->
Maybe
Text
abstract
as'
=
fmap
(
Text
.
intercalate
", "
)
as'
-- | Some Sugar for the documentation
type
Query
=
PUBMED
.
Query
type
Limit
=
PUBMED
.
Limit
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Corpus/API/Hal.hs
0 → 100644
View file @
6cbc1f5e
{-|
Module : Gargantext.Text.Corpus.API.Hal
Description : Pubmed API connection
Copyright : (c) CNRS, 2017
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Corpus.API.Hal
where
import
Data.Maybe
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
qualified
Data.Text
as
Text
import
qualified
HAL
as
HAL
import
qualified
HAL.Doc.Corpus
as
HAL
get
::
Lang
->
Text
->
Maybe
Integer
->
IO
[
HyperdataDocument
]
get
la
q
li
=
undefined
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Corpus/API/Istex.hs
0 → 100644
View file @
6cbc1f5e
{-|
Module : Gargantext.Text.Corpus.API.Istex
Description : Pubmed API connection
Copyright : (c) CNRS, 2017
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Corpus.API.Istex
where
import
Data.Maybe
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
qualified
Data.Text
as
Text
import
qualified
ISTEX
as
ISTEX
import
qualified
ISTEX.Client
as
ISTEX
get
::
Lang
->
Text
->
Maybe
Integer
->
IO
[
HyperdataDocument
]
get
la
q
ml
=
undefined
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Corpus/API/Pubmed.hs
0 → 100644
View file @
6cbc1f5e
{-|
Module : Gargantext.Text.Corpus.API.Pubmed
Description : Pubmed API connection
Copyright : (c) CNRS, 2017
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Corpus.API.Pubmed
where
import
Data.Maybe
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
qualified
Data.Text
as
Text
import
qualified
PUBMED
as
PubMed
import
qualified
PUBMED.Parser
as
PubMedDoc
type
Query
=
Text
type
Limit
=
PubMed
.
Limit
get
::
Query
->
Maybe
Limit
->
IO
[
HyperdataDocument
]
get
q
l
=
either
(
\
e
->
panic
$
"CRAWL: PubMed"
<>
e
)
(
map
(
toDoc
EN
))
<$>
PubMed
.
getMetadataWith
q
l
toDoc
::
Lang
->
PubMedDoc
.
PubMed
->
HyperdataDocument
toDoc
l
(
PubMedDoc
.
PubMed
(
PubMedDoc
.
PubMedArticle
t
j
as
aus
)
(
PubMedDoc
.
PubMedDate
a
y
m
d
)
)
=
HyperdataDocument
(
Just
"PubMed"
)
Nothing
Nothing
Nothing
Nothing
Nothing
t
(
authors
aus
)
Nothing
j
(
abstract
as
)
(
Just
$
Text
.
pack
$
show
a
)
(
Just
$
fromIntegral
y
)
(
Just
m
)
(
Just
d
)
Nothing
Nothing
Nothing
(
Just
$
(
Text
.
pack
.
show
)
l
)
where
authors
::
Maybe
[
PubMedDoc
.
Author
]
->
Maybe
Text
authors
aus'
=
case
aus'
of
Nothing
->
Nothing
Just
au
->
Just
$
(
Text
.
intercalate
", "
)
$
catMaybes
$
map
PubMedDoc
.
foreName
au
abstract
::
Maybe
[
Text
]
->
Maybe
Text
abstract
as'
=
fmap
(
Text
.
intercalate
", "
)
as'
This diff is collapsed.
Click to expand it.
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