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:
parent
6e1a7957ec
commit
1a35975c4f
@ -22,12 +22,13 @@ rws compare getLabel as bs
|
|||||||
| null as, null bs = []
|
| null as, null bs = []
|
||||||
| null as = insert <$> bs
|
| null as = insert <$> bs
|
||||||
| null bs = delete <$> as
|
| null bs = delete <$> as
|
||||||
| otherwise = uncurry deleteRemaining . (`runState` []) $ traverse findNearestNeighbourTo (featurize <$> bs)
|
| otherwise = uncurry deleteRemaining . (`runState` []) $ traverse findNearestNeighbourTo fbs
|
||||||
where insert = pure . Insert
|
where insert = pure . Insert
|
||||||
delete = pure . Delete
|
delete = pure . Delete
|
||||||
replace = (pure .) . Replace
|
replace = (pure .) . Replace
|
||||||
(p, q, d) = (2, 2, 15)
|
(p, q, d) = (2, 2, 15)
|
||||||
fas = featurize <$> as
|
fas = featurize <$> as
|
||||||
|
fbs = featurize <$> bs
|
||||||
kdas = KdTree.build (Vector.toList . fst) fas
|
kdas = KdTree.build (Vector.toList . fst) fas
|
||||||
featurize = featureVector d . pqGrams p q getLabel &&& identity
|
featurize = featureVector d . pqGrams p q getLabel &&& identity
|
||||||
findNearestNeighbourTo kv@(_, v) = do
|
findNearestNeighbourTo kv@(_, v) = do
|
||||||
|
Loading…
Reference in New Issue
Block a user