From bf3b8fdc3f7042b7c91caa4c9517d80827fcddd5 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 9 Aug 2016 16:00:19 -0400 Subject: [PATCH] :fire: decorateTermWithPGram. --- src/Data/RandomWalkSimilarity.hs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Data/RandomWalkSimilarity.hs b/src/Data/RandomWalkSimilarity.hs index f3e1b47d2..60dde3057 100644 --- a/src/Data/RandomWalkSimilarity.hs +++ b/src/Data/RandomWalkSimilarity.hs @@ -75,13 +75,6 @@ featureVector d bag = sumVectors $ unitVector d . hash <$> bag decorateTermWithLabel :: Functor f => (forall b. CofreeF f (Record fields) b -> label) -> Cofree f (Record fields) -> Cofree f (Record (label ': fields)) decorateTermWithLabel getLabel = cata $ \ c -> cofree ((getLabel c .: headF c) :< tailF c) --- | Replaces labels in a term’s annotations with corresponding p,1-grams. -decorateTermWithPGram :: Functor f => Int -> Cofree f (Record (label ': fields)) -> Cofree f (Record (Gram label ': fields)) -decorateTermWithPGram p = ana coalgebra . (,) [] - where coalgebra :: Functor f => ([Maybe label], Cofree f (Record (label ': fields))) -> CofreeF f (Record (Gram label ': fields)) ([Maybe label], Cofree f (Record (label ': fields))) - coalgebra (parentLabels, c) = case extract c of - RCons label rest -> (Gram (padToSize p parentLabels) (pure (Just label)) .: rest) :< fmap ((,) (padToSize p (Just label : parentLabels))) (unwrap c) - -- | Replaces labels in a term’s annotations with corresponding p,q-grams. decorateTermWithPQGram :: Traversable f => Int -> Int -> Cofree f (Record (label ': fields)) -> Cofree f (Record (Gram label ': fields)) decorateTermWithPQGram p q = cata algebra