Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pubmed
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
pubmed
Commits
62ecec55
Commit
62ecec55
authored
Jul 08, 2019
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct removeSub
parent
06476735
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
Main.hs
app/Main.hs
+1
-1
PUBMED.hs
src/PUBMED.hs
+12
-6
No files found.
app/Main.hs
View file @
62ecec55
...
@@ -6,4 +6,4 @@ import PUBMED (crawler)
...
@@ -6,4 +6,4 @@ import PUBMED (crawler)
main
::
IO
()
main
::
IO
()
main
=
crawler
"bisphenol"
(
Just
3
)
>>=
print
main
=
crawler
"bisphenol"
(
Just
50
)
>>=
print
src/PUBMED.hs
View file @
62ecec55
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
module
PUBMED
where
module
PUBMED
where
import
Prelude
hiding
(
takeWhile
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
PUBMED.Client
import
PUBMED.Client
import
PUBMED.Parser
import
PUBMED.Parser
...
@@ -31,12 +32,17 @@ runParser parser = parser . fromDocument . parseLBS_ def
...
@@ -31,12 +32,17 @@ runParser parser = parser . fromDocument . parseLBS_ def
removeSub
::
Parser
ByteString
removeSub
::
Parser
ByteString
removeSub
=
do
removeSub
=
do
dt
<-
many
textWithBalise
dt
<-
many
textWithBalise
pure
$
LBS
.
fromStrict
$
pack
$
concat
dt
eo
<-
manyTill
anyChar
endOfInput
pure
$
LBS
.
fromStrict
$
pack
$
concat
dt
<>
eo
where
where
textWithBalise
=
manyTill
anyChar
(
try
subs
)
textWithBalise
=
subs
=
sub
<|>
asub
-- <|> isEndOfInput
manyTill
anyChar
(
sub
<|>
asub
)
sub
=
string
"<sub>"
sub
=
string
"<sub>"
<|>
string
"<sup>"
<|>
string
"<i>"
asub
=
string
"</sub>"
asub
=
string
"</sub>"
<|>
string
"</sup>"
<|>
string
"</i>"
type
Query
=
Text
type
Query
=
Text
type
Limit
=
Integer
type
Limit
=
Integer
...
@@ -51,18 +57,18 @@ runSimpleFindPubmedAbstractRequest query limit = do
...
@@ -51,18 +57,18 @@ runSimpleFindPubmedAbstractRequest query limit = do
(
search
(
Just
query
)
limit
)
(
search
(
Just
query
)
limit
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
case
res
of
case
res
of
(
Left
_
)
->
pure
(
Left
"Error: PubMed Internet connection"
)
(
Left
err
)
->
pure
(
Left
$
T
.
pack
$
show
err
)
(
Right
(
BsXml
docs
))
->
do
(
Right
(
BsXml
docs
))
->
do
let
docIds
=
runParser
parseDocId
docs
let
docIds
=
runParser
parseDocId
docs
res'
<-
runClientM
res'
<-
runClientM
(
fetch
(
Just
"pubmed"
)
(
Just
"abstract"
)
docIds
)
(
fetch
(
Just
"pubmed"
)
(
Just
"abstract"
)
docIds
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
case
res'
of
case
res'
of
(
Left
_
)
->
pure
(
Left
"Error: PubMed API connection"
)
(
Left
err'
)
->
pure
(
Left
$
T
.
pack
$
show
err'
)
(
Right
(
BsXml
abstracts
))
->
do
(
Right
(
BsXml
abstracts
))
->
do
-- TODO remove "</sub>" maybe there is a cleaner way with isEndOfInput
-- TODO remove "</sub>" maybe there is a cleaner way with isEndOfInput
case
(
parseOnly
removeSub
$
LBS
.
toStrict
abstracts
<>
"</sub>"
)
of
case
(
parseOnly
removeSub
$
LBS
.
toStrict
abstracts
<>
"</sub>"
)
of
(
Left
err
)
->
pure
(
Left
"Error: PubMed parser"
)
(
Left
err
''
)
->
pure
(
Left
$
T
.
pack
err''
)
(
Right
v
)
->
Right
<$>
pubMedParser
v
(
Right
v
)
->
Right
<$>
pubMedParser
v
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