Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
istex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
gargantext
crawlers
istex
Commits
36d378b3
Commit
36d378b3
authored
Aug 27, 2019
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add abstract + need to delete space in output
parent
2b756240
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
Main.hs
app/Main.hs
+5
-3
ISTEX.hs
src/ISTEX.hs
+8
-0
Client.hs
src/ISTEX/Client.hs
+11
-5
No files found.
app/Main.hs
View file @
36d378b3
...
@@ -7,7 +7,9 @@ import ISTEX.Client
...
@@ -7,7 +7,9 @@ import ISTEX.Client
main
::
IO
()
main
::
IO
()
main
=
do
main
=
do
res
<-
runIstexAPIClient
$
search
(
Just
40
)
(
Just
"ia"
)
(
Just
"author,title
"
)
res
<-
basicSearch
(
Just
"ia
"
)
case
res
of
case
res
of
(
Left
err
)
->
print
err
(
Left
err
)
->
print
"Error"
(
Right
val
)
->
print
val
(
Right
val
)
->
do
print
$
take
5
$
_hits
val
-- print $ _abstract <$> (_hits val)
src/ISTEX.hs
View file @
36d378b3
{-# LANGUAGE OverloadedStrings #-}
module
ISTEX
where
module
ISTEX
where
import
ISTEX.Client
import
ISTEX.Client
...
@@ -5,7 +7,13 @@ import Network.HTTP.Client (newManager)
...
@@ -5,7 +7,13 @@ import Network.HTTP.Client (newManager)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
import
Servant.Client
import
qualified
Data.Text
as
T
runIstexAPIClient
::
ClientM
(
Documents
)
->
IO
(
Either
ClientError
Documents
)
runIstexAPIClient
::
ClientM
(
Documents
)
->
IO
(
Either
ClientError
Documents
)
runIstexAPIClient
cmd
=
do
runIstexAPIClient
cmd
=
do
manager'
<-
newManager
tlsManagerSettings
manager'
<-
newManager
tlsManagerSettings
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
basicSearch
::
Maybe
T
.
Text
->
IO
(
Either
ClientError
Documents
)
basicSearch
rq
=
do
runIstexAPIClient
$
search
(
Just
"author,title,abstract"
)
(
Just
5000
)
rq
src/ISTEX/Client.hs
View file @
36d378b3
...
@@ -31,13 +31,18 @@ data Document = Document
...
@@ -31,13 +31,18 @@ data Document = Document
{
{
_id
::
T
.
Text
,
_id
::
T
.
Text
,
_title
::
Maybe
T
.
Text
,
_title
::
Maybe
T
.
Text
,
_authors
::
[
Author
]
_authors
::
[
Author
],
_abstract
::
Maybe
T
.
Text
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocument
L
.
makeLenses
''
D
ocument
instance
FromJSON
Document
where
instance
FromJSON
Document
where
parseJSON
(
Object
o
)
=
parseJSON
(
Object
o
)
=
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:?
"abstract"
)
data
Documents
=
Documents
data
Documents
=
Documents
{
{
...
@@ -51,13 +56,14 @@ instance FromJSON Documents where
...
@@ -51,13 +56,14 @@ instance FromJSON Documents where
type
ISTEXAPI
=
Search
type
ISTEXAPI
=
Search
type
Search
=
QueryParam
"size"
Int
type
Search
=
QueryParam
"output"
T
.
Text
:>
QueryParam
"size"
Int
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"output"
T
.
Text
:>
Get
'[
J
SON
]
Documents
:>
Get
'[
J
SON
]
Documents
istexProxy
::
Proxy
(
ISTEXAPI
)
istexProxy
::
Proxy
(
ISTEXAPI
)
istexProxy
=
Proxy
istexProxy
=
Proxy
search
::
Maybe
Int
->
Maybe
T
.
Tex
t
->
Maybe
T
.
Text
->
ClientM
Documents
search
::
Maybe
T
.
Text
->
Maybe
In
t
->
Maybe
T
.
Text
->
ClientM
Documents
search
=
client
istexProxy
search
=
client
istexProxy
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