1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Reindent collect & addSubtermVector.

This commit is contained in:
Rob Rix 2017-10-27 10:26:10 -04:00
parent 2ed2b65cd0
commit d42c33ca5b

View File

@ -127,10 +127,10 @@ defaultFeatureVectorDecorator getLabel = featureVectorDecorator . pqGramDecorato
-- | 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 = cata collect
where collect :: (Foldable f, Functor f, Hashable label) => TermF f (Record (Gram label ': fields)) (Term f (Record (FeatureVector ': fields))) -> Term f (Record (FeatureVector ': fields))
collect (In (gram :. rest) functor) = termIn (foldl' addSubtermVector (unitVector (hash gram)) functor :. rest) functor
addSubtermVector :: Functor f => FeatureVector -> Term f (Record (FeatureVector ': fields)) -> FeatureVector
addSubtermVector v term = addVectors v (rhead (extract term))
where collect :: (Foldable f, Functor f, Hashable label) => TermF f (Record (Gram label ': fields)) (Term f (Record (FeatureVector ': fields))) -> Term f (Record (FeatureVector ': fields))
collect (In (gram :. rest) functor) = termIn (foldl' addSubtermVector (unitVector (hash gram)) functor :. rest) functor
addSubtermVector :: Functor f => FeatureVector -> Term f (Record (FeatureVector ': fields)) -> FeatureVector
addSubtermVector v term = addVectors v (rhead (extract term))
-- | Annotates a term with the corresponding p,q-gram at each node.
pqGramDecorator