mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Idiomatic record construction.
This commit is contained in:
parent
638d8eda23
commit
8d1fb84ed3
@ -96,7 +96,7 @@ decorateTermWithPQGram q = cata algebra
|
||||
-- | Replaces bags of p,q-grams in a term’s annotations with corresponding feature vectors.
|
||||
decorateTermWithFeatureVector :: (Hashable label, Prologue.Foldable f, Functor f) => Int -> Cofree f (Record (Gram label ': fields)) -> Cofree f (Record (Vector.Vector Double ': fields))
|
||||
decorateTermWithFeatureVector d = cata $ \ (RCons gram rest :< functor) ->
|
||||
cofree (RCons (foldr (Vector.zipWith (+) . getField . extract) (unitVector d (hash gram)) functor) rest :< functor)
|
||||
cofree ((foldr (Vector.zipWith (+) . getField . extract) (unitVector d (hash gram)) functor .: rest) :< functor)
|
||||
|
||||
-- | Computes a unit vector of the specified dimension from a hash.
|
||||
unitVector :: Int -> Int -> Vector.Vector Double
|
||||
|
Loading…
Reference in New Issue
Block a user