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
199
Issues
199
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
e1d48283
Commit
e1d48283
authored
Oct 21, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Phylo] readings
parent
8113d268
Pipeline
#1160
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
81 deletions
+54
-81
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+19
-58
LevelMaker.hs
src/Gargantext/Core/Viz/Phylo/LevelMaker.hs
+15
-12
Main.hs
src/Gargantext/Core/Viz/Phylo/Main.hs
+20
-11
No files found.
src/Gargantext/Core/Viz/Phylo/API.hs
View file @
e1d48283
...
@@ -115,11 +115,11 @@ postPhylo :: CorpusId -> UserId -> GargServer PostPhylo
...
@@ -115,11 +115,11 @@ postPhylo :: CorpusId -> UserId -> GargServer PostPhylo
postPhylo
n
userId
_lId
=
do
postPhylo
n
userId
_lId
=
do
-- TODO get Reader settings
-- TODO get Reader settings
-- s <- ask
-- s <- ask
let
--
let
-- _vrs = Just ("1" :: Text)
-- _vrs = Just ("1" :: Text)
-- _sft = Just (Software "Gargantext" "4")
-- _sft = Just (Software "Gargantext" "4")
-- _prm = initPhyloParam vrs sft (Just q)
-- _prm = initPhyloParam vrs sft (Just q)
phy
<-
flowPhylo
n
phy
<-
flowPhylo
n
pId
<-
insertNodes
[
node
NodePhylo
"Phylo"
(
HyperdataPhylo
Nothing
(
Just
phy
))
(
Just
n
)
userId
]
pId
<-
insertNodes
[
node
NodePhylo
"Phylo"
(
HyperdataPhylo
Nothing
(
Just
phy
))
(
Just
n
)
userId
]
pure
$
NodeId
(
fromIntegral
pId
)
pure
$
NodeId
(
fromIntegral
pId
)
...
@@ -136,64 +136,25 @@ putPhylo = undefined
...
@@ -136,64 +136,25 @@ putPhylo = undefined
-- | Instances
-- | Instances
instance
Arbitrary
PhyloView
instance
Arbitrary
Phylo
where
arbitrary
=
elements
[
phylo
]
where
instance
Arbitrary
PhyloGroup
where
arbitrary
=
elements
[]
arbitrary
=
elements
[
phyloView
]
instance
Arbitrary
PhyloView
where
arbitrary
=
elements
[
phyloView
]
instance
FromHttpApiData
DisplayMode
where
parseUrlPiece
=
readTextData
-- | TODO add phyloGroup ex
instance
FromHttpApiData
ExportMode
where
parseUrlPiece
=
readTextData
instance
Arbitrary
PhyloGroup
instance
FromHttpApiData
Filiation
where
parseUrlPiece
=
readTextData
where
instance
FromHttpApiData
Metric
where
parseUrlPiece
=
readTextData
arbitrary
=
elements
[]
instance
FromHttpApiData
Order
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Sort
where
parseUrlPiece
=
readTextData
instance
Arbitrary
Phylo
instance
FromHttpApiData
Tagger
where
parseUrlPiece
=
readTextData
where
instance
FromHttpApiData
[
Metric
]
where
parseUrlPiece
=
readTextData
arbitrary
=
elements
[
phylo
]
instance
FromHttpApiData
[
Tagger
]
where
parseUrlPiece
=
readTextData
instance
ToSchema
Order
instance
ToParamSchema
Order
instance
FromHttpApiData
Order
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
Metric
instance
FromHttpApiData
[
Metric
]
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Metric
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
DisplayMode
instance
ToParamSchema
DisplayMode
instance
FromHttpApiData
DisplayMode
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
ExportMode
instance
ToParamSchema
ExportMode
instance
FromHttpApiData
ExportMode
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Sort
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
Sort
instance
FromHttpApiData
[
Tagger
]
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Tagger
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
Tagger
instance
FromHttpApiData
Filiation
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
Filiation
instance
ToParamSchema
Filiation
instance
ToParamSchema
Tagger
instance
ToParamSchema
Metric
instance
ToParamSchema
Order
instance
ToParamSchema
Sort
instance
ToSchema
Order
src/Gargantext/Core/Viz/Phylo/LevelMaker.hs
View file @
e1d48283
...
@@ -195,9 +195,13 @@ toPhylo q c termList fis = toNthLevel (getNthLevel q) (getInterTemporalMatching
...
@@ -195,9 +195,13 @@ toPhylo q c termList fis = toNthLevel (getNthLevel q) (getInterTemporalMatching
phyloDocs
=
groupDocsByPeriod
date
(
getPhyloPeriods
phyloBase
)
c
phyloDocs
=
groupDocsByPeriod
date
(
getPhyloPeriods
phyloBase
)
c
--------------------------------------
--------------------------------------
phyloBase
::
Phylo
phyloBase
::
Phylo
phyloBase
=
tracePhyloBase
phyloBase
=
tracePhyloBase
$
toPhyloBase
q
(
initPhyloParam
(
Just
defaultPhyloVersion
)
(
Just
defaultSoftware
)
(
Just
q
))
c
termList
fis
$
toPhyloBase
q
init
c
termList
fis
--------------------------------------
where
init
=
initPhyloParam
(
Just
defaultPhyloVersion
)
(
Just
defaultSoftware
)
(
Just
q
)
---------------------------------------
-- | To incrementally add new Levels to a Phylo by making all the linking and aggregation tasks
-- | To incrementally add new Levels to a Phylo by making all the linking and aggregation tasks
...
@@ -205,17 +209,16 @@ toNthLevel :: Level -> Proximity -> Cluster -> Phylo -> Phylo
...
@@ -205,17 +209,16 @@ toNthLevel :: Level -> Proximity -> Cluster -> Phylo -> Phylo
toNthLevel
lvlMax
prox
clus
p
toNthLevel
lvlMax
prox
clus
p
|
lvl
>=
lvlMax
=
p
|
lvl
>=
lvlMax
=
p
|
otherwise
=
toNthLevel
lvlMax
prox
clus
|
otherwise
=
toNthLevel
lvlMax
prox
clus
$
traceBranches
(
lvl
+
1
)
$
traceBranches
(
lvl
+
1
)
$
setPhyloBranches
(
lvl
+
1
)
$
setPhyloBranches
(
lvl
+
1
)
-- \$ transposePeriodLinks (lvl + 1)
-- \$ transposePeriodLinks (lvl + 1)
$
traceTranspose
(
lvl
+
1
)
Descendant
$
traceTranspose
(
lvl
+
1
)
Descendant
$
transposeLinks
(
lvl
+
1
)
Descendant
$
transposeLinks
(
lvl
+
1
)
Descendant
$
traceTranspose
(
lvl
+
1
)
Ascendant
$
traceTranspose
(
lvl
+
1
)
Ascendant
$
transposeLinks
(
lvl
+
1
)
Ascendant
$
transposeLinks
(
lvl
+
1
)
Ascendant
$
tracePhyloN
(
lvl
+
1
)
$
tracePhyloN
(
lvl
+
1
)
$
setLevelLinks
(
lvl
,
lvl
+
1
)
$
setLevelLinks
(
lvl
,
lvl
+
1
)
$
addPhyloLevel
(
lvl
+
1
)
$
addPhyloLevel
(
lvl
+
1
)
(
clusters
)
p
(
clusters
)
p
where
where
--------------------------------------
--------------------------------------
clusters
::
Map
(
Date
,
Date
)
[
PhyloCluster
]
clusters
::
Map
(
Date
,
Date
)
[
PhyloCluster
]
...
...
src/Gargantext/Core/Viz/Phylo/Main.hs
View file @
e1d48283
...
@@ -35,12 +35,14 @@ import Gargantext.Database.Schema.Ngrams (NgramsType(..))
...
@@ -35,12 +35,14 @@ import Gargantext.Database.Schema.Ngrams (NgramsType(..))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Terms.WithList
import
Gargantext.Core.Text.Terms.WithList
import
Gargantext.Core.Viz.Phylo
hiding
(
Svg
,
Dot
)
import
Gargantext.Core.Viz.Phylo
hiding
(
Svg
,
Dot
)
import
Gargantext.Core.Viz.Phylo.LevelMaker
import
Gargantext.Core.Viz.Phylo.LevelMaker
(
toPhylo
)
import
Gargantext.Core.Viz.Phylo.Tools
import
Gargantext.Core.Viz.Phylo.Tools
import
Gargantext.Core.Viz.Phylo.View.Export
import
Gargantext.Core.Viz.Phylo.View.Export
import
Gargantext.Core.Viz.Phylo.View.ViewMaker
-- TODO Just Maker is fine
import
Gargantext.Core.Viz.Phylo.View.ViewMaker
-- TODO Just Maker is fine
type
MinSizeBranch
=
Int
type
MinSizeBranch
=
Int
flowPhylo
::
FlowCmdM
env
err
m
flowPhylo
::
FlowCmdM
env
err
m
...
@@ -48,14 +50,14 @@ flowPhylo :: FlowCmdM env err m
...
@@ -48,14 +50,14 @@ flowPhylo :: FlowCmdM env err m
->
m
Phylo
->
m
Phylo
flowPhylo
cId
=
do
flowPhylo
cId
=
do
list
<-
defaultList
cId
list
<-
defaultList
cId
termList
<-
Map
.
toList
<$>
getTermsWith
Text
.
words
[
list
]
NgramsTerms
MapTerm
termList
<-
Map
.
toList
<$>
getTermsWith
Text
.
words
[
list
]
NgramsTerms
MapTerm
docs'
<-
catMaybes
docs'
<-
catMaybes
<$>
map
(
\
h
->
(,)
<$>
_hd_publication_year
h
<$>
map
(
\
h
->
(,)
<$>
_hd_publication_year
h
<*>
_hd_abstract
h
<*>
_hd_abstract
h
)
)
<$>
selectDocs
cId
<$>
selectDocs
cId
let
let
patterns
=
buildPatterns
termList
patterns
=
buildPatterns
termList
...
@@ -65,10 +67,13 @@ flowPhylo cId = do
...
@@ -65,10 +67,13 @@ flowPhylo cId = do
where
where
--------------------------------------
--------------------------------------
termsInText
::
Patterns
->
Text
->
[
Text
]
termsInText
::
Patterns
->
Text
->
[
Text
]
termsInText
pats
txt
=
List
.
nub
$
List
.
concat
$
map
(
map
Text
.
unwords
)
$
extractTermsWithList
pats
txt
termsInText
pats
txt
=
List
.
nub
$
List
.
concat
$
map
(
map
Text
.
unwords
)
$
extractTermsWithList
pats
txt
--------------------------------------
--------------------------------------
docs
=
map
(
(
\
(
y
,
t
)
->
Document
y
t
)
.
filterTerms
patterns
)
docs'
docs
=
map
((
\
(
y
,
t
)
->
Document
y
t
)
.
filterTerms
patterns
)
docs'
--liftBase $ flowPhylo' (List.sortOn date docs) termList l m fp
--liftBase $ flowPhylo' (List.sortOn date docs) termList l m fp
pure
$
buildPhylo
(
List
.
sortOn
date
docs
)
termList
pure
$
buildPhylo
(
List
.
sortOn
date
docs
)
termList
...
@@ -76,9 +81,9 @@ flowPhylo cId = do
...
@@ -76,9 +81,9 @@ flowPhylo cId = do
-- TODO SortedList Document
-- TODO SortedList Document
flowPhylo'
::
[
Document
]
->
TermList
-- ^Build
flowPhylo'
::
[
Document
]
->
TermList
-- ^Build
->
Level
->
MinSizeBranch
-- ^View
->
Level
->
MinSizeBranch
-- ^View
->
FilePath
->
FilePath
->
IO
FilePath
->
IO
FilePath
flowPhylo'
corpus
terms
l
m
fp
=
do
flowPhylo'
corpus
terms
l
m
fp
=
do
let
let
phylo
=
buildPhylo
corpus
terms
phylo
=
buildPhylo
corpus
terms
...
@@ -116,3 +121,7 @@ writePhylo fp phview = runGraphviz (viewToDot phview) Svg fp
...
@@ -116,3 +121,7 @@ writePhylo fp phview = runGraphviz (viewToDot phview) Svg fp
viewPhylo2Svg
::
PhyloView
->
IO
DB
.
ByteString
viewPhylo2Svg
::
PhyloView
->
IO
DB
.
ByteString
viewPhylo2Svg
p
=
graphvizWithHandle
Dot
(
viewToDot
p
)
Svg
DB
.
hGetContents
viewPhylo2Svg
p
=
graphvizWithHandle
Dot
(
viewToDot
p
)
Svg
DB
.
hGetContents
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