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

[FIX] some warnings/errors at compilation time. OK.

parent 29959d51
...@@ -36,7 +36,7 @@ import Gargantext.Core (Lang) ...@@ -36,7 +36,7 @@ import Gargantext.Core (Lang)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map) import Gargantext.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map)
import Gargantext.Viz.Graph.Distances.Matrice (distributional, measureConditional) import Gargantext.Viz.Graph.Distances.Matrice (measureConditional)
import Gargantext.Viz.Graph (Graph(..), data2graph) import Gargantext.Viz.Graph (Graph(..), data2graph)
import Gargantext.Text.Metrics.Count (cooc) import Gargantext.Text.Metrics.Count (cooc)
import Gargantext.Text.Metrics (filterCooc, FilterConfig(..), Clusters(..), SampleBins(..), DefaultValue(..), MapListSize(..), InclusionSize(..)) import Gargantext.Text.Metrics (filterCooc, FilterConfig(..), Clusters(..), SampleBins(..), DefaultValue(..), MapListSize(..), InclusionSize(..))
...@@ -58,7 +58,7 @@ import Data.Graph.Clustering.Louvain.CplusPlus (cLouvain, l_community_id) ...@@ -58,7 +58,7 @@ import Data.Graph.Clustering.Louvain.CplusPlus (cLouvain, l_community_id)
contextText :: [T.Text] contextText :: [T.Text]
contextText = ["The dog is an animal." contextText = map T.pack ["The dog is an animal."
,"The bird is an animal." ,"The bird is an animal."
,"The bird is an animal." ,"The bird is an animal."
,"The bird and the dog are an animal." ,"The bird and the dog are an animal."
...@@ -72,14 +72,13 @@ contextText = ["The dog is an animal." ...@@ -72,14 +72,13 @@ contextText = ["The dog is an animal."
] ]
-- | Control the flow of text
data TextFlow = CSV FilePath data TextFlow = CSV FilePath
| FullText FilePath | FullText FilePath
| Contexts [T.Text] | Contexts [T.Text]
| DB Connection CorpusId | DB Connection CorpusId
| Query T.Text | Query T.Text
-- ExtDatabase Query
-- IntDatabase NodeId
textFlow :: TermType Lang -> TextFlow -> IO Graph textFlow :: TermType Lang -> TextFlow -> IO Graph
textFlow termType workType = do textFlow termType workType = do
...@@ -87,7 +86,7 @@ textFlow termType workType = do ...@@ -87,7 +86,7 @@ textFlow termType workType = do
FullText path -> splitBy (Sentences 5) <$> readFile path FullText path -> splitBy (Sentences 5) <$> readFile path
CSV path -> readCsvOn [csv_title, csv_abstract] path CSV path -> readCsvOn [csv_title, csv_abstract] path
Contexts ctxt -> pure ctxt Contexts ctxt -> pure ctxt
SQL con corpusId -> catMaybes <$> map (\n -> hyperdataDocumentV3_title (node_hyperdata n) <> hyperdataDocumentV3_abstract (node_hyperdata n))<$> getDocumentsV3WithParentId con corpusId DB con corpusId -> catMaybes <$> map (\n -> hyperdataDocumentV3_title (node_hyperdata n) <> hyperdataDocumentV3_abstract (node_hyperdata n))<$> getDocumentsV3WithParentId con corpusId
_ -> undefined _ -> undefined
textFlow' termType contexts textFlow' termType contexts
...@@ -147,7 +146,7 @@ textFlow' termType contexts = do ...@@ -147,7 +146,7 @@ textFlow' termType contexts = do
printDebug "distanceMat" distanceMat printDebug "distanceMat" distanceMat
-- --
--let distanceMap = M.filter (>0) $ mat2map distanceMat --let distanceMap = M.filter (>0) $ mat2map distanceMat
let distanceMap = M.map (\n -> 1) $ M.filter (>0) $ mat2map distanceMat let distanceMap = M.map (\_ -> 1) $ M.filter (>0) $ mat2map distanceMat
printDebug "distanceMap size" $ M.size distanceMap printDebug "distanceMap size" $ M.size distanceMap
printDebug "distanceMap" distanceMap printDebug "distanceMap" distanceMap
...@@ -160,4 +159,3 @@ textFlow' termType contexts = do ...@@ -160,4 +159,3 @@ textFlow' termType contexts = do
--printDebug "partitions" partitions --printDebug "partitions" partitions
pure $ data2graph (M.toList ti) myCooc4 distanceMap partitions pure $ data2graph (M.toList ti) myCooc4 distanceMap partitions
...@@ -227,7 +227,6 @@ conditional' m = (run $ ie $ map fromIntegral $ use m, run $ sg $ map fromIntegr ...@@ -227,7 +227,6 @@ conditional' m = (run $ ie $ map fromIntegral $ use m, run $ sg $ map fromIntegr
distributional :: Matrix Int -> Matrix Double distributional :: Matrix Int -> Matrix Double
distributional m = run $ matMiniMax $ ri (map fromIntegral $ use m) distributional m = run $ matMiniMax $ ri (map fromIntegral $ use m)
where where
n = dim m
-- filter m = zipWith (\a b -> max a b) m (transpose m) -- filter m = zipWith (\a b -> max a b) m (transpose m)
...@@ -240,6 +239,7 @@ distributional m = run $ matMiniMax $ ri (map fromIntegral $ use m) ...@@ -240,6 +239,7 @@ distributional m = run $ matMiniMax $ ri (map fromIntegral $ use m)
$ zipWith (/) (crossProduct m') (total m') $ zipWith (/) (crossProduct m') (total m')
total m'' = replicate (constant (Z :. n :. n)) $ fold (+) 0 $ fold (+) 0 m'' total m'' = replicate (constant (Z :. n :. n)) $ fold (+) 0 $ fold (+) 0 m''
n = dim m
crossProduct m''' = zipWith (*) (cross m''' ) (cross (transpose m''')) crossProduct m''' = zipWith (*) (cross m''' ) (cross (transpose m'''))
cross mat = zipWith (-) (matSum n mat) (mat) cross mat = zipWith (-) (matSum n mat) (mat)
......
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