Commit 76adf7a6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski Committed by Alexandre Delanoë

[ngrams] small refactoring

parent 91224ece
...@@ -491,16 +491,16 @@ tree p = R.createElement treeCpt p [] ...@@ -491,16 +491,16 @@ tree p = R.createElement treeCpt p []
treeCpt :: R.Component TreeProps treeCpt :: R.Component TreeProps
treeCpt = R.hooksComponent "G.C.NT.tree" cpt treeCpt = R.hooksComponent "G.C.NT.tree" cpt
where where
cpt params@{ngramsTable, ngramsStyle, ngramsEdit, ngramsClick, ngramsDepth: nd} _ = cpt params@{ ngramsClick, ngramsDepth, ngramsEdit, ngramsStyle, ngramsTable } _ =
pure $ pure $
H.li { style: {width : "100%"} } H.li { style: {width : "100%"} }
([ H.i { className, style } [] ] ([ H.i { className, style } [] ]
<> [ R2.buff $ tag [ text $ " " <> ngramsTermText nd.ngrams ] ] <> [ R2.buff $ tag [ text $ " " <> ngramsTermText ngramsDepth.ngrams ] ]
<> maybe [] edit (ngramsEdit nd) <> maybe [] edit (ngramsEdit ngramsDepth)
<> [ forest cs ]) <> [ forest cs ])
where where
tag = tag =
case ngramsClick nd of case ngramsClick ngramsDepth of
Just effect -> Just effect ->
a (ngramsStyle <> [onClick $ const effect]) a (ngramsStyle <> [onClick $ const effect])
Nothing -> Nothing ->
...@@ -513,10 +513,10 @@ treeCpt = R.hooksComponent "G.C.NT.tree" cpt ...@@ -513,10 +513,10 @@ treeCpt = R.hooksComponent "G.C.NT.tree" cpt
className = "glyphicon glyphicon-chevron-" <> if open then "down" else "right" className = "glyphicon glyphicon-chevron-" <> if open then "down" else "right"
style = if leaf then {color: "#adb5bd"} else {color: ""} style = if leaf then {color: "#adb5bd"} else {color: ""}
open = not leaf || false {- TODO -} open = not leaf || false {- TODO -}
cs = ngramsTable ^.. ix nd.ngrams <<< _NgramsElement <<< _children <<< folded cs = ngramsTable ^.. ix ngramsDepth.ngrams <<< _NgramsElement <<< _children <<< folded
forest = forest =
let depth = nd.depth + 1 in let depth = ngramsDepth.depth + 1 in
H.ul {} <<< map (\ngrams -> tree (params { ngramsDepth = {depth, ngrams} })) <<< List.toUnfoldable H.ul {} <<< map (\ngrams -> tree (params { ngramsDepth = {depth, ngrams} })) <<< List.toUnfoldable
sumOccurrences' :: NgramsTable -> NgramsTerm -> Additive Int sumOccurrences' :: NgramsTable -> NgramsTerm -> Additive Int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment