From 99f36330601848fd7847bc012e516c81767ab372 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Dec 2017 17:00:40 -0500 Subject: [PATCH] Generalize featureVectorDecorator to accept any Hashable label. --- src/Diffing/Algorithm/RWS.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Diffing/Algorithm/RWS.hs b/src/Diffing/Algorithm/RWS.hs index 542638dd9..d39fa8e26 100644 --- a/src/Diffing/Algorithm/RWS.hs +++ b/src/Diffing/Algorithm/RWS.hs @@ -125,9 +125,9 @@ defaultFeatureVectorDecorator defaultFeatureVectorDecorator getLabel = featureVectorDecorator . pqGramDecorator getLabel defaultP defaultQ -- | Annotates a term with a feature vector at each node, parameterized by stem length, base width, and feature vector dimensions. -featureVectorDecorator :: (Foldable f, Functor f, Hashable label) => Term f (Record (Gram label ': fields)) -> Term f (Record (FeatureVector ': fields)) -featureVectorDecorator = cata (\ (In (gram :. rest) functor) -> - termIn (foldl' addSubtermVector (unitVector (hash gram)) functor :. rest) functor) +featureVectorDecorator :: (Foldable f, Functor f, Hashable label) => Term f (Record (label ': fields)) -> Term f (Record (FeatureVector ': fields)) +featureVectorDecorator = cata (\ (In (label :. rest) functor) -> + termIn (foldl' addSubtermVector (unitVector (hash label)) functor :. rest) functor) where addSubtermVector v term = addVectors v (rhead (termAnnotation term)) -- | Annotates a term with the corresponding p,q-gram at each node.