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
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
6dcedcdc
Commit
6dcedcdc
authored
Apr 14, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Clean] before factoring
parent
30386057
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
50 deletions
+44
-50
New.hs
src/Gargantext/API/Corpus/New.hs
+18
-30
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+1
-16
Learn.hs
src/Gargantext/Database/Action/Learn.hs
+3
-3
Tree.hs
src/Gargantext/Database/Action/Query/Tree.hs
+10
-0
GrandDebat.hs
src/Gargantext/Text/Corpus/Parsers/GrandDebat.hs
+12
-1
No files found.
src/Gargantext/API/Corpus/New.hs
View file @
6dcedcdc
...
...
@@ -54,6 +54,7 @@ import Test.QuickCheck.Arbitrary
import
Web.FormUrlEncoded
(
FromForm
)
import
qualified
Gargantext.Text.Corpus.API
as
API
------------------------------------------------------------------------
data
Query
=
Query
{
query_query
::
Text
,
query_corpus_id
::
Int
,
query_databases
::
[
API
.
ExternalAPIs
]
...
...
@@ -64,7 +65,8 @@ deriveJSON (unPrefix "query_") 'Query
instance
Arbitrary
Query
where
arbitrary
=
elements
[
Query
q
n
fs
|
q
<-
[
"a"
,
"b"
]
|
q
<-
[
"honeybee* AND collopase"
,
"covid 19"
]
,
n
<-
[
0
..
10
]
,
fs
<-
take
3
$
repeat
API
.
externalAPIs
]
...
...
@@ -85,6 +87,7 @@ type GetApi = Get '[JSON] ApiInfo
-- | TODO manage several apis
-- TODO-ACCESS
-- TODO this is only the POST
{-
api :: (FlowCmdM env err m) => UserId -> Query -> m CorpusId
api uid (Query q _ as) = do
cId <- case head as of
...
...
@@ -96,8 +99,10 @@ api uid (Query q _ as) = do
pure cId'
pure cId
-}
------------------------------------------------
-- TODO use this route for Client implementation
data
ApiInfo
=
ApiInfo
{
api_info
::
[
API
.
ExternalAPIs
]}
deriving
(
Generic
)
instance
Arbitrary
ApiInfo
where
...
...
@@ -147,35 +152,35 @@ type AsyncJobs event ctI input output =
type
Upload
=
Summary
"Corpus Upload endpoint"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:<|>
"addWithquery"
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
:<|>
"addWithfile"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
:>
Capture
"corpus_id"
CorpusId
:<|>
"addWithquery"
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
:<|>
"addWithfile"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
type
AddWithQuery
=
Summary
"Add with Query to corpus endpoint"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:>
Capture
"corpus_id"
CorpusId
:>
"add"
:>
"query"
:>
"async"
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
type
AddWithFile
=
Summary
"Add with MultipartData to corpus endpoint"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:>
"add"
:>
Capture
"corpus_id"
CorpusId
:>
"add"
:>
"file"
:>
MultipartForm
Mem
(
MultipartData
Mem
)
:>
QueryParam
"fileType"
FileType
:>
MultipartForm
Mem
(
MultipartData
Mem
)
:>
QueryParam
"fileType"
FileType
:>
"async"
:>
AsyncJobs
ScraperStatus
'[
J
SON
]
()
ScraperStatus
:>
AsyncJobs
ScraperStatus
'[
J
SON
]
()
ScraperStatus
type
AddWithForm
=
Summary
"Add with FormUrlEncoded to corpus endpoint"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:>
Capture
"corpus_id"
CorpusId
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
------------------------------------------------------------------------
-- TODO WithQuery also has a corpus id
...
...
@@ -227,23 +232,6 @@ addToCorpusWithFile cid input filetype logStatus = do
,
_scst_events
=
Just
[]
}
{- | Model to fork the flow
-- This is not really optimized since it increases the need RAM
-- and freezes the whole system
-- This is mainly for documentation (see a better solution in the function below)
-- Each process has to be tailored
addToCorpusWithForm' :: FlowCmdM env err m
=> CorpusId
-> WithForm
-> (ScraperStatus -> m ())
-> m ScraperStatus
addToCorpusWithForm' cid (WithForm ft d l) logStatus = do
newStatus <- liftBase newEmptyMVar
s <- addToCorpusWithForm cid (WithForm ft d l) logStatus
_ <- liftBase $ forkIO $ putMVar newStatus s
s' <- liftBase $ takeMVar newStatus
pure s'
-}
addToCorpusWithForm
::
FlowCmdM
env
err
m
=>
User
->
CorpusId
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
6dcedcdc
...
...
@@ -71,7 +71,6 @@ import Gargantext.Database.Schema.NodeNodeNgrams2 -- (NodeNodeNgrams2, insertNod
import
Gargantext.Ext.IMT
(
toSchoolName
)
import
Gargantext.Ext.IMTUser
(
deserialiseImtUsersFromFile
)
import
Gargantext.Prelude
import
Gargantext.Prelude.Utils
hiding
(
sha
)
import
Gargantext.Text.Corpus.Parsers
(
parseFile
,
FileFormat
)
import
Gargantext.Text.List
(
buildNgramsLists
,
StopSize
(
..
))
import
Gargantext.Text.Terms
(
TermType
(
..
),
tt_lang
,
extractTerms
,
uniText
)
...
...
@@ -84,7 +83,6 @@ import qualified Data.Map as Map
import
qualified
Data.Text
as
Text
import
qualified
Gargantext.Database.Action.Query.Node.Document.Add
as
Doc
(
add
)
import
qualified
Gargantext.Text.Corpus.API.Isidore
as
Isidore
import
qualified
Gargantext.Text.Corpus.Parsers.GrandDebat
as
GD
------------------------------------------------------------------------
...
...
@@ -111,7 +109,6 @@ _flowCorpusApi u n tt l q = do
flowCorpus
u
n
tt
docs
------------------------------------------------------------------------
flowAnnuaire
::
FlowCmdM
env
err
m
=>
User
->
Either
CorpusName
[
CorpusId
]
...
...
@@ -121,19 +118,7 @@ flowAnnuaire :: FlowCmdM env err m
flowAnnuaire
u
n
l
filePath
=
do
docs
<-
liftBase
$
((
splitEvery
500
<$>
deserialiseImtUsersFromFile
filePath
)
::
IO
[[
HyperdataContact
]])
flow
(
Nothing
::
Maybe
HyperdataAnnuaire
)
u
n
l
docs
-- UNUSED
_flowCorpusDebat
::
FlowCmdM
env
err
m
=>
User
->
Either
CorpusName
[
CorpusId
]
->
Limit
->
FilePath
->
m
CorpusId
_flowCorpusDebat
u
n
l
fp
=
do
docs
<-
liftBase
(
splitEvery
500
<$>
take
l
<$>
readFile'
fp
::
IO
[[
GD
.
GrandDebatReference
]]
)
flowCorpus
u
n
(
Multi
FR
)
(
map
(
map
toHyperdataDocument
)
docs
)
------------------------------------------------------------------------
flowCorpusFile
::
FlowCmdM
env
err
m
=>
User
->
Either
CorpusName
[
CorpusId
]
...
...
src/Gargantext/Database/Action/Learn.hs
View file @
6dcedcdc
...
...
@@ -44,13 +44,13 @@ moreLike cId o l order ft = do
---------------------------------------------------------------------------
getPriors
::
FavOrTrash
->
CorpusId
->
Cmd
err
(
Events
Bool
)
getPriors
ft
cId
=
do
docs_fav
<-
filter
(
\
(
FacetDoc
_
_
_
_
f
_
)
->
f
==
Just
2
)
<$>
runViewDocuments
cId
False
Nothing
Nothing
Nothing
docs_trash
<-
List
.
take
(
List
.
length
docs_fav
)
<$>
runViewDocuments
cId
True
Nothing
Nothing
Nothing
let
priors
=
priorEventsWith
text
(
fav2bool
ft
)
(
List
.
zip
(
repeat
False
)
docs_fav
<>
List
.
zip
(
repeat
True
)
docs_trash
...
...
src/Gargantext/Database/Action/Query/Tree.hs
View file @
6dcedcdc
...
...
@@ -34,6 +34,16 @@ import Gargantext.Database.Admin.Types.Node (NodeId, NodeType, DocId, allNodeTyp
import
Gargantext.Database.Admin.Utils
(
Cmd
,
runPGSQuery
)
import
Gargantext.Prelude
------------------------------------------------------------------------
findCorpus
::
RootId
->
Cmd
err
(
Maybe
CorpusId
)
findCorpus
r
=
do
_mapNodes
<-
toTreeParent
<$>
dbTree
r
[]
pure
Nothing
------------------------------------------------------------------------
data
TreeError
=
NoRoot
|
EmptyRoot
|
TooManyRoots
deriving
(
Show
)
...
...
src/Gargantext/Text/Corpus/Parsers/GrandDebat.hs
View file @
6dcedcdc
...
...
@@ -7,7 +7,18 @@ Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
TODO: create a separate Lib.
_flowCorpusDebat :: FlowCmdM env err m
=> User -> Either CorpusName [CorpusId]
-> Limit -> FilePath
-> m CorpusId
_flowCorpusDebat u n l fp = do
docs <- liftBase ( splitEvery 500
<$> take l
<$> readFile' fp
:: IO [[GD.GrandDebatReference ]]
)
flowCorpus u n (Multi FR) (map (map toHyperdataDocument) docs)
-}
...
...
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