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
dd670d8e
Commit
dd670d8e
authored
May 02, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARSERS] RIS OK
parent
69bc5fe7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
RIS.hs
src/Gargantext/Text/Parsers/RIS.hs
+10
-21
No files found.
src/Gargantext/Text/Parsers/RIS.hs
View file @
dd670d8e
...
@@ -17,7 +17,7 @@ citation programs to exchange data.[More](https://en.wikipedia.org/wiki/RIS_(fil
...
@@ -17,7 +17,7 @@ citation programs to exchange data.[More](https://en.wikipedia.org/wiki/RIS_(fil
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers.RIS
(
risParser
,
field
,
notice
)
where
module
Gargantext.Text.Parsers.RIS
(
risParser
)
where
import
Control.Applicative
import
Control.Applicative
import
Data.Attoparsec.ByteString
(
Parser
,
try
,
string
,
takeTill
,
take
,
manyTill
,
many1
,
endOfInput
)
import
Data.Attoparsec.ByteString
(
Parser
,
try
,
string
,
takeTill
,
take
,
manyTill
,
many1
,
endOfInput
)
...
@@ -34,46 +34,35 @@ data Lines = OneLine | MultiLine
...
@@ -34,46 +34,35 @@ data Lines = OneLine | MultiLine
risParser
::
Parser
[[(
ByteString
,
ByteString
)]]
risParser
::
Parser
[[(
ByteString
,
ByteString
)]]
risParser
=
do
risParser
=
do
--
_
<-
manyTill
anyChar
(
string
$
pack
"START"
)
n
<-
notice
"TY -"
ns
<-
many1
notice
-- <* (string $ pack "\nXXX
")
ns
<-
many1
(
notice
"
\n
TY -
"
)
pure
ns
pure
$
[
n
]
<>
ns
notice
::
Parser
[(
ByteString
,
ByteString
)]
notice
::
Parser
ByteString
->
Parser
[(
ByteString
,
ByteString
)]
notice
=
start
*>
many
field
<*
end
notice
s
=
start
*>
many
field
<*
end
where
where
start
::
Parser
ByteString
start
::
Parser
ByteString
start
=
"
\n
TY"
*>
takeTill
isEndOfLine
start
=
s
*>
takeTill
isEndOfLine
end
::
Parser
ByteString
end
::
Parser
ByteString
end
=
"
\n
ER
\n
"
*>
takeTill
isEndOfLine
end
=
"
\n
ER -"
*>
takeTill
isEndOfLine
--end = manyTill anyChar (string $ pack "\nER\n")
fields
::
Parser
[(
ByteString
,
ByteString
)]
fields
=
many
field
field
::
Parser
(
ByteString
,
ByteString
)
field
::
Parser
(
ByteString
,
ByteString
)
field
=
do
field
=
do
--name <- "\n" *> take 2 <* takeTill isEndOfLine -- " -"
name
<-
"
\n
"
*>
take
2
<*
" - "
name
<-
"
\n
"
*>
take
2
<*
" - "
txt
<-
takeTill
isEndOfLine
-- " -"
txt
<-
takeTill
isEndOfLine
--name <- take 2
--txt <- takeTill isEndOfLine
{-
txts
<-
try
lines
txts
<-
try
lines
let
txts'
=
case
DL
.
length
txts
>
0
of
let
txts'
=
case
DL
.
length
txts
>
0
of
True
->
txts
True
->
txts
False
->
[]
False
->
[]
pure
(
translate
name
,
concat
([
txt
]
<>
txts'
))
pure
(
translate
name
,
concat
([
txt
]
<>
txts'
))
--}
pure
(
translate
name
,
txt
)
lines
::
Parser
[
ByteString
]
lines
::
Parser
[
ByteString
]
lines
=
many
line
lines
=
many
line
where
where
line
::
Parser
ByteString
line
::
Parser
ByteString
line
=
"
\n
"
*>
takeTill
isEndOfLine
line
=
"
\n
\n
"
*>
takeTill
isEndOfLine
translate
::
ByteString
->
ByteString
translate
::
ByteString
->
ByteString
translate
champs
translate
champs
...
...
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