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
5722575b
Commit
5722575b
authored
Jan 27, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Lang to upload + instances
parent
5da469ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
New.hs
src/Gargantext/API/Corpus/New.hs
+12
-6
File.hs
src/Gargantext/API/Corpus/New/File.hs
+4
-1
Core.hs
src/Gargantext/Core.hs
+9
-1
No files found.
src/Gargantext/API/Corpus/New.hs
View file @
5722575b
...
...
@@ -29,6 +29,7 @@ import Control.Lens hiding (elements)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Either
import
Data.Swagger
import
Data.Text
(
Text
)
...
...
@@ -43,7 +44,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
(
FileFormat
(
..
),
parseFormat
)
import
qualified
Gargantext.Text.Corpus.Parsers
as
Parser
(
FileFormat
(
..
),
parseFormat
)
import
Gargantext.Text.Terms
(
TermType
(
..
))
import
Servant
import
Servant.API.Flatten
(
Flat
)
...
...
@@ -127,6 +128,7 @@ instance ToSchema WithQuery where
data
WithForm
=
WithForm
{
_wf_filetype
::
!
FileType
,
_wf_data
::
!
Text
,
_wf_lang
::
!
(
Maybe
Lang
)
}
deriving
(
Eq
,
Show
,
Generic
)
makeLenses
''
W
ithForm
...
...
@@ -221,15 +223,16 @@ addToCorpusWithForm :: FlowCmdM env err m
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
addToCorpusWithForm
cid
(
WithForm
ft
d
)
logStatus
=
do
addToCorpusWithForm
cid
(
WithForm
ft
d
l
)
logStatus
=
do
printDebug
"ft"
ft
let
parse
=
case
ft
of
CSV_HAL
->
parseFormat
CsvHal
CSV
->
parseFormat
CsvGargV3
_
->
parseFormat
CsvHal
CSV_HAL
->
Parser
.
parseFormat
Parser
.
CsvHal
CSV
->
Parser
.
parseFormat
Parser
.
CsvGargV3
WOS
->
Parser
.
parseFormat
Parser
.
WOS
PresseRIS
->
Parser
.
parseFormat
Parser
.
RisPresse
docs
<-
liftIO
$
splitEvery
500
...
...
@@ -241,8 +244,11 @@ addToCorpusWithForm cid (WithForm ft d) logStatus = do
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
cid'
<-
flowCorpus
"user1"
(
Right
[
cid
])
(
Multi
$
fromMaybe
EN
l
)
(
map
(
map
toHyperdataDocument
)
docs
)
cid'
<-
flowCorpus
"user1"
(
Right
[
cid
])
(
Multi
EN
)
(
map
(
map
toHyperdataDocument
)
docs
)
printDebug
"cid'"
cid'
pure
ScraperStatus
{
_scst_succeeded
=
Just
2
...
...
src/Gargantext/API/Corpus/New/File.hs
View file @
5722575b
...
...
@@ -48,7 +48,10 @@ import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
-------------------------------------------------------------
type
Hash
=
Text
data
FileType
=
CSV
|
CSV_HAL
|
PresseRIS
data
FileType
=
CSV
|
CSV_HAL
|
PresseRIS
|
WOS
deriving
(
Eq
,
Show
,
Generic
)
instance
ToSchema
FileType
...
...
src/Gargantext/Core.hs
View file @
5722575b
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Core
where
...
...
@@ -19,7 +20,9 @@ module Gargantext.Core
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Data.Aeson
import
Data.Either
(
Either
(
Left
))
import
Data.Swagger
import
Servant.API
------------------------------------------------------------------------
-- | Language of a Text
-- For simplicity, we suppose text has an homogenous language
...
...
@@ -42,6 +45,11 @@ data Lang = EN | FR | All
instance
ToJSON
Lang
instance
FromJSON
Lang
instance
ToSchema
Lang
instance
FromHttpApiData
Lang
where
parseUrlPiece
"EN"
=
pure
EN
parseUrlPiece
"FR"
=
pure
FR
parseUrlPiece
"All"
=
pure
All
parseUrlPiece
_
=
Left
"Unexpected value of OrderBy"
allLangs
::
[
Lang
]
allLangs
=
[
minBound
..
]
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