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
198
Issues
198
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
c9ce9c6f
Commit
c9ce9c6f
authored
Jun 15, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EXT/API] Isidore.
parent
846d21f5
Pipeline
#474
canceled with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
2 deletions
+96
-2
Parsers.hs
src/Gargantext/Text/Parsers.hs
+6
-1
IsidoreApi.hs
src/Gargantext/Text/Parsers/IsidoreApi.hs
+89
-0
stack.yaml
stack.yaml
+1
-1
No files found.
src/Gargantext/Text/Parsers.hs
View file @
c9ce9c6f
...
@@ -22,7 +22,7 @@ please follow the types.
...
@@ -22,7 +22,7 @@ please follow the types.
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers
(
FileFormat
(
..
),
clean
,
parseFile
)
module
Gargantext.Text.Parsers
(
FileFormat
(
..
),
clean
,
parseFile
,
cleanText
)
where
where
--import Data.ByteString (ByteString)
--import Data.ByteString (ByteString)
...
@@ -164,9 +164,14 @@ openZip fp = do
...
@@ -164,9 +164,14 @@ openZip fp = do
bs
<-
mapConcurrently
(
\
s
->
withArchive
fp
(
getEntry
s
))
entries
bs
<-
mapConcurrently
(
\
s
->
withArchive
fp
(
getEntry
s
))
entries
pure
bs
pure
bs
cleanText
::
Text
->
Text
cleanText
=
cs
.
clean
.
cs
clean
::
DB
.
ByteString
->
DB
.
ByteString
clean
::
DB
.
ByteString
->
DB
.
ByteString
clean
txt
=
DBC
.
map
clean'
txt
clean
txt
=
DBC
.
map
clean'
txt
where
where
clean'
'’'
=
'
\'
'
clean'
'’'
=
'
\'
'
clean'
'
\r
'
=
' '
clean'
'
\r
'
=
' '
clean'
'
\t
'
=
' '
clean'
';'
=
'.'
clean'
c
=
c
clean'
c
=
c
src/Gargantext/Text/Parsers/IsidoreApi.hs
0 → 100644
View file @
c9ce9c6f
{-|
Module : Gargantext.Text.Parsers.IsidoreApi
Description : To query French Humanities publication database from its API
Copyright : (c) CNRS, 2019-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Parsers.IsidoreApi
where
import
System.FilePath
(
FilePath
())
import
Data.Text
(
Text
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
Gargantext.Prelude
import
Isidore.Client
import
Servant.Client
import
qualified
Data.Text
as
Text
import
qualified
Gargantext.Text.Parsers.Date
as
Date
import
qualified
Isidore
as
Isidore
import
Gargantext.Text.Parsers.CSV
(
writeDocs2Csv
)
import
Gargantext.Text.Parsers
(
cleanText
)
-- | TODO work with the ServantErr
get
::
Lang
->
Maybe
Isidore
.
Limit
->
Maybe
Isidore
.
TextQuery
->
Maybe
Isidore
.
AuthorQuery
->
IO
[
HyperdataDocument
]
get
la
l
q
a
=
do
let
printErr
(
DecodeFailure
e
_
)
=
panic
e
printErr
e
=
panic
(
cs
$
show
e
)
iDocs
<-
either
printErr
(
_docs
)
<$>
Isidore
.
get
l
q
a
hDocs
<-
mapM
(
\
d
->
isidoreToDoc
la
d
)
iDocs
pure
hDocs
isidore2csvFile
::
FilePath
->
Lang
->
Maybe
Isidore
.
Limit
->
Maybe
Isidore
.
TextQuery
->
Maybe
Isidore
.
AuthorQuery
->
IO
()
isidore2csvFile
fp
la
li
tq
aq
=
do
hdocs
<-
get
la
li
tq
aq
writeDocs2Csv
fp
hdocs
isidoreToDoc
::
Lang
->
IsidoreDoc
->
IO
HyperdataDocument
isidoreToDoc
l
(
IsidoreDoc
t
a
d
u
s
as
)
=
do
let
author
::
Author
->
Text
author
(
Author
fn
ln
)
=
(
_name
fn
)
<>
", "
<>
(
_name
ln
)
author
(
Authors
aus
)
=
Text
.
intercalate
". "
$
map
author
aus
creator2text
::
Creator
->
Text
creator2text
(
Creator
au
)
=
author
au
creator2text
(
Creators
aus'
)
=
Text
.
intercalate
". "
$
map
author
aus'
langText
::
LangText
->
Text
langText
(
LangText
_l
t1
)
=
t1
langText
(
OnlyText
t2
)
=
t2
langText
(
ArrayText
ts
)
=
Text
.
intercalate
" "
$
map
langText
ts
(
utcTime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
split
l
(
maybe
(
Just
"2019"
)
(
Just
)
d
)
pure
$
HyperdataDocument
(
Just
"IsidoreApi"
)
Nothing
u
Nothing
Nothing
Nothing
(
Just
$
cleanText
$
langText
t
)
Nothing
(
creator2text
<$>
as
)
(
_sourceName
<$>
s
)
(
cleanText
<$>
langText
<$>
a
)
(
fmap
(
Text
.
pack
.
show
)
utcTime
)
(
pub_year
)
(
pub_month
)
(
pub_day
)
Nothing
Nothing
Nothing
(
Just
$
(
Text
.
pack
.
show
)
l
)
stack.yaml
View file @
c9ce9c6f
...
@@ -33,7 +33,7 @@ extra-deps:
...
@@ -33,7 +33,7 @@ extra-deps:
-
git
:
https://github.com/delanoe/hsparql.git
-
git
:
https://github.com/delanoe/hsparql.git
commit
:
308c74b71a1abb0a91546fa57d353131248e3a7f
commit
:
308c74b71a1abb0a91546fa57d353131248e3a7f
-
git
:
https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git
-
git
:
https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git
commit
:
884906b4617955223ad83615ab04fae78d9476db
commit
:
069118b29198ee1044a685d8c08dcfb242d601e3
-
KMP-0.1.0.2
-
KMP-0.1.0.2
-
accelerate-1.2.0.0
-
accelerate-1.2.0.0
-
aeson-lens-0.5.0.0
-
aeson-lens-0.5.0.0
...
...
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