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
01a30b1e
Commit
01a30b1e
authored
Jul 12, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NgramsTab] fix norm according type of Ngrams.
parent
8e724e56
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
34 deletions
+47
-34
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+3
-2
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+11
-11
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+17
-13
Config.purs
src/Gargantext/Config.purs
+2
-2
Specs.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
+10
-2
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+3
-3
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+1
-1
No files found.
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
01a30b1e
...
...
@@ -26,6 +26,7 @@ import Reactix as R
import Reactix.DOM.HTML as HTML
import Reactix.SyntheticEvent as E
import Gargantext.Config (CTabNgramType(..))
import Gargantext.Types ( TermList )
import Gargantext.Components.Annotation.Utils ( termBootstrapClass )
import Gargantext.Components.NgramsTable.Core ( NgramsTerm, NgramsTable(..), _NgramsElement, _list, highlightNgrams, findNgramTermList )
...
...
@@ -80,7 +81,7 @@ maybeShowMenu setMenu setTermList ngrams event = do
sel' -> do
let x = E.clientX event
y = E.clientY event
list = findNgramTermList ngrams sel'
list = findNgramTermList
CTabTerms
ngrams sel'
setList t = do
setTermList sel' list t
setMenu (const Nothing)
...
...
@@ -97,7 +98,7 @@ maybeAddMenu setMenu e (Just props) = annotationMenu setMenu props <> e
maybeAddMenu _ e _ = e
compile :: NgramsTable -> Maybe String -> Array (Tuple String (Maybe TermList))
compile ngrams = maybe [] (highlightNgrams ngrams)
compile ngrams = maybe [] (highlightNgrams
CTabTerms
ngrams)
-- Runs
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
01a30b1e
...
...
@@ -34,7 +34,7 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (TermList(..), readTermList, readTermSize, termLists, termSizes)
import Gargantext.Config (OrderBy(..), TabType)
import Gargantext.Config (OrderBy(..), TabType
, CTabNgramType(..)
)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Table as T
import Gargantext.Prelude
...
...
@@ -197,8 +197,8 @@ toggleMap :: forall a. a -> Maybe a -> Maybe a
toggleMap _ (Just _) = Nothing
toggleMap b Nothing = Just b
ngramsTableSpec :: Spec State LoadedNgramsTableProps Action
ngramsTableSpec = simpleSpec performAction render
ngramsTableSpec ::
CTabNgramType ->
Spec State LoadedNgramsTableProps Action
ngramsTableSpec
ntype
= simpleSpec performAction render
where
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
...
...
@@ -214,7 +214,7 @@ ngramsTableSpec = simpleSpec performAction render
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: pt})
where
pe = NgramsPatch { patch_list: pl, patch_children: mempty }
pt = singletonNgramsTablePatch n pe
pt = singletonNgramsTablePatch n
type n
pe
performAction AddTermChildren _ {ngramsParent: Nothing} =
-- impossible but harmless
pure unit
...
...
@@ -228,11 +228,11 @@ ngramsTableSpec = simpleSpec performAction render
where
pc = patchSetFromMap ngramsChildren
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
pt = singletonNgramsTablePatch parent pe
pt = singletonNgramsTablePatch
ntype
parent pe
performAction (AddNewNgram ngram) {path: {listIds, nodeId, tabType}} {ngramsVersion} =
commitPatch {listIds, nodeId, tabType} (Versioned {version: ngramsVersion, data: pt})
where
pt = addNewNgram ngram CandidateTerm
pt = addNewNgram n
type n
gram CandidateTerm
render :: Render State LoadedNgramsTableProps Action
render dispatch { path: pageParams
...
...
@@ -292,8 +292,8 @@ ngramsTableSpec = simpleSpec performAction render
, delete: false
}
ngramsTableClass :: Loader.InnerClass PageParams VersionedNgramsTable
ngramsTableClass
= createClass "NgramsTable" ngramsTableSpec
initialState
ngramsTableClass ::
CTabNgramType ->
Loader.InnerClass PageParams VersionedNgramsTable
ngramsTableClass
ct = createClass "NgramsTable" (ngramsTableSpec ct)
initialState
type MainNgramsTableProps =
{ nodeId :: Int
...
...
@@ -302,14 +302,14 @@ type MainNgramsTableProps =
, tabType :: TabType
}
mainNgramsTableSpec :: Spec {} MainNgramsTableProps Void
mainNgramsTableSpec = simpleSpec defaultPerformAction render
mainNgramsTableSpec ::
CTabNgramType ->
Spec {} MainNgramsTableProps Void
mainNgramsTableSpec
nt
= simpleSpec defaultPerformAction render
where
render :: Render {} MainNgramsTableProps Void
render _ {nodeId, defaultListId, tabType} _ _ =
[ ngramsLoader
{ path: initialPageParams nodeId [defaultListId] tabType
, component:
ngramsTableClass
, component:
(ngramsTableClass nt)
} ]
type NgramsDepth = {ngrams :: NgramsTerm, depth :: Int}
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
01a30b1e
...
...
@@ -86,7 +86,7 @@ import Partial.Unsafe (unsafePartial)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Types (TermList(..), TermSize)
import Gargantext.Config (toUrl, End(..), Path(..), TabType, OrderBy(..))
import Gargantext.Config (toUrl, End(..), Path(..), TabType, OrderBy(..)
, CTabNgramType(..)
)
import Gargantext.Config.REST (get, put, post)
import Gargantext.Components.Table as T
import Gargantext.Prelude
...
...
@@ -224,8 +224,8 @@ wordBoundaryReg2 = case R.regex ("(" <> wordBoundaryChars <> ")\\1") (R.global <
-- TODO: while this function works well with word boundaries,
-- it inserts too many spaces.
highlightNgrams :: NgramsTable -> String -> Array (Tuple String (Maybe TermList))
highlightNgrams (NgramsTable table) input0 =
highlightNgrams ::
CTabNgramType ->
NgramsTable -> String -> Array (Tuple String (Maybe TermList))
highlightNgrams
ntype
(NgramsTable table) input0 =
-- trace {pats, input0, input, ixs} \_ ->
let sN = unsafePartial (foldl goFold {i0: 0, s: input, l: Nil} ixs) in
A.reverse (A.fromFoldable (consNonEmpty (undb (init sN.s)) sN.l))
...
...
@@ -238,7 +238,7 @@ highlightNgrams (NgramsTable table) input0 =
init x = S.take (S.length x - 1) x
input = spR input0
pats = A.fromFoldable (Map.keys table)
ixs = indicesOfAny (sp <$> pats) (normNgram input)
ixs = indicesOfAny (sp <$> pats) (normNgram
ntype
input)
consOnJustTail s xs@(Tuple _ (Just _) : _) =
Tuple s Nothing : xs
...
...
@@ -486,14 +486,18 @@ type NgramsTablePatch =
fromNgramsPatches :: NgramsPatches -> NgramsTablePatch
fromNgramsPatches ngramsPatches = {ngramsNewElems: mempty, ngramsPatches}
normNgram :: String -> NgramsTerm
normNgram = S.toLower <<< R.replace wordBoundaryReg " "
normNgram :: CTabNgramType -> String -> NgramsTerm
normNgram CTabAuthors = identity
normNgram CTabSources = identity
normNgram CTabInstitutes = identity
normNgram CTabTerms = S.toLower <<< R.replace wordBoundaryReg " "
findNgramTermList :: NgramsTable -> String -> Maybe TermList
findNgramTermList (NgramsTable m) s = m ^? at (normNgram s) <<< _Just <<< _NgramsElement <<< _list
singletonNgramsTablePatch :: NgramsTerm -> NgramsPatch -> NgramsTablePatch
singletonNgramsTablePatch n p = fromNgramsPatches $ singletonPatchMap (normNgram n) p
findNgramTermList :: CTabNgramType -> NgramsTable -> String -> Maybe TermList
findNgramTermList ntype (NgramsTable m) s = m ^? at (normNgram ntype s) <<< _Just <<< _NgramsElement <<< _list
singletonNgramsTablePatch :: CTabNgramType -> NgramsTerm -> NgramsPatch -> NgramsTablePatch
singletonNgramsTablePatch m n p = fromNgramsPatches $ singletonPatchMap (normNgram m n) p
type RootParent = { root :: NgramsTerm, parent :: NgramsTerm }
...
...
@@ -566,9 +570,9 @@ postNewElems newElems params = void $ traverseWithIndex postNewElem newElems
where
postNewElem ngrams list = postNewNgrams [ngrams] (Just list) params
addNewNgram :: NgramsTerm -> TermList -> NgramsTablePatch
addNewNgram ngrams list = { ngramsPatches: mempty
, ngramsNewElems: Map.singleton (normNgram ngrams) list }
addNewNgram ::
CTabNgramType ->
NgramsTerm -> TermList -> NgramsTablePatch
addNewNgram n
type n
grams list = { ngramsPatches: mempty
, ngramsNewElems: Map.singleton (normNgram n
type n
grams) list }
putNgramsPatches :: {nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
putNgramsPatches {nodeId, listIds, tabType} =
...
...
src/Gargantext/Config.purs
View file @
01a30b1e
...
...
@@ -28,8 +28,8 @@ endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative
--
, back : backLocal v
, back: backDev v
, back : backLocal v
--
, back: backDev v
, static : staticRelative
}
-- , back : backDemo v }
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
View file @
01a30b1e
...
...
@@ -9,7 +9,7 @@ import Data.List (fromFoldable)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..), PTabNgramType(..))
import Gargantext.Config (TabType(..), TabSubType(..), PTabNgramType(..)
, CTabNgramType(..)
)
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Tab as Tab
...
...
@@ -32,6 +32,14 @@ modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
-- TODO fix this type
modeTabType' :: Mode -> CTabNgramType
modeTabType' Patents = CTabAuthors
modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors
type PropsRow =
( nodeId :: Int
, contactData :: ContactData
...
...
@@ -72,6 +80,6 @@ ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
cmapProps (\{contactData: {defaultListId}, nodeId} ->
{defaultListId, nodeId, tabType})
(noState
NT.mainNgramsTableSpec
)
(noState
(NT.mainNgramsTableSpec (modeTabType' mode))
)
where
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Corpus/Document.purs
View file @
01a30b1e
...
...
@@ -12,7 +12,7 @@ import Reactix as R
import Thermite (PerformAction, Render, Spec, simpleSpec, cmapProps, createClass)
import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..), TabSubType(..), TabType(..), CTabNgramType(..))
import Gargantext.Config (toUrl, NodeType(..), End(..), TabSubType(..), TabType(..), CTabNgramType(..)
, CTabNgramType(..)
)
import Gargantext.Config.REST (get)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Loader2 (useLoader)
...
...
@@ -284,11 +284,11 @@ docViewSpec = simpleSpec performAction render
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: pt})
where
pe = NgramsPatch { patch_list: pl, patch_children: mempty }
pt = singletonNgramsTablePatch n pe
pt = singletonNgramsTablePatch
CTabTerms
n pe
performAction (AddNewNgram ngram termList) {path: {nodeId, listIds, tabType}} {ngramsVersion} =
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: pt})
where
pt = addNewNgram ngram termList
pt = addNewNgram
CTabTerms
ngram termList
render :: Render State Props Action
render dispatch { loaded: { ngramsTable: Versioned { data: initTable }, document } }
...
...
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
01a30b1e
...
...
@@ -91,7 +91,7 @@ ngramsViewSpec {mode} =
noState $ chart mode <>
cmapProps (\{corpusData: {defaultListId}, corpusId: nodeId} ->
{defaultListId, nodeId, tabType})
NT.mainNgramsTableSpec
(NT.mainNgramsTableSpec (modeTabType mode))
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
...
...
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