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
c41cdec8
Commit
c41cdec8
authored
May 04, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARSERS] RIS PRESSE fix bug of \r
parent
c45062cb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
12 deletions
+12
-12
Convert.hs
src/Gargantext/Text/Convert.hs
+1
-0
Parsers.hs
src/Gargantext/Text/Parsers.hs
+6
-7
Date.hs
src/Gargantext/Text/Parsers/Date.hs
+3
-3
RIS.hs
src/Gargantext/Text/Parsers/RIS.hs
+1
-1
Presse.hs
src/Gargantext/Text/Parsers/RIS/Presse.hs
+1
-1
No files found.
src/Gargantext/Text/Convert.hs
View file @
c41cdec8
...
@@ -23,6 +23,7 @@ import Gargantext.Prelude
...
@@ -23,6 +23,7 @@ import Gargantext.Prelude
import
Gargantext.Text.Parsers.CSV
(
writeDocs2Csv
)
import
Gargantext.Text.Parsers.CSV
(
writeDocs2Csv
)
import
Gargantext.Text.Parsers
(
parseDocs
,
FileFormat
(
..
))
import
Gargantext.Text.Parsers
(
parseDocs
,
FileFormat
(
..
))
risPress2csv
::
FilePath
->
IO
()
risPress2csv
::
FilePath
->
IO
()
risPress2csv
f
=
parseDocs
RisPresse
(
f
<>
".ris"
)
risPress2csv
f
=
parseDocs
RisPresse
(
f
<>
".ris"
)
>>=
\
hs
->
writeDocs2Csv
(
f
<>
".csv"
)
hs
>>=
\
hs
->
writeDocs2Csv
(
f
<>
".csv"
)
hs
...
...
src/Gargantext/Text/Parsers.hs
View file @
c41cdec8
...
@@ -22,12 +22,13 @@ please follow the types.
...
@@ -22,12 +22,13 @@ please follow the types.
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers
(
parse
,
FileFormat
(
..
),
clean
,
parseDocs
,
risPress2csv
)
module
Gargantext.Text.Parsers
(
parse
,
FileFormat
(
..
),
clean
,
parseDocs
)
where
where
import
"zip"
Codec.Archive.Zip
(
withArchive
,
getEntry
,
getEntries
)
import
"zip"
Codec.Archive.Zip
(
withArchive
,
getEntry
,
getEntries
)
import
Control.Concurrent.Async
as
CCA
(
mapConcurrently
)
import
Control.Concurrent.Async
as
CCA
(
mapConcurrently
)
import
Control.Monad
(
join
)
import
Control.Monad
(
join
)
import
qualified
Data.ByteString.Char8
as
DBC
import
Data.Attoparsec.ByteString
(
parseOnly
,
Parser
)
import
Data.Attoparsec.ByteString
(
parseOnly
,
Parser
)
import
Data.Either
(
Either
(
..
))
import
Data.Either
(
Either
(
..
))
import
Data.Either.Extra
(
partitionEithers
)
import
Data.Either.Extra
(
partitionEithers
)
...
@@ -149,7 +150,7 @@ parse' :: FileFormat -> FilePath
...
@@ -149,7 +150,7 @@ parse' :: FileFormat -> FilePath
parse'
format
path
=
do
parse'
format
path
=
do
files
<-
case
takeExtension
path
of
files
<-
case
takeExtension
path
of
".zip"
->
openZip
path
".zip"
->
openZip
path
_
->
pure
<$>
DB
.
readFile
path
_
->
pure
<$>
clean
<$>
DB
.
readFile
path
partitionEithers
<$>
mapConcurrently
(
runParser
format
)
files
partitionEithers
<$>
mapConcurrently
(
runParser
format
)
files
...
@@ -174,13 +175,11 @@ openZip fp = do
...
@@ -174,13 +175,11 @@ openZip fp = do
bs
<-
mapConcurrently
(
\
s
->
withArchive
fp
(
getEntry
s
))
entries
bs
<-
mapConcurrently
(
\
s
->
withArchive
fp
(
getEntry
s
))
entries
pure
bs
pure
bs
clean
::
Text
->
Text
clean
::
DB
.
ByteString
->
DB
.
ByteString
clean
txt
=
D
T
.
map
clean'
txt
clean
txt
=
D
BC
.
map
clean'
txt
where
where
clean'
'’'
=
'
\'
'
clean'
'’'
=
'
\'
'
clean'
'
\r
'
=
' '
clean'
c
=
c
clean'
c
=
c
risPress2csv
f
=
parseDocs
RisPresse
(
f
<>
".ris"
)
>>=
\
hs
->
writeDocs2Csv
(
f
<>
".csv"
)
hs
src/Gargantext/Text/Parsers/Date.hs
View file @
c41cdec8
...
@@ -66,10 +66,10 @@ import qualified Text.ParserCombinators.Parsec (parse)
...
@@ -66,10 +66,10 @@ import qualified Text.ParserCombinators.Parsec (parse)
parseDate
::
Lang
->
Text
->
IO
UTCTime
parseDate
::
Lang
->
Text
->
IO
UTCTime
parseDate
lang
s
=
parseDate'
"%Y-%m-%dT%T"
"0-0-0T0:0:0"
lang
s
parseDate
lang
s
=
parseDate'
"%Y-%m-%dT%T"
"0-0-0T0:0:0"
lang
s
type
DateFormat
=
Text
type
DateFormat
=
Text
type
Date
Null
=
Text
type
Date
Default
=
Text
parseDate'
::
DateFormat
->
Date
Null
->
Lang
->
Text
->
IO
UTCTime
parseDate'
::
DateFormat
->
Date
Default
->
Lang
->
Text
->
IO
UTCTime
parseDate'
format
def
lang
s
=
do
parseDate'
format
def
lang
s
=
do
dateStr'
<-
parseDateRaw
lang
s
dateStr'
<-
parseDateRaw
lang
s
let
dateStr
=
unpack
$
maybe
def
identity
let
dateStr
=
unpack
$
maybe
def
identity
...
...
src/Gargantext/Text/Parsers/RIS.hs
View file @
c41cdec8
...
@@ -63,7 +63,7 @@ lines :: Parser [ByteString]
...
@@ -63,7 +63,7 @@ lines :: Parser [ByteString]
lines
=
many
line
lines
=
many
line
where
where
line
::
Parser
ByteString
line
::
Parser
ByteString
line
=
"
\n
\n
"
*>
takeTill
isEndOfLine
line
=
"
\n
"
*>
takeTill
isEndOfLine
-------------------------------------------------------------
-------------------------------------------------------------
withField
::
ByteString
->
(
ByteString
->
[(
ByteString
,
ByteString
)])
withField
::
ByteString
->
(
ByteString
->
[(
ByteString
,
ByteString
)])
...
...
src/Gargantext/Text/Parsers/RIS/Presse.hs
View file @
c41cdec8
...
@@ -54,7 +54,7 @@ parseDate = do
...
@@ -54,7 +54,7 @@ parseDate = do
presseLang
::
ByteString
->
[(
ByteString
,
ByteString
)]
presseLang
::
ByteString
->
[(
ByteString
,
ByteString
)]
presseLang
"Français"
=
[(
"language"
,
"FR"
)]
presseLang
"Français"
=
[(
"language"
,
"FR"
)]
presseLang
"English"
=
[(
"language"
,
"EN"
)]
presseLang
"English"
=
[(
"language"
,
"EN"
)]
presseLang
_
=
undefined
presseLang
x
=
[(
"language"
,
x
)]
presseFields
::
ByteString
->
ByteString
presseFields
::
ByteString
->
ByteString
...
...
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