mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Pad the base at the root.
This commit is contained in:
parent
ea950d1953
commit
46f4ca93c3
@ -99,7 +99,7 @@ decorateTermWithPGram p = futu coalgebra . (,) []
|
||||
RCons label rest -> (Gram (padToSize p parentLabels) (pure (Just label)) .: rest) :< fmap (pure . (,) (take p (Just label : parentLabels))) (unwrap c)
|
||||
|
||||
decorateTermWithBagOfPQGrams :: (Typeable label, Prologue.Foldable f, Functor f) => Int -> Cofree f (Record (Gram label ': fields)) -> Cofree f (Record (DList.DList (Gram label) ': fields))
|
||||
decorateTermWithBagOfPQGrams q = fmap (\ (RCons (first, rest) t) -> DList.cons first rest .: t) . cata algebra
|
||||
decorateTermWithBagOfPQGrams q = fmap (\ (RCons (first, rest) t) -> DList.cons (first { base = padToSize q (base first) }) rest .: t) . cata algebra
|
||||
where algebra :: (Prologue.Foldable f, Functor f) => CofreeF f (Record (Gram label ': fields)) (Cofree f (Record ((Gram label, DList.DList (Gram label)) ': fields))) -> Cofree f (Record ((Gram label, DList.DList (Gram label)) ': fields))
|
||||
algebra (RCons gram rest :< functor) = cofree (((gram, DList.fromList (windowed q setBases [] (fst . getGrams . extract <$> toList functor)) <> foldMap (snd . getGrams . extract) functor) .: rest) :< functor)
|
||||
setBases :: Gram label -> [Gram label] -> [Gram label] -> [Gram label]
|
||||
|
Loading…
Reference in New Issue
Block a user