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
195
Issues
195
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
3d6fbdb3
Commit
3d6fbdb3
authored
Apr 08, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API][PHYLO] Get + Post (put not implemented yet) + Del same as others nodes.
parent
e10cf51e
Pipeline
#345
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
41 deletions
+52
-41
API.hs
src/Gargantext/API.hs
+1
-8
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+7
-7
API.hs
src/Gargantext/Viz/Phylo/API.hs
+28
-19
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+16
-7
No files found.
src/Gargantext/API.hs
View file @
3d6fbdb3
...
@@ -8,15 +8,8 @@ Stability : experimental
...
@@ -8,15 +8,8 @@ Stability : experimental
Portability : POSIX
Portability : POSIX
Main REST API of Gargantext (both Server and Client sides)
Main REST API of Gargantext (both Server and Client sides)
Thanks @yannEsposito for our discussions at the beginning of this project :).
TODO App type, the main monad in which the bot code is written with.
Provide config, state, logs and IO
type App m a = ( MonadState AppState m
, MonadReader Conf m
, MonadLog (WithSeverity Doc) m
, MonadIO m) => m a
Thanks @yannEsposito for this.
-}
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
...
...
src/Gargantext/Viz/Phylo.hs
View file @
3d6fbdb3
...
@@ -238,21 +238,21 @@ data PhyloError = LevelDoesNotExist
...
@@ -238,21 +238,21 @@ data PhyloError = LevelDoesNotExist
data
Cluster
=
Fis
FisParams
data
Cluster
=
Fis
FisParams
|
RelatedComponents
RCParams
|
RelatedComponents
RCParams
|
Louvain
LouvainParams
|
Louvain
LouvainParams
deriving
(
Generic
,
Show
,
Eq
)
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-- | Parameters for Fis clustering
-- | Parameters for Fis clustering
data
FisParams
=
FisParams
data
FisParams
=
FisParams
{
_fis_keepMinorFis
::
Bool
{
_fis_keepMinorFis
::
Bool
,
_fis_minSupport
::
Support
,
_fis_minSupport
::
Support
}
deriving
(
Generic
,
Show
,
Eq
)
}
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-- | Parameters for RelatedComponents clustering
-- | Parameters for RelatedComponents clustering
data
RCParams
=
RCParams
data
RCParams
=
RCParams
{
_rc_proximity
::
Proximity
}
deriving
(
Generic
,
Show
,
Eq
)
{
_rc_proximity
::
Proximity
}
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-- | Parameters for Louvain clustering
-- | Parameters for Louvain clustering
data
LouvainParams
=
LouvainParams
data
LouvainParams
=
LouvainParams
{
_louvain_proximity
::
Proximity
}
deriving
(
Generic
,
Show
,
Eq
)
{
_louvain_proximity
::
Proximity
}
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-------------------
-------------------
...
@@ -264,17 +264,17 @@ data LouvainParams = LouvainParams
...
@@ -264,17 +264,17 @@ data LouvainParams = LouvainParams
data
Proximity
=
WeightedLogJaccard
WLJParams
data
Proximity
=
WeightedLogJaccard
WLJParams
|
Hamming
HammingParams
|
Hamming
HammingParams
|
Filiation
|
Filiation
deriving
(
Generic
,
Show
,
Eq
)
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-- | Parameters for WeightedLogJaccard proximity
-- | Parameters for WeightedLogJaccard proximity
data
WLJParams
=
WLJParams
data
WLJParams
=
WLJParams
{
_wlj_threshold
::
Double
{
_wlj_threshold
::
Double
,
_wlj_sensibility
::
Double
,
_wlj_sensibility
::
Double
}
deriving
(
Generic
,
Show
,
Eq
)
}
deriving
(
Generic
,
Show
,
Eq
,
Read
)
-- | Parameters for Hamming proximity
-- | Parameters for Hamming proximity
data
HammingParams
=
HammingParams
data
HammingParams
=
HammingParams
{
_hamming_threshold
::
Double
}
deriving
(
Generic
,
Show
,
Eq
)
{
_hamming_threshold
::
Double
}
deriving
(
Generic
,
Show
,
Eq
,
Read
)
----------------
----------------
...
...
src/Gargantext/Viz/Phylo/API.hs
View file @
3d6fbdb3
...
@@ -24,6 +24,8 @@ Portability : POSIX
...
@@ -24,6 +24,8 @@ Portability : POSIX
module
Gargantext.Viz.Phylo.API
module
Gargantext.Viz.Phylo.API
where
where
--import Control.Monad.Reader (ask)
import
Data.Text
(
Text
)
import
Data.Swagger
import
Data.Swagger
import
Gargantext.API.Types
import
Gargantext.API.Types
import
Gargantext.Database.Types.Node
(
PhyloId
,
ListId
,
CorpusId
)
import
Gargantext.Database.Types.Node
(
PhyloId
,
ListId
,
CorpusId
)
...
@@ -32,6 +34,7 @@ import Gargantext.Viz.Phylo
...
@@ -32,6 +34,7 @@ import Gargantext.Viz.Phylo
import
Gargantext.Viz.Phylo.Example
import
Gargantext.Viz.Phylo.Example
import
Gargantext.Viz.Phylo.Tools
import
Gargantext.Viz.Phylo.Tools
import
Gargantext.Viz.Phylo.View.ViewMaker
import
Gargantext.Viz.Phylo.View.ViewMaker
import
Gargantext.Viz.Phylo.LevelMaker
import
Servant
import
Servant
import
Servant.Job.Utils
(
swaggerOptions
)
import
Servant.Job.Utils
(
swaggerOptions
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
...
@@ -40,19 +43,15 @@ import Web.HttpApiData (parseUrlPiece, readTextData)
...
@@ -40,19 +43,15 @@ import Web.HttpApiData (parseUrlPiece, readTextData)
------------------------------------------------------------------------
------------------------------------------------------------------------
type
PhyloAPI
=
Summary
"Phylo API"
type
PhyloAPI
=
Summary
"Phylo API"
-- :> QueryParam "param" PhyloQueryView
-- :<|>
:>
GetPhylo
:>
GetPhylo
:<|>
PutPhylo
-- :<|> PutPhylo
-- :<|> Capture "id" PhyloId :> Post '[JSON] Phylo
:<|>
PostPhylo
-- :<|> Capture "id" PhyloId :> Put '[JSON] Phylo
phyloAPI
::
PhyloId
->
GargServer
PhyloAPI
phyloAPI
::
PhyloId
->
GargServer
PhyloAPI
phyloAPI
n
=
getPhylo
n
phyloAPI
n
=
getPhylo
n
:<|>
putPhylo
n
-- :<|> putPhylo n
-- :<|> pure . (postPhylo n)
:<|>
postPhylo
n
------------------------------------------------------------------------
------------------------------------------------------------------------
type
GetPhylo
=
QueryParam
"listId"
ListId
type
GetPhylo
=
QueryParam
"listId"
ListId
...
@@ -66,7 +65,7 @@ type GetPhylo = QueryParam "listId" ListId
...
@@ -66,7 +65,7 @@ type GetPhylo = QueryParam "listId" ListId
:>
QueryParam
"minNodes"
Int
:>
QueryParam
"minNodes"
Int
:>
QueryParam
"taggers"
[
Tagger
]
:>
QueryParam
"taggers"
[
Tagger
]
:>
QueryParam
"sort"
Sort
:>
QueryParam
"sort"
Sort
:>
QueryParam
"
sort"
Order
:>
QueryParam
"
order"
Order
:>
QueryParam
"display"
DisplayMode
:>
QueryParam
"display"
DisplayMode
:>
QueryParam
"verbose"
Bool
:>
QueryParam
"verbose"
Bool
:>
Get
'[
J
SON
]
PhyloView
:>
Get
'[
J
SON
]
PhyloView
...
@@ -84,22 +83,35 @@ getPhylo _phyloId _lId l f b l' ms x y z ts s o d b' = do
...
@@ -84,22 +83,35 @@ getPhylo _phyloId _lId l f b l' ms x y z ts s o d b' = do
pure
(
toPhyloView
q
phylo
)
pure
(
toPhyloView
q
phylo
)
------------------------------------------------------------------------
------------------------------------------------------------------------
{-
type PutPhylo = (Put '[JSON] Phylo )
type PutPhylo = (Put '[JSON] Phylo )
--putPhylo :: PhyloId -> Maybe ListId -> PhyloQueryBuild -> Phylo
--putPhylo :: PhyloId -> Maybe ListId -> PhyloQueryBuild -> Phylo
putPhylo :: PhyloId -> GargServer PutPhylo
putPhylo :: PhyloId -> GargServer PutPhylo
putPhylo = undefined
putPhylo = undefined
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
type
PostPhylo
=
(
Post
'[
J
SON
]
Phylo
)
type
PostPhylo
=
QueryParam
"listId"
ListId
--postPhylo :: CorpusId -> Maybe ListId -> PhyloQueryBuild -> Phylo
:>
ReqBody
'[
J
SON
]
PhyloQueryBuild
postPhylo
::
CorpusId
->
Phylo
:>
(
Post
'[
J
SON
]
Phylo
)
postPhylo
=
undefined
postPhylo
::
CorpusId
->
GargServer
PostPhylo
postPhylo
_n
_lId
q
=
do
-- TODO get Reader settings
-- s <- ask
let
vrs
=
Just
(
"1"
::
Text
)
sft
=
Just
(
Software
"Gargantext"
"4"
)
prm
=
initPhyloParam
vrs
sft
(
Just
q
)
pure
(
toPhyloBase
q
prm
corpus
actants
actantsTrees
)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | DELETE Phylo == delete a node
-- | DELETE Phylo == delete a node
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Instances
-- | Instances
instance
Arbitrary
PhyloView
instance
Arbitrary
PhyloView
where
where
...
@@ -115,8 +127,6 @@ instance Arbitrary Phylo
...
@@ -115,8 +127,6 @@ instance Arbitrary Phylo
arbitrary
=
elements
[
phylo
]
arbitrary
=
elements
[
phylo
]
instance
ToSchema
Cluster
instance
ToSchema
Cluster
instance
ToSchema
EdgeType
instance
ToSchema
EdgeType
instance
ToSchema
Filiation
instance
ToSchema
Filiation
...
@@ -194,4 +204,3 @@ instance FromHttpApiData Filiation
...
@@ -194,4 +204,3 @@ instance FromHttpApiData Filiation
instance
ToParamSchema
Filiation
instance
ToParamSchema
Filiation
src/Gargantext/Viz/Phylo/Tools.hs
View file @
3d6fbdb3
...
@@ -146,7 +146,9 @@ initPhyloBase pds fds pks prm = Phylo ((fst . (head' "initPhyloBase")) pds, (snd
...
@@ -146,7 +146,9 @@ initPhyloBase pds fds pks prm = Phylo ((fst . (head' "initPhyloBase")) pds, (snd
-- | To init the param of a Phylo
-- | To init the param of a Phylo
initPhyloParam
::
Maybe
Text
->
Maybe
Software
->
Maybe
PhyloQueryBuild
->
PhyloParam
initPhyloParam
::
Maybe
Text
->
Maybe
Software
->
Maybe
PhyloQueryBuild
->
PhyloParam
initPhyloParam
(
def
defaultPhyloVersion
->
v
)
(
def
defaultSoftware
->
s
)
(
def
defaultQuery
->
q
)
=
PhyloParam
v
s
q
initPhyloParam
(
def
defaultPhyloVersion
->
v
)
(
def
defaultSoftware
->
s
)
(
def
defaultQueryBuild
->
q
)
=
PhyloParam
v
s
q
-- | To get the foundations of a Phylo
-- | To get the foundations of a Phylo
getFoundations
::
Phylo
->
Vector
Ngrams
getFoundations
::
Phylo
->
Vector
Ngrams
...
@@ -655,10 +657,14 @@ initWeightedLogJaccard (def 0 -> thr) (def 0.01 -> sens) = WLJParams thr sens
...
@@ -655,10 +657,14 @@ initWeightedLogJaccard (def 0 -> thr) (def 0.01 -> sens) = WLJParams thr sens
-- | To initialize a PhyloQuery from given and default parameters
-- | To initialize a PhyloQuery from given and default parameters
initPhyloQuery
::
Text
->
Text
->
Maybe
Int
->
Maybe
Int
->
Maybe
Cluster
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
Proximity
->
Maybe
Level
->
Maybe
Cluster
->
PhyloQueryBuild
initPhyloQuery
Build
::
Maybe
Text
->
Maybe
Text
->
Maybe
Int
->
Maybe
Int
->
Maybe
Cluster
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
Proximity
->
Maybe
Level
->
Maybe
Cluster
->
PhyloQueryBuild
initPhyloQuery
name
desc
(
def
5
->
grain
)
(
def
3
->
steps
)
(
def
defaultFis
->
cluster
)
(
def
[]
->
metrics
)
(
def
[]
->
filters
)
initPhyloQuery
Build
name
desc
(
def
5
->
grain
)
(
def
3
->
steps
)
(
def
defaultFis
->
cluster
)
(
def
[]
->
metrics
)
(
def
[]
->
filters
)
(
def
defaultWeightedLogJaccard
->
matching'
)
(
def
2
->
nthLevel
)
(
def
defaultRelatedComponents
->
nthCluster
)
=
(
def
defaultWeightedLogJaccard
->
matching'
)
(
def
2
->
nthLevel
)
(
def
defaultRelatedComponents
->
nthCluster
)
=
PhyloQueryBuild
name
desc
grain
steps
cluster
metrics
filters
matching'
nthLevel
nthCluster
PhyloQueryBuild
name'
desc'
grain
steps
cluster
metrics
filters
matching'
nthLevel
nthCluster
where
name'
=
maybe
"Phylo Title"
identity
name
desc'
=
maybe
"Phylo Desc"
identity
desc
-- | To initialize a PhyloQueryView default parameters
-- | To initialize a PhyloQueryView default parameters
...
@@ -706,9 +712,12 @@ defaultWeightedLogJaccard = WeightedLogJaccard (initWeightedLogJaccard Nothing N
...
@@ -706,9 +712,12 @@ defaultWeightedLogJaccard = WeightedLogJaccard (initWeightedLogJaccard Nothing N
-- Queries
-- Queries
defaultQuery
::
PhyloQueryBuild
defaultQueryBuild
::
PhyloQueryBuild
defaultQuery
=
initPhyloQuery
"Cesar et Cleôpatre"
"An example of Phylomemy (french without accent)"
defaultQueryBuild
=
initPhyloQueryBuild
(
Just
"Cesar et Cleôpatre"
)
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
(
Just
"An example of Phylomemy (french without accent)"
)
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
defaultQueryView
::
PhyloQueryView
defaultQueryView
::
PhyloQueryView
defaultQueryView
=
initPhyloQueryView
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
defaultQueryView
=
initPhyloQueryView
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
...
...
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