More WithList fixes

parent 4348e54a
...@@ -52,7 +52,8 @@ main = do ...@@ -52,7 +52,8 @@ main = do
putStrLn $ show $ length termList putStrLn $ show $ length termList
corpusIndexed <- mapM (terms (WithList $ buildPatterns termList)) corpus let patterns = WithList $ buildPatterns termList
corpusIndexed <- mapM (terms patterns) corpus
putStrLn $ show corpusIndexed putStrLn $ show corpusIndexed
let myCooc = cooc corpusIndexed let myCooc = cooc corpusIndexed
......
...@@ -20,7 +20,7 @@ import qualified Data.Algorithms.KMP as KMP ...@@ -20,7 +20,7 @@ import qualified Data.Algorithms.KMP as KMP
import Data.Text (Text) import Data.Text (Text)
import qualified Data.IntMap.Strict as IntMap import qualified Data.IntMap.Strict as IntMap
import Gargantext.Core.Types (Terms(Terms)) import Gargantext.Core.Types (Terms(..))
import Gargantext.Text.Context import Gargantext.Text.Context
import Gargantext.Text.Terms.Mono (monoTextsBySentence) import Gargantext.Text.Terms.Mono (monoTextsBySentence)
...@@ -50,8 +50,8 @@ replaceTerms pats terms = go 0 ...@@ -50,8 +50,8 @@ replaceTerms pats terms = go 0
| otherwise = | otherwise =
case IntMap.lookup ix m of case IntMap.lookup ix m of
Nothing -> go (ix + 1) Nothing -> go (ix + 1)
Just (len, terms) -> Just (len, term) ->
terms : go (ix + len) term : go (ix + len)
merge (len1, lab1) (len2, lab2) = merge (len1, lab1) (len2, lab2) =
...@@ -59,8 +59,8 @@ replaceTerms pats terms = go 0 ...@@ -59,8 +59,8 @@ replaceTerms pats terms = go 0
m = m =
IntMap.fromListWith merge IntMap.fromListWith merge
[ (ix, (len, terms)) [ (ix, (len, term))
| Pattern pat len terms <- pats, ix <- KMP.match pat terms ] | Pattern pat len term <- pats, ix <- KMP.match pat (_terms_label term) ]
buildPatterns :: TermList -> Patterns buildPatterns :: TermList -> Patterns
buildPatterns = sortWith (Down . _pat_length) . concatMap buildPattern buildPatterns = sortWith (Down . _pat_length) . concatMap buildPattern
......
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