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
200
Issues
200
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
b388c75e
Verified
Commit
b388c75e
authored
Jun 26, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 471-dev-node-multiterms
parents
7971d93c
d362b468
Pipeline
#7699
failed with stages
in 43 minutes and 30 seconds
Changes
25
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
121 additions
and
285 deletions
+121
-285
Routes.hs
bin/gargantext-cli/CLI/Server/Routes.hs
+2
-2
update-project-dependencies
bin/update-project-dependencies
+2
-2
cabal.project
cabal.project
+1
-1
gargantext.cabal
gargantext.cabal
+0
-3
Count.hs
src/Gargantext/API/Count.hs
+0
-33
Types.hs
src/Gargantext/API/Count/Types.hs
+0
-142
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+0
-1
Context.hs
src/Gargantext/API/GraphQL/Context.hs
+5
-5
List.hs
src/Gargantext/API/Ngrams/List.hs
+7
-4
Node.hs
src/Gargantext/API/Node.hs
+18
-19
Corpus.hs
src/Gargantext/API/Routes/Named/Corpus.hs
+1
-1
Count.hs
src/Gargantext/API/Routes/Named/Count.hs
+0
-18
Private.hs
src/Gargantext/API/Routes/Named/Private.hs
+10
-14
Remote.hs
src/Gargantext/API/Routes/Named/Remote.hs
+17
-9
Share.hs
src/Gargantext/API/Routes/Named/Share.hs
+1
-1
Search.hs
src/Gargantext/API/Search.hs
+1
-1
Private.hs
src/Gargantext/API/Server/Named/Private.hs
+0
-2
Terms.hs
src/Gargantext/Core/Text/Terms.hs
+2
-2
Multi.hs
src/Gargantext/Core/Text/Terms/Multi.hs
+21
-2
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+13
-8
Extract.hs
src/Gargantext/Database/Action/Flow/Extract.hs
+6
-6
Types.hs
src/Gargantext/Database/Action/Flow/Types.hs
+4
-6
NodeContext.hs
src/Gargantext/Database/Query/Table/NodeContext.hs
+2
-2
stack.yaml
stack.yaml
+1
-1
Instances.hs
test/Test/Instances.hs
+7
-0
No files found.
bin/gargantext-cli/CLI/Server/Routes.hs
View file @
b388c75e
...
@@ -14,8 +14,8 @@ import Data.Aeson.Encode.Pretty
...
@@ -14,8 +14,8 @@ import Data.Aeson.Encode.Pretty
import
Data.ByteString
qualified
as
B
import
Data.ByteString
qualified
as
B
import
Data.ByteString.Lazy
qualified
as
BL
import
Data.ByteString.Lazy
qualified
as
BL
import
Gargantext.API.Routes.Named
import
Gargantext.API.Routes.Named
import
Gargantext.Prelude
import
Options.Applicative
import
Options.Applicative
import
Prelude
import
Servant.API
import
Servant.API
import
Servant.API.Routes
import
Servant.API.Routes
import
Servant.API.WebSocket
qualified
as
WS
(
WebSocketPending
)
import
Servant.API.WebSocket
qualified
as
WS
(
WebSocketPending
)
...
@@ -52,6 +52,6 @@ instance HasRoutes Raw where
...
@@ -52,6 +52,6 @@ instance HasRoutes Raw where
routesCLI
::
CLIRoutes
->
IO
()
routesCLI
::
CLIRoutes
->
IO
()
routesCLI
=
\
case
routesCLI
=
\
case
CLIR_list
CLIR_list
->
printRoutes
@
(
NamedRoutes
API
)
->
printRoutes
Sorted
@
(
NamedRoutes
API
)
(
CLIR_export
filePath
)
(
CLIR_export
filePath
)
->
B
.
writeFile
filePath
.
BL
.
toStrict
$
encodePretty
(
getRoutes
@
(
NamedRoutes
API
))
->
B
.
writeFile
filePath
.
BL
.
toStrict
$
encodePretty
(
getRoutes
@
(
NamedRoutes
API
))
bin/update-project-dependencies
View file @
b388c75e
...
@@ -16,8 +16,8 @@ fi
...
@@ -16,8 +16,8 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and
# with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in.
# cache can kick in.
expected_cabal_project_hash
=
"
7d021a8e3d0b68421e26bdfe4e1da82f6ea26b6c420fc984b3c30c14bc5fea9
8"
expected_cabal_project_hash
=
"
c7e0466c8d4c1ca88b4f3d62d022bd29329d44afc48fffbcfacf0f65293acba
8"
expected_cabal_project_freeze_hash
=
"553b98aadb35506a305bd740cdd71f5fadc1e6d55d10f91cf39daa6735a63d78"
expected_cabal_project_freeze_hash
=
"553b98aadb35506a305bd740cdd71f5fadc1e6d55d10f91cf39daa6735a63d78"
cabal
--store-dir
=
$STORE_DIR
v2-build
--dry-run
cabal
--store-dir
=
$STORE_DIR
v2-build
--dry-run
...
...
cabal.project
View file @
b388c75e
...
@@ -146,7 +146,7 @@ source-repository-package
...
@@ -146,7 +146,7 @@ source-repository-package
source
-
repository
-
package
source
-
repository
-
package
type
:
git
type
:
git
location
:
https
://
github
.
com
/
fpringle
/
servant
-
routes
.
git
location
:
https
://
github
.
com
/
fpringle
/
servant
-
routes
.
git
tag
:
7694f62
af6bc1596d754b42af16da131ac403b3a
tag
:
c3c558d9278ef239a474f1e1b69afc461be60d01
source
-
repository
-
package
source
-
repository
-
package
type
:
git
type
:
git
...
...
gargantext.cabal
View file @
b388c75e
...
@@ -120,7 +120,6 @@ library
...
@@ -120,7 +120,6 @@ library
Gargantext.API.Admin.Orchestrator.Types
Gargantext.API.Admin.Orchestrator.Types
Gargantext.API.Admin.Settings
Gargantext.API.Admin.Settings
Gargantext.API.Auth.PolicyCheck
Gargantext.API.Auth.PolicyCheck
Gargantext.API.Count.Types
Gargantext.API.Dev
Gargantext.API.Dev
Gargantext.API.Errors
Gargantext.API.Errors
Gargantext.API.Errors.Class
Gargantext.API.Errors.Class
...
@@ -166,7 +165,6 @@ library
...
@@ -166,7 +165,6 @@ library
Gargantext.API.Routes.Named.Contact
Gargantext.API.Routes.Named.Contact
Gargantext.API.Routes.Named.Context
Gargantext.API.Routes.Named.Context
Gargantext.API.Routes.Named.Corpus
Gargantext.API.Routes.Named.Corpus
Gargantext.API.Routes.Named.Count
Gargantext.API.Routes.Named.Document
Gargantext.API.Routes.Named.Document
Gargantext.API.Routes.Named.EKG
Gargantext.API.Routes.Named.EKG
Gargantext.API.Routes.Named.File
Gargantext.API.Routes.Named.File
...
@@ -335,7 +333,6 @@ library
...
@@ -335,7 +333,6 @@ library
Gargantext.API.Admin.Auth
Gargantext.API.Admin.Auth
Gargantext.API.Admin.FrontEnd
Gargantext.API.Admin.FrontEnd
Gargantext.API.Context
Gargantext.API.Context
Gargantext.API.Count
Gargantext.API.EKG
Gargantext.API.EKG
Gargantext.API.GraphQL
Gargantext.API.GraphQL
Gargantext.API.GraphQL.Annuaire
Gargantext.API.GraphQL.Annuaire
...
...
src/Gargantext/API/Count.hs
deleted
100644 → 0
View file @
7971d93c
{-|
Module : Gargantext.API.Count
Description : Server API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Count API part of Gargantext.
-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveAnyClass #-}
module
Gargantext.API.Count
(
countAPI
)
where
import
Gargantext.API.Count.Types
import
Gargantext.API.Routes.Named.Count
qualified
as
Named
import
Gargantext.Prelude
import
Servant.Server.Generic
(
AsServerT
)
-----------------------------------------------------------------------
-- TODO-ACCESS: CanCount
-- TODO-EVENTS: No events as this is a read only query.
-----------------------------------------------------------------------
countAPI
::
Query
->
Named
.
CountAPI
(
AsServerT
m
)
countAPI
_
=
Named
.
CountAPI
undefined
src/Gargantext/API/Count/Types.hs
deleted
100644 → 0
View file @
7971d93c
{-|
Module : Gargantext.API.Count.Types
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Count.Types
(
Scraper
(
..
)
,
QueryBool
(
..
)
,
Query
(
..
)
,
Message
(
..
)
,
Code
,
Error
,
Errors
,
Counts
(
..
)
,
Count
(
..
)
-- * functions
,
scrapers
)
where
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Data.Text
(
pack
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Prelude
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
(
..
))
-----------------------------------------------------------------------
data
Scraper
=
Pubmed
|
Hal
|
IsTex
|
Isidore
deriving
(
Eq
,
Show
,
Generic
,
Enum
,
Bounded
)
scrapers
::
[
Scraper
]
scrapers
=
[
minBound
..
maxBound
]
instance
FromJSON
Scraper
instance
ToJSON
Scraper
instance
Arbitrary
Scraper
where
arbitrary
=
elements
scrapers
instance
ToSchema
Scraper
-----------------------------------------------------------------------
data
QueryBool
=
QueryBool
Text
deriving
(
Eq
,
Show
,
Generic
)
queries
::
[
QueryBool
]
queries
=
[
QueryBool
(
pack
"(X OR X') AND (Y OR Y') NOT (Z OR Z')"
)]
--queries = [QueryBool (pack "(X + X') * (Y + Y') - (Z + Z')")]
instance
Arbitrary
QueryBool
where
arbitrary
=
elements
queries
instance
FromJSON
QueryBool
instance
ToJSON
QueryBool
instance
ToSchema
QueryBool
-----------------------------------------------------------------------
data
Query
=
Query
{
query_query
::
QueryBool
,
query_name
::
Maybe
[
Scraper
]
}
deriving
(
Eq
,
Show
,
Generic
)
instance
FromJSON
Query
instance
ToJSON
Query
instance
Arbitrary
Query
where
arbitrary
=
elements
[
Query
q
(
Just
n
)
|
q
<-
queries
,
n
<-
take
10
$
permutations
scrapers
]
instance
ToSchema
Query
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"query_"
)
-----------------------------------------------------------------------
type
Code
=
Integer
type
Error
=
Text
type
Errors
=
[
Error
]
-----------------------------------------------------------------------
data
Message
=
Message
Code
Errors
deriving
(
Eq
,
Show
,
Generic
)
toMessage
::
[(
Code
,
Errors
)]
->
[
Message
]
toMessage
=
map
(
\
(
c
,
err
)
->
Message
c
err
)
messages
::
[
Message
]
messages
=
toMessage
$
[
(
400
,
[
"Ill formed query "
])
,
(
300
,
[
"API connexion error "
])
,
(
300
,
[
"Internal Gargantext Error "
])
]
<>
take
10
(
repeat
(
200
,
[
""
]))
instance
Arbitrary
Message
where
arbitrary
=
elements
messages
instance
ToSchema
Message
-----------------------------------------------------------------------
data
Counts
=
Counts
{
results
::
[
Either
Message
Count
]
}
deriving
(
Eq
,
Show
,
Generic
)
instance
Arbitrary
Counts
where
arbitrary
=
elements
[
Counts
[
Right
(
Count
Pubmed
(
Just
20
))
,
Right
(
Count
IsTex
(
Just
150
))
,
Right
(
Count
Hal
(
Just
150
))
]
]
instance
ToSchema
Counts
-----------------------------------------------------------------------
data
Count
=
Count
{
count_name
::
Scraper
,
count_count
::
Maybe
Int
}
deriving
(
Eq
,
Show
,
Generic
)
instance
ToSchema
Count
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"count_"
)
--instance Arbitrary Count where
-- arbitrary = Count <$> arbitrary <*> arbitrary <*> arbitrary
--
-- JSON instances
--
instance
FromJSON
Message
instance
ToJSON
Message
$
(
deriveJSON
(
unPrefix
"count_"
)
''
C
ount
)
instance
FromJSON
Counts
instance
ToJSON
Counts
src/Gargantext/API/GraphQL.hs
View file @
b388c75e
...
@@ -15,7 +15,6 @@ Portability : POSIX
...
@@ -15,7 +15,6 @@ Portability : POSIX
{-# LANGUAGE KindSignatures #-}
-- for use of Endpoint (name :: Symbol)
{-# LANGUAGE KindSignatures #-}
-- for use of Endpoint (name :: Symbol)
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PartialTypeSignatures #-}
-- to automatically use suggested type hole signatures during compilation
{-# LANGUAGE PartialTypeSignatures #-}
-- to automatically use suggested type hole signatures during compilation
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.GraphQL
where
module
Gargantext.API.GraphQL
where
...
...
src/Gargantext/API/GraphQL/Context.hs
View file @
b388c75e
...
@@ -22,8 +22,7 @@ import Data.Morpheus.Types
...
@@ -22,8 +22,7 @@ import Data.Morpheus.Types
,
ResolverM
,
ResolverM
,
QUERY
,
QUERY
)
)
import
Data.Text
(
pack
,
unpack
)
import
Data.Text
(
pack
)
import
Data.Text
qualified
as
Text
import
Data.Time.Format.ISO8601
(
iso8601Show
)
import
Data.Time.Format.ISO8601
(
iso8601Show
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeWriteChecks
,
AccessPolicyManager
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeWriteChecks
,
AccessPolicyManager
)
...
@@ -97,7 +96,7 @@ data ContextsForNgramsArgs
...
@@ -97,7 +96,7 @@ data ContextsForNgramsArgs
=
ContextsForNgramsArgs
=
ContextsForNgramsArgs
{
corpus_id
::
Int
{
corpus_id
::
Int
,
ngrams_terms
::
[
Text
]
,
ngrams_terms
::
[
Text
]
,
and_logic
::
Text
,
and_logic
::
Bool
}
deriving
(
Generic
,
GQLType
)
}
deriving
(
Generic
,
GQLType
)
data
NodeContextCategoryMArgs
=
NodeContextCategoryMArgs
data
NodeContextCategoryMArgs
=
NodeContextCategoryMArgs
...
@@ -153,9 +152,10 @@ dbNodeContext context_id node_id = do
...
@@ -153,9 +152,10 @@ dbNodeContext context_id node_id = do
-- | Returns list of `ContextGQL` for given ngrams in given corpus id.
-- | Returns list of `ContextGQL` for given ngrams in given corpus id.
dbContextForNgrams
dbContextForNgrams
::
(
IsDBEnvExtra
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
[
Text
]
->
Text
->
GqlM
e
env
[
ContextGQL
]
=>
Int
->
[
Text
]
->
Bool
->
GqlM
e
env
[
ContextGQL
]
dbContextForNgrams
node_id
ngrams_terms
and_logic
=
do
dbContextForNgrams
node_id
ngrams_terms
and_logic
=
do
contextsForNgramsTerms
<-
lift
$
runDBQuery
$
getContextsForNgramsTerms
(
UnsafeMkNodeId
node_id
)
ngrams_terms
(
readMaybe
$
unpack
$
Text
.
toTitle
and_logic
)
contextsForNgramsTerms
<-
lift
$
runDBQuery
$
getContextsForNgramsTerms
(
UnsafeMkNodeId
node_id
)
ngrams_terms
and_logic
--lift $ printDebug "[dbContextForNgrams] contextsForNgramsTerms" contextsForNgramsTerms
--lift $ printDebug "[dbContextForNgrams] contextsForNgramsTerms" contextsForNgramsTerms
pure
$
toContextGQL
<$>
contextsForNgramsTerms
pure
$
toContextGQL
<$>
contextsForNgramsTerms
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
b388c75e
...
@@ -61,10 +61,13 @@ import Servant.Server.Generic (AsServerT)
...
@@ -61,10 +61,13 @@ import Servant.Server.Generic (AsServerT)
getAPI
::
Named
.
GETAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
getAPI
::
Named
.
GETAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
getAPI
=
Named
.
GETAPI
$
\
listId
->
Named
.
ListEndpoints
getAPI
=
Named
.
GETAPI
{
listJSONEp
=
getJson
listId
{
,
listJSONZipEp
=
getJsonZip
listId
getListEp
=
\
listId
->
Named
.
ListEndpoints
,
listTSVEp
=
getTsv
listId
{
listJSONEp
=
getJson
listId
,
listJSONZipEp
=
getJsonZip
listId
,
listTSVEp
=
getTsv
listId
}
}
}
--
--
...
...
src/Gargantext/API/Node.hs
View file @
b388c75e
...
@@ -32,7 +32,7 @@ import Gargantext.API.Admin.Auth.Types (PathId(..), AuthenticatedUser (..), auth
...
@@ -32,7 +32,7 @@ import Gargantext.API.Admin.Auth.Types (PathId(..), AuthenticatedUser (..), auth
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeReadChecks
,
nodeWriteChecks
,
moveChecks
,
AccessPolicyManager
,
publishChecks
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeReadChecks
,
nodeWriteChecks
,
moveChecks
,
AccessPolicyManager
,
publishChecks
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Metrics
import
Gargantext.API.Metrics
(
chartApi
,
pieApi
,
scatterApi
,
treeApi
,
updateChart
)
import
Gargantext.API.Ngrams.Types
(
TabType
(
..
))
import
Gargantext.API.Ngrams.Types
(
TabType
(
..
))
import
Gargantext.API.Node.DocumentUpload
qualified
as
DocumentUpload
import
Gargantext.API.Node.DocumentUpload
qualified
as
DocumentUpload
import
Gargantext.API.Node.DocumentsFromWriteNodes
qualified
as
DFWN
import
Gargantext.API.Node.DocumentsFromWriteNodes
qualified
as
DFWN
...
@@ -40,7 +40,7 @@ import Gargantext.API.Node.File ( fileApi, fileAsyncApi )
...
@@ -40,7 +40,7 @@ import Gargantext.API.Node.File ( fileApi, fileAsyncApi )
import
Gargantext.API.Node.FrameCalcUpload
qualified
as
FrameCalcUpload
import
Gargantext.API.Node.FrameCalcUpload
qualified
as
FrameCalcUpload
import
Gargantext.API.Node.New
(
postNode
,
postNodeAsyncAPI
)
import
Gargantext.API.Node.New
(
postNode
,
postNodeAsyncAPI
)
import
Gargantext.API.Node.Share
qualified
as
Share
import
Gargantext.API.Node.Share
qualified
as
Share
import
Gargantext.API.Node.Types
import
Gargantext.API.Node.Types
(
NodesToCategory
(
..
),
NodesToScore
(
..
),
RenameNode
(
..
))
import
Gargantext.API.Node.Update
qualified
as
Update
import
Gargantext.API.Node.Update
qualified
as
Update
import
Gargantext.API.Prelude
(
GargM
,
GargServer
,
IsGargServer
)
import
Gargantext.API.Prelude
(
GargM
,
GargServer
,
IsGargServer
)
import
Gargantext.API.Routes.Named.File
qualified
as
Named
import
Gargantext.API.Routes.Named.File
qualified
as
Named
...
@@ -61,14 +61,14 @@ import Gargantext.Database.Action.Delete qualified as Action (deleteNode)
...
@@ -61,14 +61,14 @@ import Gargantext.Database.Action.Delete qualified as Action (deleteNode)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataAny
,
HyperdataCorpus
,
HyperdataAnnuaire
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataAny
,
HyperdataCorpus
,
HyperdataAnnuaire
)
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
(
HyperdataC
)
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
(
HyperdataC
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
NodeId
,
ParentId
,
RootId
,
UserId
)
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
(
DBCmdExtra
,
JSONB
,
runDBTx
,
runDBQuery
)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node
(
defaultList
,
deleteNodes
,
getNodeWith
,
getNodesWithParentId
)
import
Gargantext.Database.Query.Table.Node.Children
(
getChildren
)
import
Gargantext.Database.Query.Table.Node.Children
(
getChildren
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Update
(
Update
(
..
),
update
)
import
Gargantext.Database.Query.Table.Node.Update
qualified
as
U
(
update
,
Update
(
..
),
publish
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.Node.Update
qualified
as
U
(
update
,
Update
(
..
),
publish
)
import
Gargantext.Database.Query.Table.Node.Update
(
Update
(
..
),
update
)
import
Gargantext.Database.Query.Table.NodeContext
(
nodeContextsCategory
,
nodeContextsScore
)
import
Gargantext.Database.Query.Table.NodeContext
(
nodeContextsCategory
,
nodeContextsScore
)
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Tree
(
tree
,
tree_flat
,
TreeMode
(
..
))
import
Gargantext.Database.Query.Tree
(
tree
,
tree_flat
,
TreeMode
(
..
))
...
@@ -249,11 +249,11 @@ genericNodeAPI' :: forall a proxy. ( HyperdataC a )
...
@@ -249,11 +249,11 @@ genericNodeAPI' :: forall a proxy. ( HyperdataC a )
->
Named
.
NodeAPI
a
(
AsServerT
(
GargM
Env
BackendInternalError
))
->
Named
.
NodeAPI
a
(
AsServerT
(
GargM
Env
BackendInternalError
))
genericNodeAPI'
_
authenticatedUser
targetNode
=
Named
.
NodeAPI
genericNodeAPI'
_
authenticatedUser
targetNode
=
Named
.
NodeAPI
{
nodeNodeAPI
=
withNamedPolicyT
authenticatedUser
(
nodeReadChecks
targetNode
)
$
{
nodeNodeAPI
=
withNamedPolicyT
authenticatedUser
(
nodeReadChecks
targetNode
)
$
Named
.
NodeNodeAPI
$
runDBQuery
(
getNodeWith
targetNode
(
Proxy
::
Proxy
a
))
Named
.
NodeNodeAPI
{
getNodeEp
=
runDBQuery
$
getNodeWith
targetNode
(
Proxy
::
Proxy
a
)
}
,
renameAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
,
renameAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
Named
.
RenameAPI
$
rename
loggedInUserId
targetNode
Named
.
RenameAPI
{
renameEp
=
rename
loggedInUserId
targetNode
}
,
postNodeAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
,
postNodeAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
Named
.
PostNodeAPI
$
postNode
authenticatedUser
targetNode
Named
.
PostNodeAPI
{
postWithParentEp
=
postNode
authenticatedUser
targetNode
}
,
postNodeAsyncAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
,
postNodeAsyncAPI
=
withNamedPolicyT
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
postNodeAsyncAPI
authenticatedUser
targetNode
postNodeAsyncAPI
authenticatedUser
targetNode
,
frameCalcUploadAPI
=
FrameCalcUpload
.
api
authenticatedUser
targetNode
,
frameCalcUploadAPI
=
FrameCalcUpload
.
api
authenticatedUser
targetNode
...
@@ -262,30 +262,29 @@ genericNodeAPI' _ authenticatedUser targetNode = Named.NodeAPI
...
@@ -262,30 +262,29 @@ genericNodeAPI' _ authenticatedUser targetNode = Named.NodeAPI
Update
.
api
targetNode
Update
.
api
targetNode
,
deleteEp
=
withPolicy
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
,
deleteEp
=
withPolicy
authenticatedUser
(
nodeWriteChecks
targetNode
)
$
Action
.
deleteNode
userRootId
targetNode
Action
.
deleteNode
userRootId
targetNode
,
childrenAPI
=
Named
.
ChildrenAPI
$
\
mb_nty
mb_off
mb_lim
->
,
childrenAPI
=
Named
.
ChildrenAPI
{
summaryChildrenEp
=
\
nt
o
l
->
runDBQuery
$
getChildren
targetNode
(
Proxy
::
Proxy
a
)
nt
o
l
}
runDBQuery
$
getChildren
targetNode
(
Proxy
::
Proxy
a
)
mb_nty
mb_off
mb_lim
,
tableAPI
=
tableApi
targetNode
,
tableAPI
=
tableApi
targetNode
,
tableNgramsAPI
=
apiNgramsTableCorpus
targetNode
,
tableNgramsAPI
=
apiNgramsTableCorpus
targetNode
,
catAPI
=
Named
.
CatAPI
$
catApi
targetNode
,
catAPI
=
Named
.
CatAPI
{
categoriseEp
=
catApi
targetNode
}
,
scoreAPI
=
Named
.
ScoreAPI
$
scoreApi
targetNode
,
scoreAPI
=
Named
.
ScoreAPI
{
scoreNodesEp
=
scoreApi
targetNode
}
,
searchAPI
=
Search
.
api
targetNode
,
searchAPI
=
Search
.
api
targetNode
,
shareAPI
=
Named
.
ShareNode
$
Share
.
api
userRootId
targetNode
,
shareAPI
=
Named
.
ShareNode
{
shareNodeEp
=
Share
.
api
userRootId
targetNode
}
,
unshareEp
=
Share
.
unShare
targetNode
,
unshareEp
=
Share
.
unShare
targetNode
,
publishAPI
=
withNamedPolicyT
authenticatedUser
(
publishChecks
targetNode
)
$
,
publishAPI
=
withNamedPolicyT
authenticatedUser
(
publishChecks
targetNode
)
$
Named
.
PublishAPI
$
\
Named
.
PublishRequest
{
pubrq_policy
}
->
runDBTx
$
U
.
publish
loggedInUserId
targetNode
pubrq_policy
Named
.
PublishAPI
{
publishEp
=
\
Named
.
PublishRequest
{
pubrq_policy
}
->
runDBTx
$
U
.
publish
loggedInUserId
targetNode
pubrq_policy
}
---- Pairing utilities
---- Pairing utilities
,
pairWithEp
=
pairWith
targetNode
,
pairWithEp
=
pairWith
targetNode
,
pairsEp
=
pairs
targetNode
,
pairsEp
=
pairs
targetNode
,
pairingEp
=
Named
.
PairingAPI
$
getPair
targetNode
,
pairingEp
=
Named
.
PairingAPI
{
getPairingEp
=
getPair
targetNode
}
---- VIZ
---- VIZ
,
scatterAPI
=
scatterApi
targetNode
,
scatterAPI
=
scatterApi
targetNode
,
chartAPI
=
chartApi
targetNode
,
chartAPI
=
chartApi
targetNode
,
pieAPI
=
pieApi
targetNode
,
pieAPI
=
pieApi
targetNode
,
treeAPI
=
treeApi
targetNode
,
treeAPI
=
treeApi
targetNode
,
phyloAPI
=
phyloAPI
targetNode
,
phyloAPI
=
phyloAPI
targetNode
,
moveAPI
=
Named
.
MoveAPI
$
\
parentId
->
,
moveAPI
=
Named
.
MoveAPI
{
moveNodeEp
=
\
parentId
->
withPolicy
authenticatedUser
(
moveChecks
(
SourceId
targetNode
)
(
TargetId
parentId
))
$
withPolicy
authenticatedUser
(
moveChecks
(
SourceId
targetNode
)
(
TargetId
parentId
))
$
moveNode
loggedInUserId
targetNode
parentId
moveNode
loggedInUserId
targetNode
parentId
}
,
fileAPI
=
Named
.
FileAPI
{
fileDownloadEp
=
fileApi
targetNode
}
,
fileAPI
=
Named
.
FileAPI
{
fileDownloadEp
=
fileApi
targetNode
}
,
fileAsyncAPI
=
fileAsyncApi
authenticatedUser
targetNode
,
fileAsyncAPI
=
fileAsyncApi
authenticatedUser
targetNode
,
dfwnAPI
=
DFWN
.
api
authenticatedUser
targetNode
,
dfwnAPI
=
DFWN
.
api
authenticatedUser
targetNode
...
...
src/Gargantext/API/Routes/Named/Corpus.hs
View file @
b388c75e
...
@@ -24,7 +24,7 @@ module Gargantext.API.Routes.Named.Corpus (
...
@@ -24,7 +24,7 @@ module Gargantext.API.Routes.Named.Corpus (
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
GHC.Generics
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Node.Corpus.Export.Types
(
Corpus
,
CorpusSQLite
)
import
Gargantext.API.Node.Corpus.Export.Types
(
Corpus
,
CorpusSQLite
)
import
Gargantext.API.Node.Types
(
NewWithForm
,
WithQuery
)
import
Gargantext.API.Node.Types
(
NewWithForm
,
WithQuery
)
import
Gargantext.API.Worker
(
WorkerAPI
)
import
Gargantext.API.Worker
(
WorkerAPI
)
...
...
src/Gargantext/API/Routes/Named/Count.hs
deleted
100644 → 0
View file @
7971d93c
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.Routes.Named.Count
(
-- * Routes types
CountAPI
(
..
)
-- * Re-exports
,
module
X
)
where
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Count.Types
as
X
import
Servant
newtype
CountAPI
mode
=
CountAPI
{
postCountsEp
::
mode
:-
Post
'[
J
SON
]
X
.
Counts
}
deriving
Generic
src/Gargantext/API/Routes/Named/Private.hs
View file @
b388c75e
...
@@ -30,19 +30,18 @@ import Gargantext.API.Auth.PolicyCheck (PolicyChecked)
...
@@ -30,19 +30,18 @@ import Gargantext.API.Auth.PolicyCheck (PolicyChecked)
import
Gargantext.API.Routes.Named.Contact
(
ContactAPI
)
import
Gargantext.API.Routes.Named.Contact
(
ContactAPI
)
import
Gargantext.API.Routes.Named.Context
(
ContextAPI
)
import
Gargantext.API.Routes.Named.Context
(
ContextAPI
)
import
Gargantext.API.Routes.Named.Corpus
(
AddWithTempFile
,
AddWithQuery
,
CorpusExportAPI
,
MakeSubcorpusAPI
)
import
Gargantext.API.Routes.Named.Corpus
(
AddWithTempFile
,
AddWithQuery
,
CorpusExportAPI
,
MakeSubcorpusAPI
)
import
Gargantext.API.Routes.Named.Count
(
CountAPI
,
Query
)
import
Gargantext.API.Routes.Named.Document
(
DocumentExportAPI
)
import
Gargantext.API.Routes.Named.Document
(
DocumentExportAPI
)
import
Gargantext.API.Routes.Named.List
(
GETAPI
,
JSONAPI
,
TSVAPI
)
import
Gargantext.API.Routes.Named.List
(
GETAPI
,
JSONAPI
,
TSVAPI
)
import
Gargantext.API.Routes.Named.Node
import
Gargantext.API.Routes.Named.Node
(
NodeAPI
,
NodesAPI
,
NodeNodeAPI
,
Roots
)
import
Gargantext.API.Routes.Named.Remote
import
Gargantext.API.Routes.Named.Remote
(
RemoteImportAPI
)
import
Gargantext.API.Routes.Named.Share
import
Gargantext.API.Routes.Named.Share
(
ShareURL
)
import
Gargantext.API.Routes.Named.Table
import
Gargantext.API.Routes.Named.Table
(
TableNgramsAPI
)
import
Gargantext.API.Routes.Named.Tree
import
Gargantext.API.Routes.Named.Tree
(
NodeTreeAPI
,
TreeFlatAPI
)
import
Gargantext.API.Routes.Named.Viz
import
Gargantext.API.Routes.Named.Viz
(
GraphAPI
,
PhyloExportAPI
)
import
Gargantext.Database.Admin.Types.Hyperdata.Any
import
Gargantext.Database.Admin.Types.Hyperdata.Any
(
HyperdataAny
)
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
(
HyperdataAnnuaire
,
HyperdataCorpus
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
(
ContextId
,
CorpusId
,
DocId
,
NodeId
)
import
GHC.Generics
import
GHC.Generics
(
Generic
)
import
Servant.API
import
Servant.API
import
Servant.Auth
qualified
as
SA
import
Servant.Auth
qualified
as
SA
...
@@ -81,9 +80,6 @@ data GargPrivateAPI' mode = GargPrivateAPI'
...
@@ -81,9 +80,6 @@ data GargPrivateAPI' mode = GargPrivateAPI'
:>
NamedRoutes
DocumentExportAPI
:>
NamedRoutes
DocumentExportAPI
,
phyloExportAPI
::
mode
:-
"phylo"
:>
Capture
"node_id"
DocId
,
phyloExportAPI
::
mode
:-
"phylo"
:>
Capture
"node_id"
DocId
:>
NamedRoutes
PhyloExportAPI
:>
NamedRoutes
PhyloExportAPI
,
countAPI
::
mode
:-
"count"
:>
Summary
"Count endpoint"
:>
ReqBody
'[
J
SON
]
Query
:>
NamedRoutes
CountAPI
,
graphAPI
::
mode
:-
"graph"
:>
Summary
"Graph endpoint"
,
graphAPI
::
mode
:-
"graph"
:>
Summary
"Graph endpoint"
:>
Capture
"graph_id"
NodeId
:>
Capture
"graph_id"
NodeId
:>
NamedRoutes
GraphAPI
:>
NamedRoutes
GraphAPI
...
...
src/Gargantext/API/Routes/Named/Remote.hs
View file @
b388c75e
{-|
Module : Gargantext.API.Routes.Named.Remote
Description : Server API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.Routes.Named.Remote
(
module
Gargantext.API.Routes.Named.Remote
(
-- * Routes types
-- * Routes types
RemoteExportAPI
(
..
)
RemoteExportAPI
(
..
)
...
@@ -13,16 +25,15 @@ import Conduit qualified as C
...
@@ -13,16 +25,15 @@ import Conduit qualified as C
import
Data.Aeson
as
JSON
import
Data.Aeson
as
JSON
import
Data.ByteString.Lazy
qualified
as
BL
import
Data.ByteString.Lazy
qualified
as
BL
import
Data.ByteString
qualified
as
BS
import
Data.ByteString
qualified
as
BS
import
Data.Proxy
import
Data.Proxy
(
Proxy
(
Proxy
))
import
Data.Swagger
hiding
(
Http
)
import
Data.Swagger
(
NamedSchema
(
..
),
ToSchema
,
declareNamedSchema
,
binarySchema
,
sketchStrictSchema
)
import
Gargantext.API.Admin.Auth.Types
(
Token
)
import
Gargantext.API.Admin.Auth.Types
(
Token
)
import
Gargantext.API.Auth.PolicyCheck
(
PolicyChecked
)
import
Gargantext.API.Auth.PolicyCheck
(
PolicyChecked
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
)
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
)
)
import
GHC.Generics
import
GHC.Generics
(
Generic
)
import
Prelude
import
Prelude
import
Servant.API
import
Servant.API
import
Servant.Client.Core.BaseUrl
import
Servant.Client.Core.BaseUrl
(
BaseUrl
(
..
),
parseBaseUrl
,
Scheme
(
Http
))
import
Test.QuickCheck
data
RemoteExportAPI
mode
=
RemoteExportAPI
data
RemoteExportAPI
mode
=
RemoteExportAPI
...
@@ -42,9 +53,6 @@ data RemoteExportRequest =
...
@@ -42,9 +53,6 @@ data RemoteExportRequest =
,
_rer_instance_auth
::
Token
,
_rer_instance_auth
::
Token
}
deriving
(
Show
,
Eq
,
Generic
)
}
deriving
(
Show
,
Eq
,
Generic
)
instance
Arbitrary
RemoteExportRequest
where
arbitrary
=
RemoteExportRequest
<$>
(
pure
(
BaseUrl
Http
"dev.sub.gargantext.org"
8008
""
))
<*>
arbitrary
instance
ToJSON
RemoteExportRequest
where
instance
ToJSON
RemoteExportRequest
where
toJSON
RemoteExportRequest
{
..
}
toJSON
RemoteExportRequest
{
..
}
=
JSON
.
object
[
"instance_url"
.=
toJSON
_rer_instance_url
=
JSON
.
object
[
"instance_url"
.=
toJSON
_rer_instance_url
...
...
src/Gargantext/API/Routes/Named/Share.hs
View file @
b388c75e
...
@@ -17,7 +17,7 @@ import Data.Aeson (withText)
...
@@ -17,7 +17,7 @@ import Data.Aeson (withText)
import
Data.Swagger
(
ToSchema
,
declareNamedSchema
)
import
Data.Swagger
(
ToSchema
,
declareNamedSchema
)
import
Data.Text
qualified
as
T
import
Data.Text
qualified
as
T
import
Gargantext.API.Node.Share.Types
(
ShareNodeParams
(
..
)
)
import
Gargantext.API.Node.Share.Types
(
ShareNodeParams
(
..
)
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Network.URI
(
parseURI
)
import
Network.URI
(
parseURI
)
import
Prelude
(
fail
)
import
Prelude
(
fail
)
...
...
src/Gargantext/API/Search.hs
View file @
b388c75e
{-|
{-|
Module : Gargantext.API.
Count
Module : Gargantext.API.
Search
Description : Server API
Description : Server API
Copyright : (c) CNRS, 2017-Present
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
License : AGPL + CECILL v3
...
...
src/Gargantext/API/Server/Named/Private.hs
View file @
b388c75e
...
@@ -5,7 +5,6 @@ module Gargantext.API.Server.Named.Private where
...
@@ -5,7 +5,6 @@ module Gargantext.API.Server.Named.Private where
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
(
..
))
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Context
(
contextAPI
)
import
Gargantext.API.Context
(
contextAPI
)
import
Gargantext.API.Count
qualified
as
Count
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Members
(
members
)
import
Gargantext.API.Members
(
members
)
import
Gargantext.API.Ngrams.List
qualified
as
List
import
Gargantext.API.Ngrams.List
qualified
as
List
...
@@ -54,7 +53,6 @@ serverPrivateGargAPI' authenticatedUser@(AuthenticatedUser userNodeId userId)
...
@@ -54,7 +53,6 @@ serverPrivateGargAPI' authenticatedUser@(AuthenticatedUser userNodeId userId)
,
tableNgramsAPI
=
apiNgramsTableDoc
authenticatedUser
,
tableNgramsAPI
=
apiNgramsTableDoc
authenticatedUser
,
phyloExportAPI
=
PhyloExport
.
api
userNodeId
,
phyloExportAPI
=
PhyloExport
.
api
userNodeId
,
documentExportAPI
=
documentExportAPI
userNodeId
,
documentExportAPI
=
documentExportAPI
userNodeId
,
countAPI
=
Count
.
countAPI
,
graphAPI
=
Viz
.
graphAPI
authenticatedUser
userId
,
graphAPI
=
Viz
.
graphAPI
authenticatedUser
userId
,
treeAPI
=
Tree
.
treeAPI
authenticatedUser
,
treeAPI
=
Tree
.
treeAPI
authenticatedUser
,
treeFlatAPI
=
Tree
.
treeFlatAPI
authenticatedUser
,
treeFlatAPI
=
Tree
.
treeFlatAPI
authenticatedUser
...
...
src/Gargantext/Core/Text/Terms.hs
View file @
b388c75e
...
@@ -116,11 +116,11 @@ data ExtractedNgrams = SimpleNgrams { unSimpleNgrams :: Ngrams }
...
@@ -116,11 +116,11 @@ data ExtractedNgrams = SimpleNgrams { unSimpleNgrams :: Ngrams }
instance
Hashable
ExtractedNgrams
instance
Hashable
ExtractedNgrams
-- | A typeclass that represents extracting ngrams from an entity.
-- | A typeclass that represents extracting ngrams from an entity.
class
ExtractNgrams
h
where
class
Monad
m
=>
ExtractNgrams
m
h
where
extractNgrams
::
NLPServerConfig
extractNgrams
::
NLPServerConfig
->
TermType
Lang
->
TermType
Lang
->
h
->
h
->
DBCmd
err
(
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
->
m
(
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
------------------------------------------------------------------------
------------------------------------------------------------------------
enrichedTerms
::
Lang
->
PosTagAlgo
->
POS
->
Terms
->
NgramsPostag
enrichedTerms
::
Lang
->
PosTagAlgo
->
POS
->
Terms
->
NgramsPostag
...
...
src/Gargantext/Core/Text/Terms/Multi.hs
View file @
b388c75e
...
@@ -11,9 +11,19 @@ Multi-terms are ngrams where n > 1.
...
@@ -11,9 +11,19 @@ Multi-terms are ngrams where n > 1.
-}
-}
module
Gargantext.Core.Text.Terms.Multi
(
multiterms
,
Terms
(
..
),
tokenTag2terms
,
multiterms_rake
,
tokenTagsWith
,
tokenTags
,
cleanTextForNLP
)
module
Gargantext.Core.Text.Terms.Multi
(
multiterms
,
Terms
(
..
)
,
MultitermsExtractionException
(
..
)
,
tokenTag2terms
,
multiterms_rake
,
tokenTagsWith
,
tokenTags
,
cleanTextForNLP
)
where
where
import
Control.Exception.Safe
qualified
as
Safe
import
Data.Attoparsec.Text
as
DAT
(
space
,
notChar
,
string
)
import
Data.Attoparsec.Text
as
DAT
(
space
,
notChar
,
string
)
import
Gargantext.Core
(
Lang
(
..
),
NLPServerConfig
(
..
),
PosTagAlgo
(
..
))
import
Gargantext.Core
(
Lang
(
..
),
NLPServerConfig
(
..
),
PosTagAlgo
(
..
))
import
Gargantext.Core.Text.Terms.Multi.Lang.En
qualified
as
En
import
Gargantext.Core.Text.Terms.Multi.Lang.En
qualified
as
En
...
@@ -25,14 +35,23 @@ import Gargantext.Core.Types ( POS(NP), Terms(Terms), TermsWithCount, TokenTag(T
...
@@ -25,14 +35,23 @@ import Gargantext.Core.Types ( POS(NP), Terms(Terms), TermsWithCount, TokenTag(T
import
Gargantext.Core.Utils
(
groupWithCounts
)
import
Gargantext.Core.Utils
(
groupWithCounts
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Utils.SpacyNLP
qualified
as
SpacyNLP
import
Gargantext.Utils.SpacyNLP
qualified
as
SpacyNLP
import
Network.HTTP.Client
import
Replace.Attoparsec.Text
as
RAT
(
streamEdit
)
import
Replace.Attoparsec.Text
as
RAT
(
streamEdit
)
-------------------------------------------------------------------
-------------------------------------------------------------------
type
NLP_API
=
Lang
->
Text
->
IO
PosSentences
type
NLP_API
=
Lang
->
Text
->
IO
PosSentences
data
MultitermsExtractionException
=
MEE_nlp_server_http_exception
!
NLPServerConfig
!
HttpException
deriving
Show
instance
Exception
MultitermsExtractionException
-------------------------------------------------------------------
-------------------------------------------------------------------
-- | Extracts the terms from the input 'txt'. Throws a
-- 'MultitermExtractionException' in case we fail.
multiterms
::
NLPServerConfig
->
Lang
->
Text
->
IO
[
TermsWithCount
]
multiterms
::
NLPServerConfig
->
Lang
->
Text
->
IO
[
TermsWithCount
]
multiterms
nsc
l
txt
=
do
multiterms
nsc
l
txt
=
handle
(
\
ex
->
Safe
.
throwIO
$
MEE_nlp_server_http_exception
nsc
ex
)
$
do
let
txt'
=
cleanTextForNLP
txt
let
txt'
=
cleanTextForNLP
txt
if
txt'
==
""
if
txt'
==
""
then
do
then
do
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
b388c75e
...
@@ -56,7 +56,7 @@ module Gargantext.Database.Action.Flow -- (flowDatabase, ngrams2list)
...
@@ -56,7 +56,7 @@ module Gargantext.Database.Action.Flow -- (flowDatabase, ngrams2list)
import
Conduit
import
Conduit
import
Control.Lens
(
to
,
view
)
import
Control.Lens
(
to
,
view
)
import
Control.
Monad.Catch
import
Control.
Exception.Safe
(
catch
,
MonadCatch
)
import
Data.Conduit
qualified
as
C
import
Data.Conduit
qualified
as
C
import
Data.Conduit.Internal
(
zipSources
)
import
Data.Conduit.Internal
(
zipSources
)
import
Data.Conduit.List
qualified
as
CL
import
Data.Conduit.List
qualified
as
CL
...
@@ -116,6 +116,7 @@ import Gargantext.Utils.Jobs.Monad ( JobHandle, MonadJobStatus(..) )
...
@@ -116,6 +116,7 @@ import Gargantext.Utils.Jobs.Monad ( JobHandle, MonadJobStatus(..) )
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Imports for upgrade function
-- Imports for upgrade function
import
Gargantext.Database.Query.Tree.Error
(
HasTreeError
)
import
Gargantext.Database.Query.Tree.Error
(
HasTreeError
)
import
Gargantext.Core.Text.Terms.Multi
(
MultitermsExtractionException
)
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -256,9 +257,11 @@ flowCorpus :: ( IsDBCmd env err m
...
@@ -256,9 +257,11 @@ flowCorpus :: ( IsDBCmd env err m
,
HasTreeError
err
,
HasTreeError
err
,
HasValidationError
err
,
HasValidationError
err
,
FlowCorpus
a
,
FlowCorpus
a
,
ExtractNgrams
m
a
,
MonadJobStatus
m
,
MonadJobStatus
m
,
MonadCatch
m
,
MonadCatch
m
,
HasCentralExchangeNotification
env
,
Show
a
)
,
HasCentralExchangeNotification
env
)
=>
MkCorpusUser
=>
MkCorpusUser
->
TermType
Lang
->
TermType
Lang
->
Maybe
FlowSocialListWith
->
Maybe
FlowSocialListWith
...
@@ -276,10 +279,11 @@ flow :: forall env err m a c.
...
@@ -276,10 +279,11 @@ flow :: forall env err m a c.
,
HasTreeError
err
,
HasTreeError
err
,
HasValidationError
err
,
HasValidationError
err
,
FlowCorpus
a
,
FlowCorpus
a
,
ExtractNgrams
m
a
,
MkCorpus
c
,
MkCorpus
c
,
MonadJobStatus
m
,
MonadJobStatus
m
,
HasCentralExchangeNotification
env
,
HasCentralExchangeNotification
env
,
MonadCatch
m
,
Show
a
,
MonadCatch
m
)
)
=>
Maybe
c
=>
Maybe
c
->
MkCorpusUser
->
MkCorpusUser
...
@@ -317,9 +321,10 @@ addDocumentsToHyperCorpus :: ( IsDBCmd env err m
...
@@ -317,9 +321,10 @@ addDocumentsToHyperCorpus :: ( IsDBCmd env err m
,
HasNodeError
err
,
HasNodeError
err
,
HasNLPServer
env
,
HasNLPServer
env
,
FlowCorpus
document
,
FlowCorpus
document
,
ExtractNgrams
m
document
,
MkCorpus
corpus
,
MkCorpus
corpus
,
MonadLogger
m
,
MonadLogger
m
,
MonadCatch
m
,
Show
document
,
MonadCatch
m
)
)
=>
Maybe
corpus
=>
Maybe
corpus
->
TermType
Lang
->
TermType
Lang
...
@@ -471,7 +476,7 @@ data InsertDocError
...
@@ -471,7 +476,7 @@ data InsertDocError
extractNgramsFromDocument
::
(
UniqParameters
doc
extractNgramsFromDocument
::
(
UniqParameters
doc
,
HasText
doc
,
HasText
doc
,
ExtractNgrams
doc
,
ExtractNgrams
m
doc
,
IsDBCmd
err
env
m
,
IsDBCmd
err
env
m
,
MonadLogger
m
,
MonadLogger
m
,
MonadCatch
m
,
MonadCatch
m
...
@@ -487,7 +492,7 @@ extractNgramsFromDocument nlpServer lang doc =
...
@@ -487,7 +492,7 @@ extractNgramsFromDocument nlpServer lang doc =
-- will still be added to the corpus and we can try to regen the ngrams at a later stage.
-- will still be added to the corpus and we can try to regen the ngrams at a later stage.
UncommittedNgrams
.
Map
.
singleton
docId
<$>
UncommittedNgrams
.
Map
.
singleton
docId
<$>
(
documentIdWithNgrams
(
extractNgrams
nlpServer
$
withLang
lang
[
doc
])
(
Indexed
docId
doc
)
(
documentIdWithNgrams
(
extractNgrams
nlpServer
$
withLang
lang
[
doc
])
(
Indexed
docId
doc
)
`
catch
`
\
(
e
::
Some
Exception
)
->
do
`
catch
`
\
(
e
::
MultitermsExtraction
Exception
)
->
do
$
(
logLocM
)
ERROR
$
T
.
pack
$
"Document with hash "
<>
show
docId
<>
" failed ngrams extraction due to an exception: "
<>
displayException
e
$
(
logLocM
)
ERROR
$
T
.
pack
$
"Document with hash "
<>
show
docId
<>
" failed ngrams extraction due to an exception: "
<>
displayException
e
pure
$
DocumentIdWithNgrams
(
Indexed
docId
doc
)
mempty
pure
$
DocumentIdWithNgrams
(
Indexed
docId
doc
)
mempty
)
)
...
@@ -517,7 +522,7 @@ commitNgramsForDocument (UncommittedNgrams ng) (Indexed oldIx node) = do
...
@@ -517,7 +522,7 @@ commitNgramsForDocument (UncommittedNgrams ng) (Indexed oldIx node) = do
extractNgramsFromDocuments
::
forall
doc
env
err
m
.
extractNgramsFromDocuments
::
forall
doc
env
err
m
.
(
HasText
doc
(
HasText
doc
,
UniqParameters
doc
,
UniqParameters
doc
,
ExtractNgrams
doc
,
ExtractNgrams
m
doc
,
IsDBCmd
env
err
m
,
IsDBCmd
env
err
m
,
MonadLogger
m
,
MonadLogger
m
,
MonadCatch
m
,
MonadCatch
m
...
@@ -545,7 +550,7 @@ commitNgramsForDocuments ng nodes =
...
@@ -545,7 +550,7 @@ commitNgramsForDocuments ng nodes =
insertMasterDocs
::
(
HasNodeError
err
insertMasterDocs
::
(
HasNodeError
err
,
UniqParameters
doc
,
UniqParameters
doc
,
FlowCorpus
doc
,
FlowCorpus
doc
,
MkCorpus
c
,
Show
do
c
,
MkCorpus
c
)
)
=>
GargConfig
=>
GargConfig
->
UncommittedNgrams
doc
->
UncommittedNgrams
doc
...
...
src/Gargantext/Database/Action/Flow/Extract.hs
View file @
b388c75e
...
@@ -13,6 +13,7 @@ Portability : POSIX
...
@@ -13,6 +13,7 @@ Portability : POSIX
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
module
Gargantext.Database.Action.Flow.Extract
module
Gargantext.Database.Action.Flow.Extract
...
@@ -30,7 +31,6 @@ import Gargantext.Core.Types (POS(NP), TermsCount, TermsWeight)
...
@@ -30,7 +31,6 @@ import Gargantext.Core.Types (POS(NP), TermsCount, TermsWeight)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
HyperdataContact
,
cw_lastName
,
hc_who
)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
HyperdataContact
,
cw_lastName
,
hc_who
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
,
hd_authors
,
hd_bdd
,
hd_institutes
,
hd_source
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
,
hd_authors
,
hd_bdd
,
hd_institutes
,
hd_source
)
import
Gargantext.Database.Admin.Types.Node
(
Node
)
import
Gargantext.Database.Admin.Types.Node
(
Node
)
import
Gargantext.Database.Prelude
(
DBCmd
)
import
Gargantext.Database.Query.Table.NgramsPostag
(
NgramsPostag
)
import
Gargantext.Database.Query.Table.NgramsPostag
(
NgramsPostag
)
import
Gargantext.Database.Schema.Ngrams
(
text2ngrams
)
import
Gargantext.Database.Schema.Ngrams
(
text2ngrams
)
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
))
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
))
...
@@ -39,7 +39,7 @@ import Gargantext.Prelude
...
@@ -39,7 +39,7 @@ import Gargantext.Prelude
------------------------------------------------------------------------
------------------------------------------------------------------------
instance
ExtractNgrams
HyperdataContact
where
instance
Monad
m
=>
ExtractNgrams
m
HyperdataContact
where
extractNgrams
_ncs
_l
=
pure
.
HashMap
.
mapKeys
(
cleanExtractedNgrams
255
)
.
extract
extractNgrams
_ncs
_l
=
pure
.
HashMap
.
mapKeys
(
cleanExtractedNgrams
255
)
.
extract
where
where
extract
::
HyperdataContact
extract
::
HyperdataContact
...
@@ -55,15 +55,15 @@ instance ExtractNgrams HyperdataContact where
...
@@ -55,15 +55,15 @@ instance ExtractNgrams HyperdataContact where
-- | Main ngrams extraction functionality.
-- | Main ngrams extraction functionality.
-- For NgramsTerms, this calls NLP server under the hood.
-- For NgramsTerms, this calls NLP server under the hood.
-- For Sources, Institutes, Authors, this uses simple split on " ".
-- For Sources, Institutes, Authors, this uses simple split on " ".
instance
ExtractNgrams
HyperdataDocument
where
instance
(
Monad
m
,
MonadBase
IO
m
)
=>
ExtractNgrams
m
HyperdataDocument
where
extractNgrams
::
NLPServerConfig
extractNgrams
::
NLPServerConfig
->
TermType
Lang
->
TermType
Lang
->
HyperdataDocument
->
HyperdataDocument
->
DBCmd
err
(
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
->
m
(
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
extractNgrams
ncs
lang
hd
=
HashMap
.
mapKeys
(
cleanExtractedNgrams
255
)
<$>
extractNgramsT'
hd
extractNgrams
ncs
lang
hd
=
HashMap
.
mapKeys
(
cleanExtractedNgrams
255
)
<$>
extractNgramsT'
hd
where
where
extractNgramsT'
::
HyperdataDocument
extractNgramsT'
::
HyperdataDocument
->
DBCmd
err
(
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
->
m
(
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
TermsWeight
,
TermsCount
))
extractNgramsT'
doc
=
do
extractNgramsT'
doc
=
do
let
source
=
text2ngrams
let
source
=
text2ngrams
$
maybe
"Nothing"
identity
$
maybe
"Nothing"
identity
...
@@ -87,7 +87,7 @@ instance ExtractNgrams HyperdataDocument where
...
@@ -87,7 +87,7 @@ instance ExtractNgrams HyperdataDocument where
<>
[(
SimpleNgrams
a'
,
(
DM
.
singleton
Authors
1
,
1
))
|
a'
<-
authors
]
<>
[(
SimpleNgrams
a'
,
(
DM
.
singleton
Authors
1
,
1
))
|
a'
<-
authors
]
<>
[(
EnrichedNgrams
t'
,
(
DM
.
singleton
NgramsTerms
1
,
cnt'
))
|
(
t'
,
cnt'
)
<-
termsWithCounts'
]
<>
[(
EnrichedNgrams
t'
,
(
DM
.
singleton
NgramsTerms
1
,
cnt'
))
|
(
t'
,
cnt'
)
<-
termsWithCounts'
]
instance
(
ExtractNgrams
a
,
HasText
a
)
=>
ExtractNgrams
(
Node
a
)
instance
(
ExtractNgrams
m
a
,
HasText
a
)
=>
ExtractNgrams
m
(
Node
a
)
where
where
extractNgrams
ncs
l
(
Node
{
_node_hyperdata
=
h
})
=
extractNgrams
ncs
l
h
extractNgrams
ncs
l
(
Node
{
_node_hyperdata
=
h
})
=
extractNgrams
ncs
l
h
...
...
src/Gargantext/Database/Action/Flow/Types.hs
View file @
b388c75e
...
@@ -25,7 +25,6 @@ import Gargantext.Core.NodeStory.Types ( HasNodeStory )
...
@@ -25,7 +25,6 @@ import Gargantext.Core.NodeStory.Types ( HasNodeStory )
import
Gargantext.Core.Text
(
HasText
)
import
Gargantext.Core.Text
(
HasText
)
import
Gargantext.API.Admin.Orchestrator.Types
qualified
as
API
import
Gargantext.API.Admin.Orchestrator.Types
qualified
as
API
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Text.Terms
(
ExtractNgrams
)
import
Gargantext.Core.Types
(
HasValidationError
,
TermsCount
,
TermsWeight
)
import
Gargantext.Core.Types
(
HasValidationError
,
TermsCount
,
TermsWeight
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
)
...
@@ -51,11 +50,10 @@ type FlowCmdM env err m =
...
@@ -51,11 +50,10 @@ type FlowCmdM env err m =
)
)
type
FlowCorpus
a
=
(
UniqParameters
a
type
FlowCorpus
a
=
(
UniqParameters
a
,
InsertDb
a
,
InsertDb
a
,
ExtractNgrams
a
,
HasText
a
,
HasText
a
,
ToNode
a
,
ToNode
a
,
ToJSON
a
,
ToJSON
a
)
)
type
FlowInsertDB
a
=
(
AddUniqId
a
type
FlowInsertDB
a
=
(
AddUniqId
a
...
...
src/Gargantext/Database/Query/Table/NodeContext.hs
View file @
b388c75e
...
@@ -151,9 +151,9 @@ data ContextForNgramsTerms =
...
@@ -151,9 +151,9 @@ data ContextForNgramsTerms =
getContextsForNgramsTerms
::
HasNodeError
err
getContextsForNgramsTerms
::
HasNodeError
err
=>
NodeId
=>
NodeId
->
[
Text
]
->
[
Text
]
->
Maybe
Bool
->
Bool
->
DBQuery
err
x
[
ContextForNgramsTerms
]
->
DBQuery
err
x
[
ContextForNgramsTerms
]
getContextsForNgramsTerms
cId
ngramsTerms
(
Just
True
)
=
do
getContextsForNgramsTerms
cId
ngramsTerms
True
=
do
let
terms_length
=
length
ngramsTerms
let
terms_length
=
length
ngramsTerms
res
<-
mkPGQuery
query
(
cId
,
PGS
.
In
ngramsTerms
,
terms_length
)
res
<-
mkPGQuery
query
(
cId
,
PGS
.
In
ngramsTerms
,
terms_length
)
pure
$
(
\
(
_cfnt_nodeId
pure
$
(
\
(
_cfnt_nodeId
...
...
stack.yaml
View file @
b388c75e
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
git
:
"
https://github.com/delanoe/patches-map"
git
:
"
https://github.com/delanoe/patches-map"
subdirs
:
subdirs
:
-
.
-
.
-
commit
:
7694f62af6bc1596d754b42af16da131ac403b3a
-
commit
:
c3c558d9278ef239a474f1e1b69afc461be60d01
git
:
"
https://github.com/fpringle/servant-routes.git"
git
:
"
https://github.com/fpringle/servant-routes.git"
subdirs
:
subdirs
:
-
.
-
.
...
...
test/Test/Instances.hs
View file @
b388c75e
...
@@ -42,6 +42,7 @@ import Gargantext.API.Node.Update.Types qualified as NU
...
@@ -42,6 +42,7 @@ import Gargantext.API.Node.Update.Types qualified as NU
import
Gargantext.API.Node.Types
(
NewWithForm
,
NewWithTempFile
(
..
),
RenameNode
(
..
),
WithQuery
)
import
Gargantext.API.Node.Types
(
NewWithForm
,
NewWithTempFile
(
..
),
RenameNode
(
..
),
WithQuery
)
import
Gargantext.API.Public.Types
(
PublicData
(
..
))
import
Gargantext.API.Public.Types
(
PublicData
(
..
))
import
Gargantext.API.Routes.Named.Publish
(
PublishRequest
(
..
))
import
Gargantext.API.Routes.Named.Publish
(
PublishRequest
(
..
))
import
Gargantext.API.Routes.Named.Remote
(
RemoteExportRequest
(
..
))
import
Gargantext.API.Search.Types
(
SearchQuery
(
..
),
SearchResult
(
..
),
SearchResultTypes
(
..
),
SearchType
(
..
))
import
Gargantext.API.Search.Types
(
SearchQuery
(
..
),
SearchResult
(
..
),
SearchResultTypes
(
..
),
SearchType
(
..
))
import
Gargantext.API.Table.Types
(
TableQuery
(
..
))
import
Gargantext.API.Table.Types
(
TableQuery
(
..
))
import
Gargantext.API.Viz.Types
(
PhyloData
)
import
Gargantext.API.Viz.Types
(
PhyloData
)
...
@@ -58,6 +59,7 @@ import Gargantext.Database.Admin.Types.Hyperdata qualified as Hyperdata
...
@@ -58,6 +59,7 @@ import Gargantext.Database.Admin.Types.Hyperdata qualified as Hyperdata
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
UserId
(
..
),
NodeType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
UserId
(
..
),
NodeType
(
..
))
import
Gargantext.Database.Query.Facet
(
OrderBy
(
..
))
import
Gargantext.Database.Query.Facet
(
OrderBy
(
..
))
import
Gargantext.Prelude
hiding
(
replace
,
Location
)
import
Gargantext.Prelude
hiding
(
replace
,
Location
)
import
Servant.Client.Core.BaseUrl
(
BaseUrl
(
..
),
Scheme
(
Http
))
import
Text.Parsec.Error
(
ParseError
,
Message
(
..
),
newErrorMessage
)
import
Text.Parsec.Error
(
ParseError
,
Message
(
..
),
newErrorMessage
)
import
Text.Parsec.Pos
import
Text.Parsec.Pos
import
Test.QuickCheck
import
Test.QuickCheck
...
@@ -155,6 +157,11 @@ defaultPublicData =
...
@@ -155,6 +157,11 @@ defaultPublicData =
instance
Arbitrary
PublishRequest
where
instance
Arbitrary
PublishRequest
where
arbitrary
=
PublishRequest
<$>
arbitraryBoundedEnum
arbitrary
=
PublishRequest
<$>
arbitraryBoundedEnum
instance
Arbitrary
RemoteExportRequest
where
arbitrary
=
RemoteExportRequest
<$>
(
pure
(
BaseUrl
Http
"dev.sub.gargantext.org"
8008
""
))
<*>
arbitrary
instance
Arbitrary
SearchQuery
where
instance
Arbitrary
SearchQuery
where
arbitrary
=
elements
[
SearchQuery
(
RawQuery
"electrodes"
)
SearchDoc
]
arbitrary
=
elements
[
SearchQuery
(
RawQuery
"electrodes"
)
SearchDoc
]
-- arbitrary = elements [SearchQuery "electrodes" 1 ] --SearchDoc]
-- arbitrary = elements [SearchQuery "electrodes" 1 ] --SearchDoc]
...
...
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