mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Swap the d/bag arguments in featureVector.
This commit is contained in:
parent
6c8ee2958a
commit
ed552da2af
@ -56,8 +56,8 @@ windowed n f seed = para alg
|
||||
type Bag = DList.DList
|
||||
|
||||
|
||||
featureVector :: Hashable label => Bag (Gram label) -> Int -> Vector.Vector Double
|
||||
featureVector bag d = sumVectors $ unitDVector . hash <$> bag
|
||||
featureVector :: Hashable label => Int -> Bag (Gram label) -> Vector.Vector Double
|
||||
featureVector d bag = sumVectors $ unitDVector . hash <$> bag
|
||||
where unitDVector hash = normalize . (`evalRand` mkQCGen hash) $ Prologue.sequence (Vector.replicate d getRandom)
|
||||
normalize vec = fmap (/ vmagnitude vec) vec
|
||||
sumVectors = DList.foldr (Vector.zipWith (+)) (Vector.replicate d 0)
|
||||
|
@ -23,4 +23,4 @@ spec = parallel $ do
|
||||
|
||||
describe "featureVector" $ do
|
||||
prop "produces a vector of the specified dimension" . forAll (arbitrary `suchThat` ((> 0) . snd)) $
|
||||
\ (grams, d) -> length (featureVector (fromList (grams :: [Gram String])) d) `shouldBe` d
|
||||
\ (grams, d) -> length (featureVector d (fromList (grams :: [Gram String]))) `shouldBe` d
|
||||
|
Loading…
Reference in New Issue
Block a user