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