Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
hal
Commits
a8799bb2
Commit
a8799bb2
authored
Nov 12, 2019
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'generateRequestByStructID' to make request filtered by structId
parent
802033bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
4 deletions
+42
-4
Main.hs
app/Main.hs
+24
-1
HAL.hs
src/HAL.hs
+13
-0
Corpus.hs
src/HAL/Doc/Corpus.hs
+5
-3
No files found.
app/Main.hs
View file @
a8799bb2
...
...
@@ -9,11 +9,34 @@ import Servant.Client
import
HAL
(
getMetadataWith
)
import
HAL.Client
import
HAL.Doc
import
HAL
import
Tree
import
qualified
Data.Text
as
T
imt
::
[
T
.
Text
]
imt
=
[
"224096"
,
"144103"
,
"84538"
,
"300104"
,
"300362"
,
"301262"
,
"301442"
,
"301492"
,
"302102"
,
"421532"
,
"497330"
,
"352124"
,
"481355"
,
"469216"
,
"542824"
,
"6279"
,
"29212"
]
main
::
IO
()
main
=
do
res
<-
getMetadataWith
"artificial intelligence"
(
Just
10
)
res
<-
getMetadataWith
(
generateRequestByStructID
"artificial intelligence"
imt
)
(
Just
10
)
case
res
of
(
Left
err
)
->
print
err
(
Right
val
)
->
print
$
_docs
val
src/HAL.hs
View file @
a8799bb2
...
...
@@ -41,3 +41,16 @@ runStructureRequest rq =
runSearchRequest
::
[
Text
]
->
IO
(
Either
ClientError
(
Response
Corpus
))
runSearchRequest
rq
=
runHalAPIClient
$
search
(
Just
requestedFields
)
rq
Nothing
Nothing
Nothing
generateRequestByStructID
::
Text
->
[
Text
]
->
Text
generateRequestByStructID
rq
struct_ids
=
"text:"
<>
rq
<>
" AND "
<>
"structId_i:("
<>
(
flattenPipe
struct_ids
)
<>
")"
flattenPipe
::
[
Text
]
->
Text
flattenPipe
(
x
:
[]
)
=
x
flattenPipe
(
x
:
xs
)
=
x
<>
" || "
<>
flattenPipe
xs
src/HAL/Doc/Corpus.hs
View file @
a8799bb2
...
...
@@ -22,12 +22,13 @@ data Corpus = Corpus
_corpus_date
::
Maybe
Text
,
_corpus_source
::
Maybe
Text
,
_corpus_authors_names
::
[
Text
],
_corpus_authors_affiliations
::
[
Text
]
_corpus_authors_affiliations
::
[
Text
],
_corpus_struct_id
::
[
Int
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
C
orpus
instance
Default
Corpus
where
def
=
Corpus
def
def
def
def
def
def
def
def
=
Corpus
def
def
def
def
def
def
def
def
instance
FromJSON
Corpus
where
parseJSON
(
Object
o
)
=
Corpus
<$>
...
...
@@ -38,6 +39,7 @@ instance FromJSON Corpus where
<*>
(
o
.:?
"source_s"
)
<*>
(
o
.:
"authFullName_s"
<|>
return
[]
)
<*>
(
o
.:
"authOrganism_s"
<|>
return
[]
)
<*>
(
o
.:
"structId_i"
<|>
return
[]
)
instance
ToHttpApiData
Corpus
where
toUrlPiece
_
=
"docid,title_s,abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s"
toUrlPiece
_
=
"docid,title_s,abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s
,structId_i
"
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