From ddbcb0cd18b400b3c8c8e1be928ea57dc2f1e078 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 18 Aug 2016 12:50:03 -0400 Subject: [PATCH] Roll diffCostOfMaybes into constantTimeEditDistance. --- src/Data/RandomWalkSimilarity.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Data/RandomWalkSimilarity.hs b/src/Data/RandomWalkSimilarity.hs index 2d1edf59d..ba7d8c0cb 100644 --- a/src/Data/RandomWalkSimilarity.hs +++ b/src/Data/RandomWalkSimilarity.hs @@ -77,10 +77,7 @@ rws compare as bs -- | Computes a constant-time approximation to the edit distance of a diff. This is done by comparing at most _m_ nodes, & assuming the rest are zero-cost. constantTimeEditDistance :: (Prologue.Foldable f, Functor f) => Comparator f a -> Integer -> Cofree f a -> Cofree f a -> Int -constantTimeEditDistance compare m a b = fromMaybe maxBound $ diffCostOfMaybes . cutoff m <$> compare a b - -diffCostOfMaybes :: (Prologue.Foldable f, Functor f) => Free (CofreeF f (Both annotation)) (Maybe (Patch (Cofree f annotation))) -> Int -diffCostOfMaybes = diffSum $ patchSum termSize +constantTimeEditDistance compare m a b = fromMaybe maxBound $ diffSum (patchSum termSize) . cutoff m <$> compare a b where diffSum patchCost diff = sum $ fmap (maybe 0 patchCost) diff -- | A term which has not yet been mapped by `rws`, along with its feature vector summary & index.