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
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
cab26234
Unverified
Commit
cab26234
authored
Nov 12, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS] Patch types
parent
1190af30
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
23 deletions
+40
-23
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+40
-23
No files found.
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
cab26234
...
@@ -9,7 +9,11 @@ import Data.Lens (Lens', Prism', lens, over, prism)
...
@@ -9,7 +9,11 @@ import Data.Lens (Lens', Prism', lens, over, prism)
import Data.Lens.Iso (re)
import Data.Lens.Iso (re)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.List (List)
import Data.List (List)
import Data.Map (Map)
import Data.Map as Map
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
import Data.Set (Set)
import Data.Set as Set
import Data.Tuple (Tuple(..), uncurry)
import Data.Tuple (Tuple(..), uncurry)
import Data.Void (Void)
import Data.Void (Void)
import Data.Unit (Unit)
import Data.Unit (Unit)
...
@@ -37,17 +41,44 @@ type Props' = { path :: Int
...
@@ -37,17 +41,44 @@ type Props' = { path :: Int
, loaded :: Maybe NgramsTable
, loaded :: Maybe NgramsTable
}
}
type NgramsTerm = String
newtype NgramsElement = NgramsElement
{ ngrams :: NgramsTerm
, list :: TermList
, occurrences :: Int
}
instance decodeJsonNgramsElement :: DecodeJson NgramsElement where
decodeJson json = do
obj <- decodeJson json
ngrams <- obj .? "ngrams"
list <- obj .? "list"
occurrences <- obj .? "occurrences"
pure $ NgramsElement {ngrams, list, occurrences}
type NgramsTable = Array (NTree NgramsElement)
type NgramsTable = Array (NTree NgramsElement)
data Replace a
= Keep
| Replace { old :: a, new :: a }
type NgramsPatch = { rem_children :: Set NgramsTerm
, add_children :: Set NgramsTerm
, patch_list :: Replace TermList
}
type NgramsTablePatch = Map NgramsTerm NgramsPatch
type State =
type State =
{ ngramsTable
:: NgramsTable
{ ngramsTable
Patch :: NgramsTablePatch
, searchQuery :: String
, searchQuery :: String
, termListFilter :: Maybe TermList -- Nothing means all
, termListFilter :: Maybe TermList -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all
}
}
initialState :: State
initialState :: State
initialState = { ngramsTable
: []
initialState = { ngramsTable
Patch: Map.empty
, searchQuery: ""
, searchQuery: ""
, termListFilter: Nothing
, termListFilter: Nothing
, termTypeFilter: Nothing
, termTypeFilter: Nothing
...
@@ -135,7 +166,7 @@ ngramsTableSpec' = simpleSpec performAction render
...
@@ -135,7 +166,7 @@ ngramsTableSpec' = simpleSpec performAction render
performAction (SetTermListItem _i _l) _ _ = pure unit -- TODO
performAction (SetTermListItem _i _l) _ _ = pure unit -- TODO
render :: Render State Props' Action
render :: Render State Props' Action
render dispatch {path: nodeId, loaded} {searchQuery {- TODO more state -} } _ =
render dispatch {path: nodeId, loaded
: initTable
} {searchQuery {- TODO more state -} } _ =
[ T.tableElt
[ T.tableElt
{ loadRows
{ loadRows
, container: tableContainer {searchQuery, dispatch}
, container: tableContainer {searchQuery, dispatch}
...
@@ -172,20 +203,6 @@ ngramsTableSpec' = simpleSpec performAction render
...
@@ -172,20 +203,6 @@ ngramsTableSpec' = simpleSpec performAction render
fa false = "far "
fa false = "far "
-}
-}
newtype NgramsElement = NgramsElement
{ ngrams :: String
, list :: TermList
, occurrences :: Int
}
instance decodeJsonNgramsElement :: DecodeJson NgramsElement where
decodeJson json = do
obj <- decodeJson json
ngrams <- obj .? "ngrams"
list <- obj .? "list"
occurrences <- obj .? "occurrences"
pure $ NgramsElement {ngrams, list, occurrences}
getNgramsTable :: Int -> Aff NgramsTable
getNgramsTable :: Int -> Aff NgramsTable
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
...
...
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