1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Stub in a decorator assigning feature vectors.

This commit is contained in:
Rob Rix 2016-08-03 14:33:05 -04:00
parent d866df0a3d
commit 8fc465c07c

View File

@ -107,6 +107,10 @@ featureVector d bag = sumVectors $ unitDVector . hash <$> bag
normalize vec = fmap (/ vmagnitude vec) vec normalize vec = fmap (/ vmagnitude vec) vec
sumVectors = DList.foldr (Vector.zipWith (+)) (Vector.replicate d 0) sumVectors = DList.foldr (Vector.zipWith (+)) (Vector.replicate d 0)
featureVectorDecorator :: (Prologue.Foldable f, Functor f) => (forall b. CofreeF f (Record a) b -> label) -> Int -> Int -> Int -> TermDecorator f a (Vector.Vector Double)
featureVectorDecorator getLabel p q d (a :< s) = Vector.replicate d 0
-- | The magnitude of a Euclidean vector, i.e. its distance from the origin. -- | The magnitude of a Euclidean vector, i.e. its distance from the origin.
vmagnitude :: Vector.Vector Double -> Double vmagnitude :: Vector.Vector Double -> Double
vmagnitude = sqrtDouble . Vector.sum . fmap (** 2) vmagnitude = sqrtDouble . Vector.sum . fmap (** 2)