Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
154
Issues
154
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
haskell-gargantext
Commits
d2029ea7
Commit
d2029ea7
authored
5 years ago
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] CSV
parent
9ba39267
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
16 deletions
+15
-16
Flow.hs
src/Gargantext/Database/Flow.hs
+2
-2
Convert.hs
src/Gargantext/Text/Convert.hs
+6
-4
Parsers.hs
src/Gargantext/Text/Parsers.hs
+6
-7
CSV.hs
src/Gargantext/Text/Parsers/CSV.hs
+1
-3
No files found.
src/Gargantext/Database/Flow.hs
View file @
d2029ea7
...
...
@@ -59,7 +59,7 @@ import Gargantext.Ext.IMT (toSchoolName)
import
Gargantext.Ext.IMTUser
(
deserialiseImtUsersFromFile
)
import
Gargantext.Prelude
import
Gargantext.Text.List
(
buildNgramsLists
,
StopSize
(
..
))
import
Gargantext.Text.Parsers
(
parse
Docs
,
FileFormat
)
import
Gargantext.Text.Parsers
(
parse
File
,
FileFormat
)
import
Gargantext.Text.Terms
(
TermType
(
..
),
tt_lang
)
import
Gargantext.Text.Terms
(
extractTerms
)
import
Gargantext.Text.Terms.Mono.Stem.En
(
stemIt
)
...
...
@@ -114,7 +114,7 @@ flowCorpusFile :: FlowCmdM env ServantErr m
flowCorpusFile
u
n
l
la
ff
fp
=
do
docs
<-
liftIO
(
splitEvery
500
<$>
take
l
<$>
parse
Docs
ff
fp
<$>
parse
File
ff
fp
)
flowCorpus
u
n
la
(
map
(
map
toHyperdataDocument
)
docs
)
...
...
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Convert.hs
View file @
d2029ea7
...
...
@@ -15,16 +15,18 @@ Format Converter.
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Convert
(
risPress2csv
)
module
Gargantext.Text.Convert
(
risPress2csv
Write
)
where
import
System.FilePath
(
FilePath
())
-- , takeExtension)
import
Gargantext.Prelude
import
Gargantext.Text.Parsers.CSV
(
writeDocs2Csv
)
import
Gargantext.Text.Parsers
(
parse
Docs
,
FileFormat
(
..
))
import
Gargantext.Text.Parsers
(
parse
File
,
FileFormat
(
..
))
risPress2csv
::
FilePath
->
IO
()
risPress2csv
f
=
parseDocs
RisPresse
(
f
<>
".ris"
)
risPress2csv
Write
::
FilePath
->
IO
()
risPress2csv
Write
f
=
parseFile
RisPresse
(
f
<>
".ris"
)
>>=
\
hs
->
writeDocs2Csv
(
f
<>
".csv"
)
hs
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Parsers.hs
View file @
d2029ea7
...
...
@@ -22,7 +22,7 @@ please follow the types.
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers
(
parse
,
FileFormat
(
..
),
clean
,
parse
Docs
)
module
Gargantext.Text.Parsers
(
parse
,
FileFormat
(
..
),
clean
,
parse
File
)
where
import
"zip"
Codec.Archive.Zip
(
withArchive
,
getEntry
,
getEntries
)
...
...
@@ -84,11 +84,11 @@ data FileFormat = WOS | RIS | RisPresse
-- | Parse file into documents
-- TODO manage errors here
parse
Docs
::
FileFormat
->
FilePath
->
IO
[
HyperdataDocument
]
parse
Docs
CsvHalFormat
p
=
parseHal
p
parse
Docs
RisPresse
p
=
join
$
mapM
(
toDoc
RIS
)
<$>
snd
<$>
enrichWith
presseEnrich
<$>
parse'
RIS
p
parse
Docs
WOS
p
=
join
$
mapM
(
toDoc
WOS
)
<$>
snd
<$>
enrichWith
(
map
(
first
WOS
.
keys
))
<$>
parse'
WOS
p
parse
Docs
ff
p
=
join
$
mapM
(
toDoc
ff
)
<$>
snd
<$>
parse
ff
p
parse
File
::
FileFormat
->
FilePath
->
IO
[
HyperdataDocument
]
parse
File
CsvHalFormat
p
=
parseHal
p
parse
File
RisPresse
p
=
join
$
mapM
(
toDoc
RIS
)
<$>
snd
<$>
enrichWith
presseEnrich
<$>
parse'
RIS
p
parse
File
WOS
p
=
join
$
mapM
(
toDoc
WOS
)
<$>
snd
<$>
enrichWith
(
map
(
first
WOS
.
keys
))
<$>
parse'
WOS
p
parse
File
ff
p
=
join
$
mapM
(
toDoc
ff
)
<$>
snd
<$>
parse
ff
p
type
Year
=
Int
type
Month
=
Int
...
...
@@ -182,4 +182,3 @@ clean txt = DBC.map clean' txt
clean'
'
\r
'
=
' '
clean'
c
=
c
This diff is collapsed.
Click to expand it.
src/Gargantext/Text/Parsers/CSV.hs
View file @
d2029ea7
...
...
@@ -229,8 +229,7 @@ writeCsv fp (h, vs) = BL.writeFile fp $
encodeByNameWith
csvEncodeOptions
h
(
V
.
toList
vs
)
writeDocs2Csv
::
FilePath
->
[
HyperdataDocument
]
->
IO
()
writeDocs2Csv
fp
hs
=
BL
.
writeFile
fp
$
encodeByNameWith
csvEncodeOptions
headerCsvGargV3
(
map
hyperdataDocument2csvDoc
hs
)
writeDocs2Csv
fp
hs
=
BL
.
writeFile
fp
$
hyperdataDocument2csv
hs
hyperdataDocument2csv
::
[
HyperdataDocument
]
->
BL
.
ByteString
hyperdataDocument2csv
hs
=
encodeByNameWith
csvEncodeOptions
headerCsvGargV3
(
map
hyperdataDocument2csvDoc
hs
)
...
...
@@ -346,4 +345,3 @@ parseHal :: FilePath -> IO [HyperdataDocument]
parseHal
fp
=
map
csvHal2doc
<$>
V
.
toList
<$>
snd
<$>
readHal
fp
------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
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