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
794ed1e1
Unverified
Commit
794ed1e1
authored
May 07, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an highlighting bug when pattern overlap
parent
e5ab7574
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
13 deletions
+41
-13
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+4
-1
Spec.purs
test/Gargantext/Components/NgramsTable/Spec.purs
+37
-12
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
794ed1e1
...
@@ -208,7 +208,10 @@ highlightNgrams (NgramsTable table) input =
...
@@ -208,7 +208,10 @@ highlightNgrams (NgramsTable table) input =
-- NOTE that only the first matching pattern is used, the others are ignored!
-- NOTE that only the first matching pattern is used, the others are ignored!
goFold :: Partial => _ -> Tuple Int (Array Int) -> _
goFold :: Partial => _ -> Tuple Int (Array Int) -> _
goFold { i0, s, l } (Tuple i pis) =
goFold { i0, s, l } (Tuple i pis)
| i < i0 =
{ i0, s, l }
| otherwise =
case A.index pis 0 of
case A.index pis 0 of
Nothing ->
Nothing ->
{ i0, s, l }
{ i0, s, l }
...
...
test/Gargantext/Components/NgramsTable/Spec.purs
View file @
794ed1e1
...
@@ -12,9 +12,7 @@ import Data.Map as Map
...
@@ -12,9 +12,7 @@ import Data.Map as Map
import Data.Set as Set
import Data.Set as Set
spec :: Spec Unit
spec :: Spec Unit
spec =
spec = do
describe "NgramsTable.highlightNgrams" do
it "partially works" do
let ne ngrams list =
let ne ngrams list =
NgramsElement
NgramsElement
{ ngrams
{ ngrams
...
@@ -25,7 +23,9 @@ spec =
...
@@ -25,7 +23,9 @@ spec =
, children: Set.empty
, children: Set.empty
}
}
tne ngrams list = Tuple ngrams (ne ngrams list)
tne ngrams list = Tuple ngrams (ne ngrams list)
table = NgramsTable
describe "NgramsTable.highlightNgrams" do
it "partially works" do
let table = NgramsTable
(Map.fromFoldable [tne "graph" GraphTerm
(Map.fromFoldable [tne "graph" GraphTerm
,tne "stop" StopTerm
,tne "stop" StopTerm
,tne "candidate" CandidateTerm
,tne "candidate" CandidateTerm
...
@@ -38,3 +38,28 @@ spec =
...
@@ -38,3 +38,28 @@ spec =
,Tuple "s at every " Nothing
,Tuple "s at every " Nothing
,Tuple "candidate" (Just CandidateTerm)]
,Tuple "candidate" (Just CandidateTerm)]
highlightNgrams table input `shouldEqual` output
highlightNgrams table input `shouldEqual` output
it "works when pattern overlaps" do
let table = NgramsTable
(Map.fromFoldable [tne "is" StopTerm
,tne "a" StopTerm
,tne "of" StopTerm
,tne "new" GraphTerm
,tne "the" GraphTerm
,tne "state" GraphTerm
])
input = "SCIPION is a new state of the"
output = [Tuple "SCIPION " Nothing
,Tuple "is" (Just StopTerm)
,Tuple " " Nothing
,Tuple "a" (Just StopTerm)
,Tuple " " Nothing
,Tuple "new" (Just GraphTerm)
,Tuple " " Nothing
,Tuple "state" (Just GraphTerm)
,Tuple " " Nothing
,Tuple "of" (Just StopTerm)
,Tuple " " Nothing
,Tuple "the" (Just GraphTerm)
]
highlightNgrams table input `shouldEqual` output
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