From bdb93ef44b34f0e68c9c50efa898aeeefda04775 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 15 Jul 2016 14:55:26 -0400 Subject: [PATCH] =?UTF-8?q?pqGrams=20doesn=E2=80=99t=20require=20Syntax.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/RandomWalkSimilarity.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/RandomWalkSimilarity.hs b/src/Data/RandomWalkSimilarity.hs index 3b0587e2b..5eef5442e 100644 --- a/src/Data/RandomWalkSimilarity.hs +++ b/src/Data/RandomWalkSimilarity.hs @@ -53,7 +53,7 @@ data Gram label = Gram { stem :: [Maybe label], base :: [Maybe label] } deriving (Eq, Show) -- | Compute the bag of grams with stems of length _p_ and bases of length _q_, with labels computed from annotations, which summarize the entire subtree of a term. -pqGrams :: Int -> Int -> (forall b. CofreeF (Syntax leaf) annotation b -> label) -> Cofree (Syntax leaf) annotation -> DList.DList (Gram label) +pqGrams :: (Prologue.Foldable f, Functor f) => Int -> Int -> (forall b. CofreeF f annotation b -> label) -> Cofree f annotation -> DList.DList (Gram label) pqGrams p q getLabel = uncurry DList.cons . cata merge . setRootBase . setRootStem . hylo go project where go c = cofree (Gram [] [ Just (getLabel c) ] :< (assignParent (Just (getLabel c)) p <$> tailF c)) merge (head :< tail) = let tail' = toList tail in (head, DList.fromList (windowed q setBases [] (fst <$> tail')) <> foldMap snd tail')