Commit 10ee6b8d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[COSMETICS] facto in Prelude.

parent fc00a623
{-|
Module : Gargantext.Core
Description :
Description : Which Natural language is supported ?
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
-}
module Gargantext.Core
......@@ -19,7 +17,6 @@ module Gargantext.Core
-- For simplicity, we suppose text has an homogenous language
data Lang = EN | FR
-- | DE | IT | SP
-- EN == english
-- FR == french
......
{-|
Module : Gargantext.Prelude
Description :
Description : Specific Prelude of the project
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
......@@ -72,18 +72,12 @@ import Text.Show (Show(), show)
import Text.Read (Read())
import Data.String.Conversions (cs)
--pf :: (a -> Bool) -> [a] -> [a]
--pf = filter
pr :: [a] -> [a]
pr = reverse
--pm :: (a -> b) -> [a] -> [b]
--pm = map
map2 :: (t -> b) -> [[t]] -> [[b]]
map2 fun = map (map fun)
-- Some Statistics sugar functions
-- Exponential Average
eavg :: [Double] -> Double
eavg (x:xs) = a*x + (1-a)*(eavg xs)
......@@ -95,6 +89,7 @@ mean :: Fractional a => [a] -> a
mean xs = if L.null xs then 0.0
else sum xs / fromIntegral (length xs)
sumMaybe :: Num a => [Maybe a] -> Maybe a
sumMaybe = fmap sum . M.sequence
......@@ -187,17 +182,17 @@ trunc' :: Int -> Double -> Double
trunc' n x = fromIntegral $ truncate $ (x * 10^n)
bool2int :: Num a => Bool -> a
bool2int b = case b of
True -> 1
False -> 0
------------------------------------------------------------------------
bool2num :: Num a => Bool -> a
bool2num True = 1
bool2num False = 0
bool2double :: Bool -> Double
bool2double bool = case bool of
True -> 1.0
False -> 0.0
bool2double = bool2num
bool2int :: Bool -> Int
bool2int = bool2num
------------------------------------------------------------------------
-- Normalizing && scaling data
scale :: [Double] -> [Double]
......@@ -217,8 +212,6 @@ scaleNormalize xs = map (\x -> (x - v / (m + 1))) xs'
m = mean xs'
xs' = map abs xs
normalize :: [Double] -> [Double]
normalize as = normalizeWith identity as
......@@ -234,10 +227,6 @@ zipFst f xs = zip (f xs) xs
zipSnd :: ([a] -> [b]) -> [a] -> [(a, b)]
zipSnd f xs = zip xs (f xs)
-- Just
unMaybe :: [Maybe a] -> [a]
unMaybe = map fromJust . L.filter isJust
-- | maximumWith
maximumWith :: (Ord a1, Foldable t) => (a2 -> a1) -> t a2 -> a2
maximumWith f = L.maximumBy (compare `on` f)
......
......@@ -51,7 +51,6 @@ import Data.Graph.Clustering.Louvain.CplusPlus (cLouvain, LouvainNode(..))
| |_| | (_| | | | (_| | (_| | | | | || __/> <| |_
\____|\__,_|_| \__, |\__,_|_| |_|\__\___/_/\_\\__|
|___/
-}
printDebug :: (Show a, MonadIO m) => [Char] -> a -> m ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment