Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-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
Przemyslaw Kaminski
haskell-gargantext
Commits
4ab99758
Commit
4ab99758
authored
Dec 17, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] HashMap lacking functions in main lib
parent
252b3ef9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
38 deletions
+39
-38
IMT.hs
src/Gargantext/Core/Ext/IMT.hs
+2
-2
Prelude.hs
src/Gargantext/Core/Text/List/Social/Prelude.hs
+1
-8
FrequentItemSet.hs
src/Gargantext/Core/Text/Metrics/FrequentItemSet.hs
+6
-9
Utils.hs
src/Gargantext/Core/Text/Metrics/Utils.hs
+2
-2
Utils.hs
src/Gargantext/Data/HashMap/Strict/Utils.hs
+28
-17
No files found.
src/Gargantext/Core/Ext/IMT.hs
View file @
4ab99758
...
...
@@ -20,7 +20,7 @@ import qualified Data.List as DL
import
qualified
Data.Vector
as
DV
import
qualified
Data.Map
as
M
import
Gargantext.Core.Text.Metrics.
Freq
as
F
import
Gargantext.Core.Text.Metrics.
Utils
as
Utils
import
Gargantext.Core.Text.Corpus.Parsers.CSV
as
CSV
data
School
=
School
{
school_shortName
::
Text
...
...
@@ -115,7 +115,7 @@ publisBySchool hal_data' = Gargantext.Prelude.map (\(i,n) -> (M.lookup i mapIdSc
$
DL
.
reverse
$
DL
.
sortOn
snd
$
M
.
toList
$
F
.
freq
$
Utils
.
freq
$
DL
.
concat
$
DV
.
toList
$
DV
.
map
(
\
n
->
splitOn
(
", "
)
(
csvHal_instStructId_i
n
)
)
...
...
src/Gargantext/Core/Text/List/Social/Prelude.hs
View file @
4ab99758
...
...
@@ -27,7 +27,6 @@ import Data.Semigroup (Semigroup(..))
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Text.Metrics.Freq
(
getMaxFromMap
)
import
Gargantext.Core.Types.Main
import
Gargantext.Prelude
import
qualified
Gargantext.Data.HashMap.Strict.Utils
as
HashMap
...
...
@@ -114,19 +113,13 @@ parentUnionsExcl = HashMap.unions
keyWithMaxValue
::
(
Ord
a
,
Ord
b
,
Num
b
,
Hashable
a
)
=>
HashMap
a
b
->
Maybe
a
keyWithMaxValue
m
=
do
maxKey
<-
headMay
$
HashMap
.
getKey
WithMaxValue
m
maxKey
<-
headMay
$
HashMap
.
getKey
sOrderedByValueMaxFirst
m
maxValue
<-
HashMap
.
lookup
maxKey
m
if
maxValue
>
0
then
pure
maxKey
else
Nothing
findMax
::
(
Ord
b
,
Num
b
,
Hashable
a
)
=>
HashMap
a
b
->
Maybe
(
a
,
b
)
findMax
m
=
case
HashMap
.
null
m
of
True
->
Nothing
False
->
Just
$
HashMap
.
findMax
m
------------------------------------------------------------------------
unPatchMapToHashMap
::
(
Ord
a
,
Hashable
a
)
=>
PatchMap
a
b
->
HashMap
a
b
unPatchMapToHashMap
=
HashMap
.
fromList
.
PatchMap
.
toList
...
...
src/Gargantext/Core/Text/Metrics/FrequentItemSet.hs
View file @
4ab99758
...
...
@@ -25,20 +25,17 @@ module Gargantext.Core.Text.Metrics.FrequentItemSet
)
where
import
Data.List
(
concat
,
null
)
import
Data.Map.Strict
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Set
(
Set
)
import
Gargantext.Prelude
import
HLCM
import
Prelude
(
Functor
(
..
))
-- TODO
import
qualified
Data.Map.Strict
as
Map
import
Data.Map.Strict
(
Map
)
import
qualified
Data.Set
as
Set
import
Data.Set
(
Set
)
import
qualified
Data.Vector
as
V
import
Data.List
(
concat
,
null
)
import
Data.Maybe
(
catMaybes
)
import
HLCM
import
Gargantext.Prelude
data
Size
=
Point
Int
|
Segment
Int
Int
------------------------------------------------------------------------
...
...
src/Gargantext/Core/Text/Metrics/
Freq
.hs
→
src/Gargantext/Core/Text/Metrics/
Utils
.hs
View file @
4ab99758
{-|
Module : Gargantext.Core.Text.Metrics.
Freq
Module : Gargantext.Core.Text.Metrics.
Utils
Description : Some functions to count.
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
...
...
@@ -10,7 +10,7 @@ Portability : POSIX
-}
module
Gargantext.Core.Text.Metrics.
Freq
where
module
Gargantext.Core.Text.Metrics.
Utils
where
import
Gargantext.Prelude
import
Data.Map
(
empty
,
Map
,
insertWith
,
toList
)
...
...
src/Gargantext/Data/HashMap/Strict/Utils.hs
View file @
4ab99758
module
Gargantext.Data.HashMap.Strict.Utils
where
import
Data.Hashable
(
Hashable
)
import
Data.HashMap.Strict
(
HashMap
)
import
qualified
Data.HashMap.Strict
as
HM
import
Data.Hashable
(
Hashable
)
import
Gargantext.Prelude
import
qualified
Data.HashMap.Strict
as
HashMap
------------------------------------------------------------------------
unionsWith
::
(
Foldable
f
,
Eq
k
,
Hashable
k
)
=>
(
a
->
a
->
a
)
->
f
(
HashMap
k
a
)
->
HashMap
k
a
unionsWith
f
=
foldl'
(
HM
.
unionWith
f
)
HM
.
empty
partition
::
Hashable
k
=>
(
a
->
Bool
)
->
HashMap
k
a
->
(
HashMap
k
a
,
HashMap
k
a
)
partition
=
undefined
partitionWithKey
::
Hashable
k
=>
(
k
->
a
->
Bool
)
->
HashMap
k
a
->
(
HashMap
k
a
,
HashMap
k
a
)
partitionWithKey
=
undefined
findMax
::
Hashable
k
=>
HashMap
k
a
->
(
k
,
a
)
findMax
=
undefined
unionsWith
f
=
foldl'
(
HashMap
.
unionWith
f
)
HashMap
.
empty
------------------------------------------------------------------------
-- | Partition the map according to some predicate. The first map contains all
-- elements that satisfy the predicate, the second all elements that fail the
-- predicate.
partition
::
(
Ord
k
,
Hashable
k
)
=>
(
a
->
Bool
)
->
HashMap
k
a
->
(
HashMap
k
a
,
HashMap
k
a
)
partition
p
m
=
(
HashMap
.
filter
p
m
,
HashMap
.
filter
(
not
.
p
)
m
)
-- | Partition the map according to some predicate. The first map contains all
-- elements that satisfy the predicate, the second all elements that fail the
-- predicate.
partitionWithKey
::
(
Ord
a
,
Hashable
k
)
=>
(
k
->
a
->
Bool
)
->
HashMap
k
a
->
(
HashMap
k
a
,
HashMap
k
a
)
partitionWithKey
p
m
=
(
HashMap
.
filterWithKey
p
m
,
HashMap
.
filterWithKey
(
\
k
->
not
.
p
k
)
m
)
------------------------------------------------------------------------
-- getKeyWithMaxValue :: Hashable k => HashMap k a -> Maybe k
getKeyWithMaxValue
::
Hashable
k
=>
HashMap
k
a
->
[
k
]
getKeyWithMaxValue
=
undefined
getKeysOrderedByValueMaxFirst
::
(
Ord
k
,
Hashable
k
,
Ord
a
)
=>
HashMap
k
a
->
[
k
]
getKeysOrderedByValueMaxFirst
m
=
go
[]
Nothing
(
HashMap
.
toList
m
)
where
go
ks
_
[]
=
ks
go
ks
Nothing
((
k
,
v
)
:
rest
)
=
go
(
k
:
ks
)
(
Just
v
)
rest
go
ks
(
Just
u
)
((
k
,
v
)
:
rest
)
|
v
<
u
=
go
ks
(
Just
u
)
rest
|
v
>
u
=
go
[
k
]
(
Just
v
)
rest
|
otherwise
=
go
(
k
:
ks
)
(
Just
v
)
rest
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