Commit e3eb8220 authored by qlobbe's avatar qlobbe

fix the artifacts

parent 729de971
Pipeline #606 failed with stage
...@@ -127,7 +127,7 @@ defaultConfig = ...@@ -127,7 +127,7 @@ defaultConfig =
, phyloLevel = 2 , phyloLevel = 2
, phyloProximity = WeightedLogJaccard 10 0 0.1 , phyloProximity = WeightedLogJaccard 10 0 0.1
, phyloSynchrony = ByProximityDistribution 0 , phyloSynchrony = ByProximityDistribution 0
, phyloQuality = Quality 1 1 , phyloQuality = Quality 0.2 4
, timeUnit = Year 3 1 5 , timeUnit = Year 3 1 5
, contextualUnit = Fis 1 5 , contextualUnit = Fis 1 5
, exportLabel = [BranchLabel MostInclusive 2, GroupLabel MostEmergentInclusive 2] , exportLabel = [BranchLabel MostInclusive 2, GroupLabel MostEmergentInclusive 2]
......
...@@ -106,7 +106,8 @@ groupToTable fdt g = H.Table H.HTable ...@@ -106,7 +106,8 @@ groupToTable fdt g = H.Table H.HTable
<> (pack $ show (fst $ g ^. phylo_groupPeriod)) <> (pack $ show (fst $ g ^. phylo_groupPeriod))
<> (fromStrict " , ") <> (fromStrict " , ")
<> (pack $ show (snd $ g ^. phylo_groupPeriod)) <> (pack $ show (snd $ g ^. phylo_groupPeriod))
<> (fromStrict " ) "))]] <> (fromStrict " ) ")
<> (pack $ show (getGroupId g)))]]
-------------------------------------- --------------------------------------
branchToDotNode :: PhyloBranch -> Dot DotId branchToDotNode :: PhyloBranch -> Dot DotId
......
...@@ -129,8 +129,8 @@ makePairs' ego candidates periods pointers fil thr prox docs = ...@@ -129,8 +129,8 @@ makePairs' ego candidates periods pointers fil thr prox docs =
True -> [] True -> []
False -> toLazyPairs pointers fil thr prox lastPrd False -> toLazyPairs pointers fil thr prox lastPrd
-- | at least on of the pair candidates should be from the last added period -- | at least on of the pair candidates should be from the last added period
-- $ filter (\(g,g') -> ((g ^. phylo_groupPeriod) == lastPrd) $ filter (\(g,g') -> ((g ^. phylo_groupPeriod) == lastPrd)
-- || ((g' ^. phylo_groupPeriod) == lastPrd)) || ((g' ^. phylo_groupPeriod) == lastPrd))
$ listToKeys $ listToKeys
$ filter (\g -> (g ^. phylo_groupPeriod == lastPrd) $ filter (\g -> (g ^. phylo_groupPeriod == lastPrd)
|| ((toProximity docs prox ego ego g) >= thr)) candidates || ((toProximity docs prox ego ego g) >= thr)) candidates
...@@ -145,18 +145,18 @@ filterPointers proxi thr pts = filter (\(_,w) -> filterProximity proxi thr w) pt ...@@ -145,18 +145,18 @@ filterPointers proxi thr pts = filter (\(_,w) -> filterProximity proxi thr w) pt
phyloGroupMatching :: [[PhyloGroup]] -> Filiation -> Proximity -> Map Date Double -> Double -> PhyloGroup -> PhyloGroup phyloGroupMatching :: [[PhyloGroup]] -> Filiation -> Proximity -> Map Date Double -> Double -> PhyloGroup -> PhyloGroup
phyloGroupMatching candidates fil proxi docs thr ego = phyloGroupMatching candidates fil proxi docs thr ego =
if (null $ filterPointers proxi thr $ getPeriodPointers fil ego) if (null $ filterPointers proxi thr $ getPeriodPointers fil ego)
-- | let's find new pointers -- | let's find new pointers
then if null nextPointers then if null nextPointers
then addPointers ego fil TemporalPointer [] then addPointers ego fil TemporalPointer []
else addPointers ego fil TemporalPointer else addPointers ego fil TemporalPointer
$ head' "phyloGroupMatching" $ head' "phyloGroupMatching"
-- | Keep only the best set of pointers grouped by proximity -- | Keep only the best set of pointers grouped by proximity
$ groupBy (\pt pt' -> snd pt == snd pt') $ groupBy (\pt pt' -> snd pt == snd pt')
$ reverse $ sortOn snd $ head' "pointers" nextPointers $ reverse $ sortOn snd $ head' "pointers" nextPointers
-- | Find the first time frame where at leats one pointer satisfies the proximity threshold -- | Find the first time frame where at leats one pointer satisfies the proximity threshold
else addPointers ego fil TemporalPointer else addPointers ego fil TemporalPointer
$ filterPointers proxi thr $ getPeriodPointers fil ego $ filterPointers proxi thr $ getPeriodPointers fil ego
where where
nextPointers :: [[Pointer]] nextPointers :: [[Pointer]]
nextPointers = take 1 nextPointers = take 1
...@@ -193,17 +193,11 @@ getNextPeriods fil max' pId pIds = ...@@ -193,17 +193,11 @@ getNextPeriods fil max' pId pIds =
ToParents -> take max' $ (reverse . fst) $ splitAt (elemIndex' pId pIds) pIds ToParents -> take max' $ (reverse . fst) $ splitAt (elemIndex' pId pIds) pIds
getCandidates :: Filiation -> PhyloGroup -> [[PhyloGroup]] -> [[PhyloGroup]] getCandidates :: PhyloGroup -> [[PhyloGroup]] -> [[PhyloGroup]]
getCandidates fil ego targets = getCandidates ego targets =
case fil of map (\groups' ->
ToChilds -> targets' filter (\g' -> (not . null) $ intersect (ego ^. phylo_groupNgrams) (g' ^. phylo_groupNgrams)
ToParents -> reverse targets' ) groups') targets
where
targets' :: [[PhyloGroup]]
targets' =
map (\groups' ->
filter (\g' -> (not . null) $ intersect (ego ^. phylo_groupNgrams) (g' ^. phylo_groupNgrams)
) groups') targets
phyloBranchMatching :: Int -> [PhyloPeriodId] -> Proximity -> Double -> Map Date Double -> [PhyloGroup] -> [PhyloGroup] phyloBranchMatching :: Int -> [PhyloPeriodId] -> Proximity -> Double -> Map Date Double -> [PhyloGroup] -> [PhyloGroup]
...@@ -221,8 +215,8 @@ phyloBranchMatching frame periods proximity thr docs branch = ...@@ -221,8 +215,8 @@ phyloBranchMatching frame periods proximity thr docs branch =
candidatesChi = map (\prd' -> findWithDefault [] prd' branch') periodsChi candidatesChi = map (\prd' -> findWithDefault [] prd' branch') periodsChi
docsPar = filterDocs docs ([prd] ++ periodsPar) docsPar = filterDocs docs ([prd] ++ periodsPar)
docsChi = filterDocs docs ([prd] ++ periodsChi) docsChi = filterDocs docs ([prd] ++ periodsChi)
egos = map (\ego -> phyloGroupMatching (getCandidates ToParents ego candidatesPar) ToParents proximity docsPar thr egos = map (\ego -> phyloGroupMatching (getCandidates ego candidatesPar) ToParents proximity docsPar thr
$ phyloGroupMatching (getCandidates ToChilds ego candidatesChi) ToChilds proximity docsChi thr ego) $ phyloGroupMatching (getCandidates ego candidatesChi) ToChilds proximity docsChi thr ego)
$ findWithDefault [] prd branch' $ findWithDefault [] prd branch'
egos' = egos `using` parList rdeepseq egos' = egos `using` parList rdeepseq
in acc ++ egos' ) [] periods in acc ++ egos' ) [] periods
...@@ -297,13 +291,13 @@ seqMatching proximity beta frequency minBranch egoThr frame docs periods done eg ...@@ -297,13 +291,13 @@ seqMatching proximity beta frequency minBranch egoThr frame docs periods done eg
-- | 1) keep or not the new division of ego -- | 1) keep or not the new division of ego
let done' = done ++ (if snd ego let done' = done ++ (if snd ego
then (if ((null (fst ego')) || (quality > quality')) then (if ((null (fst ego')) || (quality > quality'))
then then
-- trace (" ✗ F(β) = " <> show(quality) <> " (vs) " <> show(quality') -- trace (" ✗ F(β) = " <> show(quality) <> " (vs) " <> show(quality')
-- <> " | " <> show(length $ fst ego) <> " groups : " -- <> " | " <> show(length $ fst ego) <> " groups : "
-- <> " |✓ " <> show(length $ fst ego') <> show(map length $ fst ego') -- <> " |✓ " <> show(length $ fst ego') <> show(map length $ fst ego')
-- <> " |✗ " <> show(length $ snd ego') <> "[" <> show(length $ concat $ snd ego') <> "]") -- <> " |✗ " <> show(length $ snd ego') <> "[" <> show(length $ concat $ snd ego') <> "]")
[(fst ego,False)] [(fst ego,False)]
else else
-- trace (" ✓ F(β) = " <> show(quality) <> " (vs) " <> show(quality') -- trace (" ✓ F(β) = " <> show(quality) <> " (vs) " <> show(quality')
-- <> " | " <> show(length $ fst ego) <> " groups : " -- <> " | " <> show(length $ fst ego) <> " groups : "
-- <> " |✓ " <> show(length $ fst ego') <> show(map length $ fst ego') -- <> " |✓ " <> show(length $ fst ego') <> show(map length $ fst ego')
...@@ -346,8 +340,8 @@ recursiveMatching' proximity beta minBranch frequency egoThr frame periods docs ...@@ -346,8 +340,8 @@ recursiveMatching' proximity beta minBranch frequency egoThr frame periods docs
temporalMatching :: Phylo -> Phylo temporalMatching :: Phylo -> Phylo
temporalMatching phylo = updatePhyloGroups 1 temporalMatching phylo = updatePhyloGroups 1
(fromList $ map (\g -> (getGroupId g,g)) $ traceMatchEnd $ concat branches) (fromList $ map (\g -> (getGroupId g,g)) $ traceMatchEnd $ concat branches)
phylo phylo
where where
-- | 2) init the recursiveMatching -- | 2) init the recursiveMatching
branches :: [[PhyloGroup]] branches :: [[PhyloGroup]]
...@@ -360,10 +354,12 @@ temporalMatching phylo = updatePhyloGroups 1 ...@@ -360,10 +354,12 @@ temporalMatching phylo = updatePhyloGroups 1
(getTimeFrame $ timeUnit $ getConfig phylo) (getTimeFrame $ timeUnit $ getConfig phylo)
(getPeriodIds phylo) (getPeriodIds phylo)
(phylo ^. phylo_timeDocs) (phylo ^. phylo_timeDocs)
[(groups,True)] groups
-- | 1) for each group process an initial temporal Matching -- | 1) for each group process an initial temporal Matching
groups :: [PhyloGroup] groups :: [([PhyloGroup],Bool)]
groups = phyloBranchMatching (getTimeFrame $ timeUnit $ getConfig phylo) (getPeriodIds phylo) groups = map (\b -> (b,(length $ nub $ map _phylo_groupPeriod b) >= (_qua_minBranch $ phyloQuality $ getConfig phylo)))
$ groupsToBranches $ fromList $ map (\g -> (getGroupId g, g))
$ phyloBranchMatching (getTimeFrame $ timeUnit $ getConfig phylo) (getPeriodIds phylo)
(phyloProximity $ getConfig phylo) (getThresholdInit $ phyloProximity $ getConfig phylo) (phyloProximity $ getConfig phylo) (getThresholdInit $ phyloProximity $ getConfig phylo)
(phylo ^. phylo_timeDocs) (phylo ^. phylo_timeDocs)
(traceTemporalMatching $ getGroupsFromLevel 1 phylo) (traceTemporalMatching $ getGroupsFromLevel 1 phylo)
\ No newline at end of file
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