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
16138dfa
Commit
16138dfa
authored
Jul 10, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nGrams] normalization for the selected text
parent
040119a1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+5
-3
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+12
-10
Config.purs
src/Gargantext/Config.purs
+2
-1
No files found.
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
16138dfa
...
@@ -15,6 +15,7 @@ import Prelude
...
@@ -15,6 +15,7 @@ import Prelude
import Data.Lens ((^?), _Just)
import Data.Lens ((^?), _Just)
import Data.Lens.At (at)
import Data.Lens.At (at)
import Data.Maybe ( Maybe(..), maybe, maybe' )
import Data.Maybe ( Maybe(..), maybe, maybe' )
import Data.String.Regex as R
import Data.String as S
import Data.String as S
import Data.Tuple ( Tuple(..) )
import Data.Tuple ( Tuple(..) )
import Data.Tuple.Nested ( (/\) )
import Data.Tuple.Nested ( (/\) )
...
@@ -27,7 +28,7 @@ import Reactix.SyntheticEvent as E
...
@@ -27,7 +28,7 @@ import Reactix.SyntheticEvent as E
import Gargantext.Types ( TermList )
import Gargantext.Types ( TermList )
import Gargantext.Components.Annotation.Utils ( termBootstrapClass )
import Gargantext.Components.Annotation.Utils ( termBootstrapClass )
import Gargantext.Components.NgramsTable.Core ( NgramsTerm, NgramsTable(..), _NgramsElement, _list, highlightNgrams )
import Gargantext.Components.NgramsTable.Core ( NgramsTerm, NgramsTable(..), _NgramsElement, _list, highlightNgrams
, nGramsRegex
)
import Gargantext.Components.Annotation.Menu ( AnnotationMenu, annotationMenu, MenuType(..) )
import Gargantext.Components.Annotation.Menu ( AnnotationMenu, annotationMenu, MenuType(..) )
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Selection as Sel
...
@@ -79,9 +80,10 @@ maybeShowMenu setMenu setTermList ngrams event = do
...
@@ -79,9 +80,10 @@ maybeShowMenu setMenu setTermList ngrams event = do
sel' -> do
sel' -> do
let x = E.clientX event
let x = E.clientX event
y = E.clientY event
y = E.clientY event
list = findNgram ngrams sel'
sel'' = S.trim $ R.replace nGramsRegex " " sel'
list = findNgram ngrams sel''
setList t = do
setList t = do
setTermList sel' list t
setTermList sel'
'
list t
setMenu (const Nothing)
setMenu (const Nothing)
E.preventDefault event
E.preventDefault event
setMenu (const $ Just { x, y, list, menuType: NewNgram, setList })
setMenu (const $ Just { x, y, list, menuType: NewNgram, setList })
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
16138dfa
...
@@ -16,6 +16,7 @@ module Gargantext.Components.NgramsTable.Core
...
@@ -16,6 +16,7 @@ module Gargantext.Components.NgramsTable.Core
, VersionedNgramsTable
, VersionedNgramsTable
, CoreState
, CoreState
, LoadedNgramsTableProps
, LoadedNgramsTableProps
, nGramsRegex
, highlightNgrams
, highlightNgrams
, initialPageParams
, initialPageParams
, loadNgramsTable
, loadNgramsTable
...
@@ -210,6 +211,14 @@ instance decodeJsonNgramsTable :: DecodeJson NgramsTable where
...
@@ -210,6 +211,14 @@ instance decodeJsonNgramsTable :: DecodeJson NgramsTable where
f e@(NgramsElement e') = Tuple e'.ngrams e
f e@(NgramsElement e') = Tuple e'.ngrams e
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
nGramWordBoundaries = "[ .,;:!?'\\{}()]"
nGramsRegex = case R.regex ("(" <> nGramWordBoundaries <> ")") (R.global <> R.multiline) of
Left e -> unsafePartial $ crashWith e
Right r -> r
nGramsRegex2 = case R.regex ("(" <> nGramWordBoundaries <> ")\\1") (R.global <> R.multiline) of
Left e -> unsafePartial $ crashWith e
Right r -> r
-- TODO: while this function works well with word boundaries,
-- TODO: while this function works well with word boundaries,
-- it inserts too many spaces.
-- it inserts too many spaces.
highlightNgrams :: NgramsTable -> String -> Array (Tuple String (Maybe TermList))
highlightNgrams :: NgramsTable -> String -> Array (Tuple String (Maybe TermList))
...
@@ -218,21 +227,14 @@ highlightNgrams (NgramsTable table) input0 =
...
@@ -218,21 +227,14 @@ highlightNgrams (NgramsTable table) input0 =
let sN = unsafePartial (foldl goFold {i0: 0, s: input, l: Nil} ixs) in
let sN = unsafePartial (foldl goFold {i0: 0, s: input, l: Nil} ixs) in
A.reverse (A.fromFoldable (consNonEmpty (undb (init sN.s)) sN.l))
A.reverse (A.fromFoldable (consNonEmpty (undb (init sN.s)) sN.l))
where
where
spR x = " " <> R.replace
the
Regex "$1$1" x <> " "
spR x = " " <> R.replace
nGrams
Regex "$1$1" x <> " "
reR = R.replace
the
Regex " "
reR = R.replace
nGrams
Regex " "
db = S.replace (S.Pattern " ") (S.Replacement " ")
db = S.replace (S.Pattern " ") (S.Replacement " ")
sp x = " " <> db x <> " "
sp x = " " <> db x <> " "
undb = R.replace
the
Regex2 "$1"
undb = R.replace
nGrams
Regex2 "$1"
init x = S.take (S.length x - 1) x
init x = S.take (S.length x - 1) x
input = spR input0
input = spR input0
pats = A.fromFoldable (Map.keys table)
pats = A.fromFoldable (Map.keys table)
word_boundaries = "[ .,;:!?'\\{}()]"
theRegex = case R.regex ("(" <> word_boundaries <> ")") (R.global <> R.multiline) of
Left e -> unsafePartial $ crashWith e
Right r -> r
theRegex2 = case R.regex ("(" <> word_boundaries <> ")\\1") (R.global <> R.multiline) of
Left e -> unsafePartial $ crashWith e
Right r -> r
ixs = indicesOfAny (sp <$> pats) (S.toLower $ reR input)
ixs = indicesOfAny (sp <$> pats) (S.toLower $ reR input)
consOnJustTail s xs@(Tuple _ (Just _) : _) =
consOnJustTail s xs@(Tuple _ (Just _) : _) =
...
...
src/Gargantext/Config.purs
View file @
16138dfa
...
@@ -28,7 +28,8 @@ endConfig = endConfig' V10
...
@@ -28,7 +28,8 @@ endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig
endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative
endConfig' v = { front : frontRelative
, back : backLocal v
--, back : backLocal v
, back: backDev v
, static : staticRelative
, static : staticRelative
}
}
-- , back : backDemo v }
-- , back : backDemo v }
...
...
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