From 50c52af354fca2f344556b6135748f99da8e85e3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 9 Aug 2016 16:09:23 -0400 Subject: [PATCH] Define padToSize in pqGramDecorator. --- 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 6a7fe2241..23a022d31 100644 --- a/src/Data/RandomWalkSimilarity.hs +++ b/src/Data/RandomWalkSimilarity.hs @@ -83,6 +83,7 @@ pqGramDecorator getLabel p q = cata algebra pure $! cofree ((gram { stem = padToSize p (Just label : stem gram), base = padToSize q labels } .: rest) :< functor) siblingLabels :: Traversable f => f (Cofree f (Record (Gram label ': fields))) -> [Maybe label] siblingLabels = foldMap (base . rhead . extract) + padToSize n list = take n (list <> repeat empty) -- | Computes a unit vector of the specified dimension from a hash. unitVector :: Int -> Int -> Vector.Vector Double @@ -97,10 +98,6 @@ featureVectorDecorator getLabel p q d cofree ((foldr (Vector.zipWith (+) . getField . extract) (unitVector d (hash gram)) functor .: rest) :< functor)) . pqGramDecorator getLabel p q --- | Pads a list of Alternative values to exactly n elements. -padToSize :: Alternative f => Int -> [f a] -> [f a] -padToSize n list = take n (list <> repeat empty) - -- Instances