mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Generalize featureVectorDecorator to accept any Hashable label.
This commit is contained in:
parent
2c561be63f
commit
99f3633060
@ -125,9 +125,9 @@ defaultFeatureVectorDecorator
|
|||||||
defaultFeatureVectorDecorator getLabel = featureVectorDecorator . pqGramDecorator getLabel defaultP defaultQ
|
defaultFeatureVectorDecorator getLabel = featureVectorDecorator . pqGramDecorator getLabel defaultP defaultQ
|
||||||
|
|
||||||
-- | Annotates a term with a feature vector at each node, parameterized by stem length, base width, and feature vector dimensions.
|
-- | Annotates a term with a feature vector at each node, parameterized by stem length, base width, and feature vector dimensions.
|
||||||
featureVectorDecorator :: (Foldable f, Functor f, Hashable label) => Term f (Record (Gram label ': fields)) -> Term f (Record (FeatureVector ': fields))
|
featureVectorDecorator :: (Foldable f, Functor f, Hashable label) => Term f (Record (label ': fields)) -> Term f (Record (FeatureVector ': fields))
|
||||||
featureVectorDecorator = cata (\ (In (gram :. rest) functor) ->
|
featureVectorDecorator = cata (\ (In (label :. rest) functor) ->
|
||||||
termIn (foldl' addSubtermVector (unitVector (hash gram)) functor :. rest) functor)
|
termIn (foldl' addSubtermVector (unitVector (hash label)) functor :. rest) functor)
|
||||||
where addSubtermVector v term = addVectors v (rhead (termAnnotation term))
|
where addSubtermVector v term = addVectors v (rhead (termAnnotation term))
|
||||||
|
|
||||||
-- | Annotates a term with the corresponding p,q-gram at each node.
|
-- | Annotates a term with the corresponding p,q-gram at each node.
|
||||||
|
Loading…
Reference in New Issue
Block a user