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
b148b947
Unverified
Commit
b148b947
authored
Apr 08, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[KarpRabin] minor changes
parent
965fbb30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
KarpRabin.purs
src/Gargantext/Utils/KarpRabin.purs
+11
-10
No files found.
src/Gargantext/Utils/KarpRabin.purs
View file @
b148b947
...
...
@@ -35,6 +35,7 @@ import Data.String as S
import Data.String (CodePoint)
import Data.Tuple (Tuple(..))
import Data.UInt (UInt, shl, fromInt)
import Partial.Unsafe (unsafePartial)
import Prelude
...
...
@@ -89,16 +90,15 @@ fromCodePoint c = fromInt (fromEnum c)
-- | @'indicesOfAny'@ finds all occurrences of any of several non-empty patterns
-- in a strict target string. If no non-empty patterns are given,
-- the result is an empty array. Otherwise the result
list
contains
-- the result is an empty array. Otherwise the result
array
contains
-- the pairs of all indices where any of the (non-empty) patterns start
-- and the array of all patterns starting at that index, the patterns being
-- represented by their (zero-based) position in the pattern array.
-- Empty patterns are filtered out before processing begins.
indicesOfAny :: Partial
=> Array String -- ^ Array of non-empty patterns
-> String -- ^ String to search
-> List (Tuple Int (Array Int)) -- ^ List of matches
indicesOfAny pats = if A.null nepats then const L.Nil
indicesOfAny :: Array String -- ^ Array of non-empty patterns
-> String -- ^ String to search
-> Array (Tuple Int (Array Int)) -- ^ Array of matches
indicesOfAny pats = if A.null nepats then const []
else strictMatcher nepats
where
nepats = A.filter (not <<< S.null) pats
...
...
@@ -118,8 +118,8 @@ minimum1 a fa =
Nothing -> a
Just b -> min a b
strictMatcher ::
Partial => Array String -> String -> List
(Tuple Int (Array Int))
strictMatcher pats = search
strictMatcher ::
Array String -> String -> Array
(Tuple Int (Array Int))
strictMatcher pats =
unsafePartial
search
where
hLen = minimum1 32 (S.length <$> pats)
hLen' = fromInt hLen
...
...
@@ -141,8 +141,9 @@ strictMatcher pats = search
hashMap =
M.fromFoldableWith (flip (<>))
(A.mapWithIndex (\i a -> Tuple (hash a) [i]) pats)
search str = if strLen < hLen then L.Nil
else go 0 shash
search :: Partial => String -> Array (Tuple Int (Array Int))
search str = if strLen < hLen then []
else A.fromFoldable (go 0 shash)
where
strLen = S.length str
maxIdx = strLen - hLen
...
...
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