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
3cabc48d
Commit
3cabc48d
authored
Jan 27, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPLOAD] adding CSV Garg v3 parser.
parent
2044f66d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
New.hs
src/Gargantext/API/Corpus/New.hs
+10
-4
File.hs
src/Gargantext/API/Corpus/New/File.hs
+2
-1
CSV.hs
src/Gargantext/Text/Corpus/Parsers/CSV.hs
+3
-0
No files found.
src/Gargantext/API/Corpus/New.hs
View file @
3cabc48d
...
...
@@ -43,7 +43,7 @@ import Gargantext.Database.Types.Node (CorpusId)
import
Gargantext.Database.Types.Node
(
ToHyperdataDocument
(
..
))
import
Gargantext.Database.Types.Node
(
UserId
)
import
Gargantext.Prelude
import
Gargantext.Text.Corpus.Parsers.CSV
(
parse
Hal
'
)
import
Gargantext.Text.Corpus.Parsers.CSV
(
parse
Csv'
)
--parseHal')--, parseCsv
')
import
Gargantext.Text.Terms
(
TermType
(
..
))
import
Servant
import
Servant.API.Flatten
(
Flat
)
...
...
@@ -221,11 +221,17 @@ addToCorpusWithForm :: FlowCmdM env err m
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
addToCorpusWithForm
cid
(
WithForm
_
ft
d
)
logStatus
=
do
addToCorpusWithForm
cid
(
WithForm
ft
d
)
logStatus
=
do
let
docs
=
splitEvery
500
let
parse
=
case
ft
of
Just
CSV_HAL
->
parseHal'
Just
CSV
->
parseCsv'
_
->
parseHal'
docs
=
splitEvery
500
$
take
1000000
$
parse
Hal
'
(
cs
d
)
$
parse
Csv
'
(
cs
d
)
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
...
...
src/Gargantext/API/Corpus/New/File.hs
View file @
3cabc48d
...
...
@@ -48,7 +48,7 @@ import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
-------------------------------------------------------------
type
Hash
=
Text
data
FileType
=
CSV
|
PresseRIS
data
FileType
=
CSV
|
CSV_HAL
|
PresseRIS
deriving
(
Eq
,
Show
,
Generic
)
instance
ToSchema
FileType
...
...
@@ -65,6 +65,7 @@ instance ToParamSchema (MultipartData Mem) where
instance
FromHttpApiData
FileType
where
parseUrlPiece
"CSV"
=
pure
CSV
parseUrlPiece
"CSV_HAL"
=
pure
CSV_HAL
parseUrlPiece
"PresseRis"
=
pure
PresseRIS
parseUrlPiece
_
=
pure
CSV
-- TODO error here
...
...
src/Gargantext/Text/Corpus/Parsers/CSV.hs
View file @
3cabc48d
...
...
@@ -396,3 +396,6 @@ parseHal' = V.toList . V.map csvHal2doc . snd . readCsvHalLazyBS
parseCsv
::
FilePath
->
IO
[
HyperdataDocument
]
parseCsv
fp
=
V
.
toList
<$>
V
.
map
csv2doc
<$>
snd
<$>
readFile
fp
parseCsv'
::
BL
.
ByteString
->
[
HyperdataDocument
]
parseCsv'
bs
=
V
.
toList
$
V
.
map
csv2doc
$
snd
$
readCsvLazyBS
bs
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