Commit e49efe51 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Data.List qualified import

parent ea0fe616
...@@ -21,12 +21,11 @@ module Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt) ...@@ -21,12 +21,11 @@ module Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt)
import Control.Monad import Control.Monad
import Data.Either import Data.Either
import Data.List ((!!))
import Data.Maybe import Data.Maybe
import Data.Text (Text(), pack, unpack) import Data.Text (Text(), pack, unpack)
import Data.List hiding (map, head)
import Gargantext.Prelude import Gargantext.Prelude
import qualified Data.List as List hiding (map, head)
vowels :: [Char] vowels :: [Char]
vowels = ['a','e','i','o','u'] vowels = ['a','e','i','o','u']
...@@ -50,16 +49,16 @@ containsVowel = byIndex (any . isVowel) ...@@ -50,16 +49,16 @@ containsVowel = byIndex (any . isVowel)
-- | /!\ unsafe fromJust -- | /!\ unsafe fromJust
measure :: [Char] -> Int measure :: [Char] -> Int
measure = length . filter not . init . (True:) measure = length . filter not . List.init . (True:)
. map fromJust . map head . map fromJust . map head
. group . byIndex (map . isConsonant) . List.group . byIndex (map . isConsonant)
endsWithDouble :: [Char] -> Bool endsWithDouble :: [Char] -> Bool
endsWithDouble = startsWithDouble . reverse endsWithDouble = startsWithDouble . reverse
where where
startsWithDouble l = case l of startsWithDouble l = case l of
(x:y:_) -> x == y && x `notElem` vowels (x:y:_) -> x == y && x `List.notElem` vowels
_ -> False _ -> False
cvc :: [Char] -> Bool cvc :: [Char] -> Bool
...@@ -67,18 +66,18 @@ cvc word | length word < 3 = False ...@@ -67,18 +66,18 @@ cvc word | length word < 3 = False
| otherwise = isConsonant word lastIndex && | otherwise = isConsonant word lastIndex &&
isVowel word (lastIndex - 1) && isVowel word (lastIndex - 1) &&
isConsonant word (lastIndex - 2) && isConsonant word (lastIndex - 2) &&
last word `notElem` ['w','x','y'] List.last word `List.notElem` ['w','x','y']
where lastIndex = length word - 1 where lastIndex = length word - 1
statefulReplace :: Eq a => ([a] -> Bool) statefulReplace :: Eq a => ([a] -> Bool)
-> [a] -> [a] -> [a] -> [a] -> [a] -> [a]
-> Maybe (Data.Either.Either [a] [a]) -> Maybe (Data.Either.Either [a] [a])
statefulReplace predicate str end replacement statefulReplace predicate str end replacement
| end `isSuffixOf` str = Just replaced | end `List.isSuffixOf` str = Just replaced
| otherwise = Nothing | otherwise = Nothing
where where
part = take (length str - length end) str part = take (length str - length end) str
replaced | predicate part = Right (part ++ replacement) replaced | predicate part = Right (part <> replacement)
| otherwise = Left str | otherwise = Left str
replaceEnd :: Eq a => ([a] -> Bool) -> [a] -> [a] -> [a] -> Maybe [a] replaceEnd :: Eq a => ([a] -> Bool) -> [a] -> [a] -> [a] -> Maybe [a]
...@@ -113,12 +112,12 @@ beforeStep1b word = fromMaybe (Left word) result ...@@ -113,12 +112,12 @@ beforeStep1b word = fromMaybe (Left word) result
afterStep1b :: [Char] -> [Char] afterStep1b :: [Char] -> [Char]
afterStep1b word = fromMaybe word result afterStep1b word = fromMaybe word result
where where
double = endsWithDouble word && not (any ((`isSuffixOf` word) . return) ['l','s','z']) double = endsWithDouble word && not (any ((`List.isSuffixOf` word) . return) ['l','s','z'])
mEq1AndCvc = measure word == 1 && cvc word mEq1AndCvc = measure word == 1 && cvc word
iif cond val = if cond then Just val else Nothing iif cond val = if cond then Just val else Nothing
result = findStem (const True) word [("at", "ate"), ("bl", "ble"), ("iz", "ize")] result = findStem (const True) word [("at", "ate"), ("bl", "ble"), ("iz", "ize")]
`mplus` iif double (init word) `mplus` iif double (List.init word)
`mplus` iif mEq1AndCvc (word ++ "e") `mplus` iif mEq1AndCvc (word <> "e")
step1b :: [Char] -> [Char] step1b :: [Char] -> [Char]
step1b = either identity afterStep1b . beforeStep1b step1b = either identity afterStep1b . beforeStep1b
...@@ -171,7 +170,7 @@ step3 word = fromMaybe word result ...@@ -171,7 +170,7 @@ step3 word = fromMaybe word result
step4 :: [Char] -> [Char] step4 :: [Char] -> [Char]
step4 word = fromMaybe word result step4 word = fromMaybe word result
where where
gt1andST str = (measureGT 1) str && any ((`isSuffixOf` str) . return) ['s','t'] gt1andST str = (measureGT 1) str && any ((`List.isSuffixOf` str) . return) ['s','t']
findGT1 = findStem (measureGT 1) word . map (flip (,) "") findGT1 = findStem (measureGT 1) word . map (flip (,) "")
result = (findGT1 ["al", "ance", "ence", "er", "ic", "able", "ible", "ant", "ement", "ment", "ent"]) `mplus` result = (findGT1 ["al", "ance", "ence", "er", "ic", "able", "ible", "ant", "ement", "ment", "ent"]) `mplus`
(findStem gt1andST word [("ion","")]) `mplus` (findStem gt1andST word [("ion","")]) `mplus`
...@@ -186,7 +185,7 @@ step5a word = fromMaybe word result ...@@ -186,7 +185,7 @@ step5a word = fromMaybe word result
step5b :: [Char] -> [Char] step5b :: [Char] -> [Char]
step5b word = fromMaybe word result step5b word = fromMaybe word result
where where
cond s = last s == 'l' && measureGT 1 s cond s = List.last s == 'l' && measureGT 1 s
result = replaceEnd cond word "l" "" result = replaceEnd cond word "l" ""
step5 :: [Char] -> [Char] step5 :: [Char] -> [Char]
......
...@@ -16,7 +16,7 @@ module Gargantext.Core.Viz.Graph.FGL where ...@@ -16,7 +16,7 @@ module Gargantext.Core.Viz.Graph.FGL where
import Gargantext.Prelude import Gargantext.Prelude
import qualified Data.Graph.Inductive as FGL import qualified Data.Graph.Inductive as FGL
import Data.List as List import qualified Data.List as List
------------------------------------------------------------------ ------------------------------------------------------------------
-- | Main Types -- | Main Types
......
...@@ -6,12 +6,11 @@ import Control.Concurrent.STM ...@@ -6,12 +6,11 @@ import Control.Concurrent.STM
import Control.Exception import Control.Exception
import Control.Monad import Control.Monad
import Data.Function import Data.Function
import Data.List
import Data.Ord
import Data.Maybe import Data.Maybe
import Data.Ord
import Prelude import Prelude
import System.IO import System.IO
import Data.List
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Data.Vector as Vector import qualified Data.Vector as Vector
......
...@@ -7,7 +7,7 @@ import Gargantext.Utils.Jobs.Settings ...@@ -7,7 +7,7 @@ import Gargantext.Utils.Jobs.Settings
import Control.Concurrent.Async import Control.Concurrent.Async
import Control.Concurrent.STM import Control.Concurrent.STM
import Control.Monad import Control.Monad
import Data.List import qualified Data.List as List
import Data.Map.Strict (Map) import Data.Map.Strict (Map)
import Data.Maybe import Data.Maybe
import Data.Ord import Data.Ord
...@@ -67,7 +67,7 @@ newJobsState js prios = do ...@@ -67,7 +67,7 @@ newJobsState js prios = do
case mje of case mje of
Nothing -> return Nothing Nothing -> return Nothing
Just je -> return $ Just (jid, popjid, jRegistered je) Just je -> return $ Just (jid, popjid, jRegistered je)
let (jid, popjid, _) = minimumBy (comparing _3) jinfos let (jid, popjid, _) = List.minimumBy (comparing _3) jinfos
return (jid, popjid) return (jid, popjid)
_3 (_, _, c) = c _3 (_, _, c) = c
......
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