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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
purescript-gargantext
Commits
90f07e87
Unverified
Commit
90f07e87
authored
Nov 12, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS] some functions to apply patches
parent
5aff0b2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+19
-0
No files found.
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
90f07e87
...
@@ -4,6 +4,7 @@ module Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable where
...
@@ -4,6 +4,7 @@ module Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable where
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Array (filter, toUnfoldable)
import Data.Array (filter, toUnfoldable)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.FunctorWithIndex
import Data.Newtype (class Newtype, unwrap)
import Data.Newtype (class Newtype, unwrap)
import Data.Lens (Lens', Prism', lens, over, prism)
import Data.Lens (Lens', Prism', lens, over, prism)
import Data.Lens.Iso (re)
import Data.Lens.Iso (re)
...
@@ -73,6 +74,10 @@ instance semigroupReplace :: Semigroup (Replace a) where
...
@@ -73,6 +74,10 @@ instance semigroupReplace :: Semigroup (Replace a) where
instance semigroupMonoid :: Monoid (Replace a) where
instance semigroupMonoid :: Monoid (Replace a) where
mempty = Keep
mempty = Keep
applyReplace :: forall a. Eq a => Replace a -> a -> a
applyReplace Keep a = a
applyReplace (Replace { old, new }) a = new -- assert (a == old)
newtype PatchSet a = PatchSet
newtype PatchSet a = PatchSet
{ rem :: Set a
{ rem :: Set a
, add :: Set a
, add :: Set a
...
@@ -87,6 +92,9 @@ instance semigroupPatchSet :: Ord a => Semigroup (PatchSet a) where
...
@@ -87,6 +92,9 @@ instance semigroupPatchSet :: Ord a => Semigroup (PatchSet a) where
instance monoidPatchSet :: Ord a => Monoid (PatchSet a) where
instance monoidPatchSet :: Ord a => Monoid (PatchSet a) where
mempty = PatchSet { rem: Set.empty, add: Set.empty }
mempty = PatchSet { rem: Set.empty, add: Set.empty }
applyPatchSet :: forall a. Ord a => PatchSet a -> Set a -> Set a
applyPatchSet (PatchSet p) s = Set.difference s p.rem <> p.add
newtype NgramsPatch = NgramsPatch
newtype NgramsPatch = NgramsPatch
{ patch_children :: PatchSet NgramsTerm
{ patch_children :: PatchSet NgramsTerm
, patch_list :: Replace TermList
, patch_list :: Replace TermList
...
@@ -109,8 +117,19 @@ instance semigroupPatchMap :: (Ord k, Semigroup p) => Semigroup (PatchMap k p) w
...
@@ -109,8 +117,19 @@ instance semigroupPatchMap :: (Ord k, Semigroup p) => Semigroup (PatchMap k p) w
instance monoidPatchMap :: (Ord k, Semigroup p) => Monoid (PatchMap k p) where
instance monoidPatchMap :: (Ord k, Semigroup p) => Monoid (PatchMap k p) where
mempty = PatchMap Map.empty
mempty = PatchMap Map.empty
applyPatchMap :: forall k p v. Ord k => (p -> v -> v) -> PatchMap k p -> Map k v -> Map k v
applyPatchMap applyPatchValue (PatchMap p) = mapWithIndex f
where
f k v =
case Map.lookup k p of
Nothing -> v
Just pv -> applyPatchValue pv v
type NgramsTablePatch = PatchMap NgramsTerm NgramsPatch
type NgramsTablePatch = PatchMap NgramsTerm NgramsPatch
applyNgramsTablePatch :: NgramsTablePatch -> NgramsTable -> NgramsTable
applyNgramsTablePatch p t = t -- TODO
type State =
type State =
{ ngramsTablePatch :: NgramsTablePatch
{ ngramsTablePatch :: NgramsTablePatch
, searchQuery :: String
, searchQuery :: String
...
...
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