1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Define padToSize in pqGramDecorator.

This commit is contained in:
Rob Rix 2016-08-09 16:09:23 -04:00
parent 89aa3dc96e
commit 50c52af354

View File

@ -83,6 +83,7 @@ pqGramDecorator getLabel p q = cata algebra
pure $! cofree ((gram { stem = padToSize p (Just label : stem gram), base = padToSize q labels } .: rest) :< functor)
siblingLabels :: Traversable f => f (Cofree f (Record (Gram label ': fields))) -> [Maybe label]
siblingLabels = foldMap (base . rhead . extract)
padToSize n list = take n (list <> repeat empty)
-- | Computes a unit vector of the specified dimension from a hash.
unitVector :: Int -> Int -> Vector.Vector Double
@ -97,10 +98,6 @@ featureVectorDecorator getLabel p q d
cofree ((foldr (Vector.zipWith (+) . getField . extract) (unitVector d (hash gram)) functor .: rest) :< functor))
. pqGramDecorator getLabel p q
-- | Pads a list of Alternative values to exactly n elements.
padToSize :: Alternative f => Int -> [f a] -> [f a]
padToSize n list = take n (list <> repeat empty)
-- Instances