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
45d78285
Unverified
Commit
45d78285
authored
Mar 05, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-REPO] correctly reroot recursively
parent
99bfb3cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+17
-4
No files found.
src/Gargantext/API/Ngrams.hs
View file @
45d78285
...
...
@@ -44,6 +44,7 @@ import Data.Patch.Class (Replace, replace, Action(act), Applicable(..),
ConflictResolutionReplace
,
ours
)
import
qualified
Data.Map.Strict.Patch
as
PM
import
Data.Monoid
import
Data.Foldable
--import Data.Semigroup
import
Data.Set
(
Set
)
-- import qualified Data.List as List
...
...
@@ -54,7 +55,7 @@ import Data.Map.Strict (Map)
import
qualified
Data.Set
as
Set
import
Control.Category
((
>>>
))
import
Control.Concurrent
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Prism
'
,
prism'
,
Iso
'
,
iso
,
from
,
(
.~
),
(
#
),
to
,
{-withIndex, folded, ifolded,-}
view
,
use
,
(
^.
),
(
+~
),
(
%~
),
(
%=
),
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
mapped
)
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Prism
'
,
prism'
,
Iso
'
,
iso
,
from
,
(
.~
),
(
.=
),
(
#
),
to
,
folded
,
{-withIndex, ifolded,-}
view
,
use
,
(
^.
),
(
^?
),
(
+~
),
(
%~
),
(
%=
),
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
mapped
,
forOf_
)
import
Control.Monad
(
guard
)
import
Control.Monad.Error.Class
(
MonadError
,
throwError
)
import
Control.Monad.Reader
...
...
@@ -131,6 +132,9 @@ mSetFromSet = MSet . Map.fromSet (const ())
mSetFromList
::
Ord
a
=>
[
a
]
->
MSet
a
mSetFromList
=
MSet
.
Map
.
fromList
.
map
(
\
x
->
(
x
,
()
))
instance
Foldable
MSet
where
foldMap
f
(
MSet
m
)
=
Map
.
foldMapWithKey
(
\
k
_
->
f
k
)
m
instance
(
Ord
a
,
FromJSON
a
)
=>
FromJSON
(
MSet
a
)
where
parseJSON
=
fmap
mSetFromList
.
parseJSON
...
...
@@ -525,10 +529,19 @@ instance Arbitrary NgramsTablePatch where
type
ReParent
a
=
forall
m
.
MonadState
NgramsTableMap
m
=>
a
->
m
()
reRootChildren
::
Maybe
NgramsTerm
->
ReParent
NgramsTerm
reRootChildren
root
ngram
=
do
nre
<-
use
$
at
ngram
forOf_
(
_Just
.
nre_children
.
folded
)
nre
$
\
child
->
do
at
child
.
_Just
.
nre_root
.=
root
reRootChildren
root
child
reParent
::
Maybe
RootParent
->
ReParent
NgramsTerm
reParent
rp
child
=
at
child
.
_Just
%=
(
(
nre_parent
.~
(
_rp_parent
<$>
rp
))
.
(
nre_root
.~
(
_rp_root
<$>
rp
))
)
reParent
rp
child
=
do
at
child
.
_Just
%=
(
(
nre_parent
.~
(
_rp_parent
<$>
rp
))
.
(
nre_root
.~
(
_rp_root
<$>
rp
))
)
reRootChildren
(
rp
^?
_Just
.
rp_root
)
child
reParentAddRem
::
RootParent
->
NgramsTerm
->
ReParent
AddRem
reParentAddRem
rp
child
p
=
...
...
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