From fa760d7ae10331157ca559042962ac018a582bd4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 22 Jun 2016 10:13:25 -0400 Subject: [PATCH] Assign parents. --- src/Data/Gram.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Data/Gram.hs b/src/Data/Gram.hs index 21aa86c2f..f8d790c3f 100644 --- a/src/Data/Gram.hs +++ b/src/Data/Gram.hs @@ -16,7 +16,9 @@ serialize gram = stem gram <> base gram pqGrams :: Foldable.Foldable tree => Int -> Int -> (forall a. Base tree a -> (label, [a])) -> tree -> Bag (Gram label) pqGrams p q unpack = foldr (<>) empty . snd . cata go - where go functor = let (label, children) = unpack functor in (label, []) + where go functor = let (label, children) = unpack functor in + (label, children >>= assignParent label) + assignParent parentLabel (label, children) = DList.singleton (Gram [ parentLabel ] [ label ]) : children type Bag = DList.DList