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
5386816c
Commit
5386816c
authored
Nov 29, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARSERS] Patent analysis demo for seminar at IHEDN.
parent
3dcdd2db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
CSV.hs
src/Gargantext/Text/Parsers/CSV.hs
+10
-0
Json2Csv.hs
src/Gargantext/Text/Parsers/Json2Csv.hs
+60
-0
No files found.
src/Gargantext/Text/Parsers/CSV.hs
View file @
5386816c
...
...
@@ -38,6 +38,16 @@ import Gargantext.Text
import
Gargantext.Text.Context
import
Gargantext.Prelude
hiding
(
length
)
---------------------------------------------------------------
headerCsvGargV3
::
Header
headerCsvGargV3
=
header
[
"title"
,
"source"
,
"publication_year"
,
"publication_month"
,
"publication_day"
,
"abstract"
,
"authors"
]
---------------------------------------------------------------
data
Doc
=
Doc
{
d_docId
::
!
Int
...
...
src/Gargantext/Text/Parsers/Json2Csv.hs
0 → 100644
View file @
5386816c
{-|
Module : Gargantext.Text.Parsers.Json2Csv
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Json parser to export towoard CSV GargV3 format.
(Export from the Patent Database.)
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Text.Parsers.Json2Csv
(
json2csv
,
readPatents
)
where
import
Prelude
(
read
)
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.ByteString.Lazy
(
readFile
)
import
Data.Text
(
Text
,
unpack
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Prelude
import
System.IO
(
FilePath
)
import
Gargantext.Text.Parsers.CSV
(
CsvDoc
(
..
),
writeCsv
,
headerCsvGargV3
)
import
Data.Vector
(
fromList
)
data
Patent
=
Patent
{
_patent_title
::
Text
,
_patent_abstract
::
Text
,
_patent_year
::
Text
,
_patent_id
::
Text
}
deriving
(
Show
)
$
(
deriveJSON
(
unPrefix
"_patent_"
)
''
P
atent
)
readPatents
::
FilePath
->
IO
(
Maybe
[
Patent
])
readPatents
fp
=
decode
<$>
readFile
fp
type
FilePathIn
=
FilePath
type
FilePathOut
=
FilePath
json2csv
::
FilePathIn
->
FilePathOut
->
IO
()
json2csv
fin
fout
=
do
patents
<-
maybe
(
panic
"json2csv error"
)
identity
<$>
readPatents
fin
writeCsv
fout
(
headerCsvGargV3
,
fromList
$
map
patent2csvDoc
patents
)
patent2csvDoc
::
Patent
->
CsvDoc
patent2csvDoc
(
Patent
title
abstract
year
_
)
=
CsvDoc
title
"Source"
(
read
(
unpack
year
))
1
1
abstract
"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