1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 21:01:35 +03:00

Memoize the feature vector computation for bs.

This commit is contained in:
Rob Rix 2016-06-30 12:19:01 -04:00
parent 6e1a7957ec
commit 1a35975c4f

View File

@ -22,12 +22,13 @@ rws compare getLabel as bs
| null as, null bs = []
| null as = insert <$> bs
| null bs = delete <$> as
| otherwise = uncurry deleteRemaining . (`runState` []) $ traverse findNearestNeighbourTo (featurize <$> bs)
| otherwise = uncurry deleteRemaining . (`runState` []) $ traverse findNearestNeighbourTo fbs
where insert = pure . Insert
delete = pure . Delete
replace = (pure .) . Replace
(p, q, d) = (2, 2, 15)
fas = featurize <$> as
fbs = featurize <$> bs
kdas = KdTree.build (Vector.toList . fst) fas
featurize = featureVector d . pqGrams p q getLabel &&& identity
findNearestNeighbourTo kv@(_, v) = do