1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

DRY up the computation of indexed, feature-assigned lists.

This commit is contained in:
Rob Rix 2016-06-29 10:11:38 -04:00
parent 53cfdb8f15
commit 457082ba6f

View File

@ -28,10 +28,10 @@ rws compare getLabel as bs
replace = (pure .) . Replace replace = (pure .) . Replace
(p, q) = (2, 2) (p, q) = (2, 2)
d = 15 d = 15
fas = zip (featurize <$> as) [0..] fas = featurize as
fbs = zip (featurize <$> bs) [0..] fbs = featurize bs
kdas = KdTree.build (Vector.toList . fst . fst) fas kdas = KdTree.build (Vector.toList . fst . fst) fas
featurize = featureVector d . pqGrams p q getLabel &&& identity featurize a = zip ((featureVector d . pqGrams p q getLabel &&& identity) <$> a) ([0..] :: [Integer])
findNearestNeighbourTo kv@((_, v), i) = do findNearestNeighbourTo kv@((_, v), i) = do
mapped <- get mapped <- get
let ((k, nearest), j) = KdTree.nearest kdas kv let ((k, nearest), j) = KdTree.nearest kdas kv