Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
64e0bc84
Commit
64e0bc84
authored
May 04, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARSERS] refactor.
parent
c41cdec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
RIS.hs
src/Gargantext/Text/Parsers/RIS.hs
+10
-5
WOS.hs
src/Gargantext/Text/Parsers/WOS.hs
+5
-21
No files found.
src/Gargantext/Text/Parsers/RIS.hs
View file @
64e0bc84
...
...
@@ -19,7 +19,7 @@ citation programs to exchange data.
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers.RIS
(
risParser
,
withField
)
where
module
Gargantext.Text.Parsers.RIS
(
risParser
,
withField
,
fieldWith
,
lines
)
where
import
Data.Either
(
either
)
import
Data.List
(
lookup
)
...
...
@@ -41,17 +41,21 @@ risParser = do
pure
$
[
n
]
<>
ns
notice
::
Parser
ByteString
->
Parser
[(
ByteString
,
ByteString
)]
notice
s
=
start
*>
many
field
<*
end
notice
s
=
start
*>
many
(
fieldWith
field
)
<*
end
where
field
::
Parser
ByteString
field
=
"
\n
"
*>
take
2
<*
" - "
start
::
Parser
ByteString
start
=
s
*>
takeTill
isEndOfLine
end
::
Parser
ByteString
end
=
"
\n
ER -"
*>
takeTill
isEndOfLine
field
::
Parser
(
ByteString
,
ByteString
)
field
=
do
name
<-
"
\n
"
*>
take
2
<*
" - "
fieldWith
::
Parser
ByteString
->
Parser
(
ByteString
,
ByteString
)
fieldWith
n
=
do
name
<-
n
txt
<-
takeTill
isEndOfLine
txts
<-
try
lines
let
txts'
=
case
DL
.
length
txts
>
0
of
...
...
@@ -59,6 +63,7 @@ field = do
False
->
[]
pure
(
name
,
concat
([
txt
]
<>
txts'
))
lines
::
Parser
[
ByteString
]
lines
=
many
line
where
...
...
src/Gargantext/Text/Parsers/WOS.hs
View file @
64e0bc84
...
...
@@ -29,6 +29,7 @@ import Data.Attoparsec.ByteString.Char8 (anyChar, isEndOfLine)
import
Data.ByteString
(
ByteString
,
concat
)
import
Data.ByteString.Char8
(
pack
)
import
Control.Applicative
import
Gargantext.Text.Parsers.RIS
(
fieldWith
,
lines
)
-------------------------------------------------------------
-- | wosParser parses ISI format from
...
...
@@ -42,8 +43,11 @@ wosParser = do
pure
ns
notice
::
Parser
[(
ByteString
,
ByteString
)]
notice
=
start
*>
fields
<*
end
notice
=
start
*>
many
(
fieldWith
field
)
<*
end
where
field
::
Parser
ByteString
field
=
"
\n
"
*>
take
2
<*
" "
start
::
Parser
ByteString
start
=
"
\n
PT "
*>
takeTill
isEndOfLine
...
...
@@ -51,26 +55,6 @@ notice = start *> fields <* end
end
=
manyTill
anyChar
(
string
$
pack
"
\n
ER
\n
"
)
fields
::
Parser
[(
ByteString
,
ByteString
)]
fields
=
many
field
where
field
::
Parser
(
ByteString
,
ByteString
)
field
=
do
name
<-
"
\n
"
*>
take
2
<*
" "
txt
<-
takeTill
isEndOfLine
txts
<-
try
lines
let
txts'
=
case
DL
.
length
txts
>
0
of
True
->
txts
False
->
[]
pure
(
translate
name
,
concat
([
txt
]
<>
txts'
))
lines
::
Parser
[
ByteString
]
lines
=
many
line
where
line
::
Parser
ByteString
line
=
"
\n
"
*>
takeTill
isEndOfLine
translate
::
ByteString
->
ByteString
translate
champs
|
champs
==
"AF"
=
"authors"
...
...
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