mirror of
https://github.com/github/semantic.git
synced 2024-12-20 21:31:48 +03:00
Assign parents.
This commit is contained in:
parent
c1f1fb71c9
commit
fa760d7ae1
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user