Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-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
1
Merge Requests
1
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
purescript-gargantext
Commits
471fbf05
Commit
471fbf05
authored
Oct 28, 2021
by
arturo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
>>> continue
parent
7a9fdad7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
129 deletions
+118
-129
Phylo.purs
src/Gargantext/Components/Nodes/Corpus/Phylo.purs
+2
-2
JSON.purs
src/Gargantext/Components/PhyloExplorer/JSON.purs
+12
-12
Layout.purs
src/Gargantext/Components/PhyloExplorer/Layout.purs
+57
-27
Types.js
src/Gargantext/Components/PhyloExplorer/Types.js
+0
-68
Types.purs
src/Gargantext/Components/PhyloExplorer/Types.purs
+47
-20
No files found.
src/Gargantext/Components/Nodes/Corpus/Phylo.purs
View file @
471fbf05
...
@@ -14,7 +14,7 @@ import Effect.Aff (Aff, launchAff_)
...
@@ -14,7 +14,7 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSONSet)
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSONSet)
import Gargantext.Components.PhyloExplorer.Layout (layout)
import Gargantext.Components.PhyloExplorer.Layout (layout)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet
, parsePhyloJSONSet
)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (NodeID)
import Gargantext.Types (NodeID)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -37,7 +37,7 @@ phyloLayoutCpt :: R.Component Props
...
@@ -37,7 +37,7 @@ phyloLayoutCpt :: R.Component Props
phyloLayoutCpt = here.component "phyloLayout" cpt where
phyloLayoutCpt = here.component "phyloLayout" cpt where
cpt _ _ = do
cpt _ _ = do
fetchedDataBox <- T.useBox (Nothing :: Maybe Phylo
JSON
Set)
fetchedDataBox <- T.useBox (Nothing :: Maybe Phylo
Data
Set)
fetchedData <- T.useLive T.unequal fetchedDataBox
fetchedData <- T.useLive T.unequal fetchedDataBox
R.useEffectOnce' $ launchAff_ do
R.useEffectOnce' $ launchAff_ do
...
...
src/Gargantext/Components/PhyloExplorer/JSON.purs
View file @
471fbf05
...
@@ -42,8 +42,8 @@ type GraphData =
...
@@ -42,8 +42,8 @@ type GraphData =
newtype PhyloJSONSet = PhyloJSONSet
newtype PhyloJSONSet = PhyloJSONSet
{ _subgraph_cnt :: Int
{ _subgraph_cnt :: Int
, directed :: Boolean
, directed :: Boolean
, edges :: Array Edge
, edges :: Array
Raw
Edge
, objects :: Array
Phylo
Object
, objects :: Array
Raw
Object
, strict :: Boolean
, strict :: Boolean
| GraphData
| GraphData
}
}
...
@@ -65,7 +65,7 @@ type NodeData =
...
@@ -65,7 +65,7 @@ type NodeData =
, width :: String
, width :: String
)
)
data
Phylo
Object
data
Raw
Object
= Layer
= Layer
{ _gvid :: Int
{ _gvid :: Int
, nodes :: Array Int
, nodes :: Array Int
...
@@ -116,10 +116,10 @@ data PhyloObject
...
@@ -116,10 +116,10 @@ data PhyloObject
| NodeData
| NodeData
}
}
derive instance Generic
Phylo
Object _
derive instance Generic
Raw
Object _
derive instance Eq
Phylo
Object
derive instance Eq
Raw
Object
instance Show
Phylo
Object where show = genericShow
instance Show
Raw
Object where show = genericShow
instance JSON.ReadForeign
Phylo
Object where
instance JSON.ReadForeign
Raw
Object where
readImpl f = GR.to <$> untaggedSumRep f
readImpl f = GR.to <$> untaggedSumRep f
...
@@ -133,7 +133,7 @@ type EdgeData =
...
@@ -133,7 +133,7 @@ type EdgeData =
, width :: String
, width :: String
)
)
data Edge
data
Raw
Edge
= GroupToGroup
= GroupToGroup
{ _gvid :: Int
{ _gvid :: Int
, constraint :: String
, constraint :: String
...
@@ -167,8 +167,8 @@ data Edge
...
@@ -167,8 +167,8 @@ data Edge
| EdgeData
| EdgeData
}
}
derive instance Generic Edge _
derive instance Generic
Raw
Edge _
derive instance Eq Edge
derive instance Eq
Raw
Edge
instance Show Edge where show = genericShow
instance Show
Raw
Edge where show = genericShow
instance JSON.ReadForeign Edge where
instance JSON.ReadForeign
Raw
Edge where
readImpl f = GR.to <$> untaggedSumRep f
readImpl f = GR.to <$> untaggedSumRep f
src/Gargantext/Components/PhyloExplorer/Layout.purs
View file @
471fbf05
...
@@ -5,6 +5,7 @@ module Gargantext.Components.PhyloExplorer.Layout
...
@@ -5,6 +5,7 @@ module Gargantext.Components.PhyloExplorer.Layout
import Gargantext.Prelude
import Gargantext.Prelude
import DOM.Simple (Window, window)
import DOM.Simple (Window, window)
import DOM.Simple.Console (log2)
import Data.Array as Array
import Data.Array as Array
import Data.Date as Date
import Data.Date as Date
import Data.FoldableWithIndex (forWithIndex_)
import Data.FoldableWithIndex (forWithIndex_)
...
@@ -12,17 +13,20 @@ import Data.Int as Int
...
@@ -12,17 +13,20 @@ import Data.Int as Int
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
import Data.Number as Number
import Data.Number as Number
import Data.String as String
import Data.String as String
import Data.Traversable (for)
import Data.Symbol (SProxy(..))
import Data.Traversable (for, for_)
import Data.Tuple as Tuple
import Data.Tuple as Tuple
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import FFI.Simple (maybeGetProperty, (..), (...))
import FFI.Simple (maybeGetProperty, (..), (...)
, (.=), (.?)
)
import Gargantext.Components.PhyloExplorer.Types (G
roup
, PhyloDataSet(..))
import Gargantext.Components.PhyloExplorer.Types (G
lobalTerm(..), Group(..)
, PhyloDataSet(..))
import Gargantext.Utils (nbsp)
import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Record (get)
import Toestand as T
import Toestand as T
import Type.Proxy (Proxy(..))
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.PhyloExplorer"
here = R2.here "Gargantext.Components.PhyloExplorer"
...
@@ -41,7 +45,7 @@ layoutCpt = here.component "layout" cpt where
...
@@ -41,7 +45,7 @@ layoutCpt = here.component "layout" cpt where
R.useEffectOnce' $ do
R.useEffectOnce' $ do
pure unit
setGlobalDependencies window (PhyloDataSet o)
-- @hightlightSource
-- @hightlightSource
let
let
...
@@ -260,29 +264,55 @@ layoutCpt = here.component "layout" cpt where
...
@@ -260,29 +264,55 @@ layoutCpt = here.component "layout" cpt where
setGlobalDependencies :: Window -> PhyloDataSet -> Effect Unit
setGlobalDependencies :: Window -> PhyloDataSet -> Effect Unit
setGlobalDependencies w (PhyloDataSet o)
setGlobalDependencies w (PhyloDataSet o)
= do
= do
-- _ <- w ... "freq" $ {}
_ <- pure $ (w .= "freq") {}
-- _ <- w ... "nbBranches" $ o.nbBranches
_ <- pure $ (w .= "nbBranches") o.nbBranches
-- _ <- w ... "nbDocs" $ o.nbDocs
_ <- pure $ (w .= "nbDocs") o.nbDocs
-- _ <- w ... "nbFoundations" $ o.nbFoundations
_ <- pure $ (w .= "nbFoundations") o.nbFoundations
-- _ <- w ... "nbGroups" $ o.nbGroups
_ <- pure $ (w .= "nbGroups") o.nbGroups
-- _ <- w ... "nbPeriods" $ o.nbPeriods
_ <- pure $ (w .= "nbPeriods") o.nbPeriods
-- _ <- w ... "nbTerms" $ o.nbTerms
_ <- pure $ (w .= "nbTerms") o.nbTerms
-- _ <- w ... "sources" $ o.sources
_ <- pure $ (w .= "sources") o.sources
-- _ <- w ... "terms" $ {}
_ <- pure $ (w .= "terms") []
-- _ <- w ... "timeScale" $ o.timeScale
_ <- pure $ (w .= "timeScale") o.timeScale
-- _ <- w ... "weighted" $ o.weighted
_ <- pure $ (w .= "weighted") o.weighted
(freq :: Array Int) <- pure $ w .. "freq"
(freq :: Array Int) <- pure $ w .. "freq"
pure unit
(terms :: Array GlobalTerm) <- pure $ w .. "terms"
-- forWithIndex_ o.foundations $ \i _ -> case maybeGetProperty (show i) freq of
-- Nothing -> freq ... (show i) $ 0
void $ for o.groups \(Group g) -> do
-- Just v -> freq ... (show i) $ (v + 1)
let
-- pure $ for o.groups \(g :: Group)-> pure unit
f = g.foundation
l = g.label
log2 "FOUNDATION" f
log2 "LABEL" l
-- For each entries in group.foundation array,
-- increment consequently the global window.keys array
-- forWithIndex_ f \i _ ->
-- let i' = show i
-- in case (freq .? i') of
-- Nothing -> pure $ (freq .= i') 0
-- Just v -> pure $ (freq .= i') (v +1)
for_ f \i ->
let i' = show i
in case (freq .? i') of
Nothing -> pure $ (freq .= i') 0
Just v -> pure $ (freq .= i') (v +1)
-- For each entries in group.foundation array,
-- if the global window.terms does not have it in property,
-- append an item to the global window.terms
for_ f \i ->
let i' = show i
in case (terms .? i') of
Nothing -> pure unit
Just _ -> void <<< pure $ (terms .= i') $ GlobalTerm
{ label: l .. i'
, fdt : f .. i'
}
--------------------------------------------------------
--------------------------------------------------------
type PhyloCorpusProps = ()
type PhyloCorpusProps = ()
...
...
src/Gargantext/Components/PhyloExplorer/Types.js
View file @
471fbf05
...
@@ -52,74 +52,6 @@ exports.utcStringToDate = utcStringToDate;
...
@@ -52,74 +52,6 @@ exports.utcStringToDate = utcStringToDate;
function
draw
(
json
)
{
function
draw
(
json
)
{
// groups
window
.
weighted
=
false
;
var
groups
=
json
.
objects
.
filter
(
node
=>
node
.
nodeType
==
"group"
).
map
(
function
(
g
){
// console.log(g.weight)
if
((
g
.
weight
!=
undefined
)
&&
(
g
.
weight
!=
"Nothing"
))
window
.
weighted
=
true
;
var
keys
=
(
g
.
foundation
.
slice
(
1
,
g
.
foundation
.
length
-
1
)).
split
(
'|'
)
var
labels
=
(
g
.
lbl
.
slice
(
1
,
g
.
lbl
.
length
-
1
)).
split
(
'|'
)
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
// freq
if
(
!
((
keys
[
i
]).
trim
()
in
window
.
freq
))
{
window
.
freq
[(
keys
[
i
]).
trim
()]
=
0
;
}
else
{
window
.
freq
[(
keys
[
i
]).
trim
()]
+=
1
;
}
// terms
if
(
!
((
keys
[
i
]).
trim
()
in
window
.
terms
))
{
window
.
terms
[(
keys
[
i
]).
trim
()]
=
{
label
:(
labels
[
i
]).
trim
(),
fdt
:(
keys
[
i
]).
trim
()}
}
}
var
from
=
yearToDate
(
g
.
from
),
to
=
yearToDate
(
g
.
to
),
weight
=
0
;
source
=
[];
if
(
g
.
strFrom
!=
undefined
)
{
if
(
window
.
timeScale
==
"epoch"
)
{
from
=
utcStringToDate
(
g
.
strFrom
)
}
else
{
from
=
stringToDate
(
g
.
strFrom
)
}
}
if
(
g
.
strTo
!=
undefined
)
{
if
(
window
.
timeScale
==
"epoch"
)
{
to
=
utcStringToDate
(
g
.
strTo
)
}
else
{
to
=
stringToDate
(
g
.
strTo
)
}
}
if
(
g
.
source
!=
undefined
)
source
=
intArrToArr
(
g
.
source
);
if
(
g
.
weight
!=
undefined
)
weight
=
parseFloat
((
g
.
weight
).
replace
(
"Just "
,
""
));
return
{
from
:
from
,
to
:
to
,
x
:
parseFloat
(((
g
.
pos
).
split
(
','
))[
0
])
,
y
:
parseFloat
(((
g
.
pos
).
split
(
','
))[
1
])
,
bId
:
parseInt
(
g
.
bId
)
,
gId
:
parseInt
(
g
.
_gvid
)
,
size
:
parseInt
(
g
.
support
),
source
:
source
,
weight
:
weight
,
label
:
labels
,
foundation
:
keys
,
role
:
((
g
.
role
.
slice
(
1
,
g
.
role
.
length
-
1
)).
split
(
'|'
)).
map
(
e
=>
parseInt
(
e
.
trim
()))}
});
var
links
=
json
.
edges
.
filter
(
edges
=>
edges
.
edgeType
==
"link"
).
map
(
function
(
l
){
var
links
=
json
.
edges
.
filter
(
edges
=>
edges
.
edgeType
==
"link"
).
map
(
function
(
l
){
return
{
lId
:
parseInt
(
l
.
_gvid
),
return
{
lId
:
parseInt
(
l
.
_gvid
),
...
...
src/Gargantext/Components/PhyloExplorer/Types.purs
View file @
471fbf05
module Gargantext.Components.PhyloExplorer.Types
module Gargantext.Components.PhyloExplorer.Types
( PhyloDataSet(..)
( PhyloDataSet(..)
, Branch, Period, Group
, Branch(..), Period(..), Group(..)
, GlobalTerm(..)
, parsePhyloJSONSet
, parsePhyloJSONSet
) where
) where
...
@@ -12,10 +13,11 @@ import Data.Generic.Rep (class Generic)
...
@@ -12,10 +13,11 @@ import Data.Generic.Rep (class Generic)
import Data.Int as Int
import Data.Int as Int
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
import Data.Number as Number
import Data.Number as Number
import Data.Show.Generic (genericShow)
import Data.String as String
import Data.String as String
import Data.Tuple as Tuple
import Data.Tuple as Tuple
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSONSet(..),
Phylo
Object(..))
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSONSet(..),
Raw
Object(..))
-- @WIP Date or foreign?
-- @WIP Date or foreign?
...
@@ -41,6 +43,8 @@ newtype PhyloDataSet = PhyloDataSet
...
@@ -41,6 +43,8 @@ newtype PhyloDataSet = PhyloDataSet
}
}
derive instance Generic PhyloDataSet _
derive instance Generic PhyloDataSet _
derive instance Eq PhyloDataSet
instance Show PhyloDataSet where show = genericShow
parsePhyloJSONSet :: PhyloJSONSet -> PhyloDataSet
parsePhyloJSONSet :: PhyloJSONSet -> PhyloDataSet
parsePhyloJSONSet (PhyloJSONSet o) = PhyloDataSet
parsePhyloJSONSet (PhyloJSONSet o) = PhyloDataSet
...
@@ -76,13 +80,17 @@ data Branch = Branch
...
@@ -76,13 +80,17 @@ data Branch = Branch
, y :: String
, y :: String
}
}
parseBranches :: Array PhyloObject -> Array Branch
derive instance Generic Branch _
derive instance Eq Branch
instance Show Branch where show = genericShow
parseBranches :: Array RawObject -> Array Branch
parseBranches
parseBranches
= map parse
= map parse
>>> Array.catMaybes
>>> Array.catMaybes
where
where
parse ::
Phylo
Object -> Maybe Branch
parse ::
Raw
Object -> Maybe Branch
parse (BranchToNode o) = Just $ Branch
parse (BranchToNode o) = Just $ Branch
{ bId : parseInt o.bId
{ bId : parseInt o.bId
, gvid : o._gvid
, gvid : o._gvid
...
@@ -101,13 +109,17 @@ data Period = Period
...
@@ -101,13 +109,17 @@ data Period = Period
, y :: Number
, y :: Number
}
}
parsePeriods :: Boolean -> Array PhyloObject -> Array Period
derive instance Generic Period _
derive instance Eq Period
instance Show Period where show = genericShow
parsePeriods :: Boolean -> Array RawObject -> Array Period
parsePeriods epoch
parsePeriods epoch
= map parse
= map parse
>>> Array.catMaybes
>>> Array.catMaybes
where
where
parse ::
Phylo
Object -> Maybe Period
parse ::
Raw
Object -> Maybe Period
parse (PeriodToNode o) = Just $ Period
parse (PeriodToNode o) = Just $ Period
{ from : parseNodeDate o.strFrom o.from epoch
{ from : parseNodeDate o.strFrom o.from epoch
, to : parseNodeDate o.strTo o.to epoch
, to : parseNodeDate o.strTo o.to epoch
...
@@ -132,31 +144,46 @@ data Group = Group
...
@@ -132,31 +144,46 @@ data Group = Group
, y :: Number
, y :: Number
}
}
parseGroups :: Boolean -> Array PhyloObject -> Array Group
derive instance Generic Group _
derive instance Eq Group
instance Show Group where show = genericShow
parseGroups :: Boolean -> Array RawObject -> Array Group
parseGroups epoch
parseGroups epoch
= map parse
= map parse
>>> Array.catMaybes
>>> Array.catMaybes
where
where
parse ::
Phylo
Object -> Maybe Group
parse ::
Raw
Object -> Maybe Group
parse (GroupToNode o) = Just $ Group
parse (GroupToNode o) = Just $ Group
{
from : parseNodeDate o.strFrom o.from epoch
{
bId : parseInt o.bId
,
to : parseNodeDate o.strTo o.to epoch
,
foundation : stringedArrayToArray' o.foundation
,
x : Tuple.fst $ parsePos o.pos
,
from : parseNodeDate o.strFrom o.from epoch
,
y : Tuple.snd $ parsePos o.pos
,
gId : o._gvid
,
bId : parseInt o.bId
,
label : stringedArrayToArray o.lbl
,
gId : o._gvid
,
role : stringedArrayToArray' o.role
, size : parseInt o.support
, size
: parseInt o.support
, source: parseSources o.source
, source
: parseSources o.source
,
weight: stringedMaybeToNumber o.weight
,
to : parseNodeDate o.strTo o.to epoch
,
label : stringedArrayToArray o.lbl
,
weight : stringedMaybeToNumber o.weight
,
role : stringedArrayToArray' o.role
,
x : Tuple.fst $ parsePos o.pos
,
foundation: stringedArrayToArray' o.foundation
,
y : Tuple.snd $ parsePos o.pos
}
}
parse _ = Nothing
parse _ = Nothing
-----------------------------------------------------------
-----------------------------------------------------------
data GlobalTerm = GlobalTerm
{ label :: String
, fdt :: String
}
derive instance Generic GlobalTerm _
derive instance Eq GlobalTerm
instance Show GlobalTerm where show = genericShow
-----------------------------------------------------------
parseInt :: String -> Int
parseInt :: String -> Int
parseInt s = maybe 0 identity $ Int.fromString s
parseInt s = maybe 0 identity $ Int.fromString s
...
...
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