mirror of
https://github.com/github/semantic.git
synced 2024-12-20 13:21:59 +03:00
Replace incomparable terms.
This commit is contained in:
parent
2dde2a5775
commit
be3f43702b
@ -25,6 +25,7 @@ rws compare getLabel as bs
|
|||||||
| otherwise = uncurry deleteRemaining . (`runState` Set.empty) $ traverse findNearestNeighbourTo (featurize <$> bs)
|
| otherwise = uncurry deleteRemaining . (`runState` Set.empty) $ traverse findNearestNeighbourTo (featurize <$> bs)
|
||||||
where insert = pure . Insert
|
where insert = pure . Insert
|
||||||
delete = pure . Delete
|
delete = pure . Delete
|
||||||
|
replace = (pure .) . Replace
|
||||||
(p, q) = (2, 2)
|
(p, q) = (2, 2)
|
||||||
d = 15
|
d = 15
|
||||||
fas = featurize <$> as
|
fas = featurize <$> as
|
||||||
@ -35,11 +36,12 @@ rws compare getLabel as bs
|
|||||||
let (k, nearest) = KdTree.nearest kdas kv
|
let (k, nearest) = KdTree.nearest kdas kv
|
||||||
if k `Set.member` mapped
|
if k `Set.member` mapped
|
||||||
then pure $! insert v
|
then pure $! insert v
|
||||||
else case compare nearest v of
|
else do
|
||||||
Just y -> do
|
put (Set.insert k mapped)
|
||||||
put (Set.insert k mapped)
|
case compare nearest v of
|
||||||
pure y
|
Just y -> do
|
||||||
_ -> pure $! delete v
|
pure y
|
||||||
|
_ -> pure $! replace nearest v
|
||||||
deleteRemaining diff mapped = diff <> (delete . snd <$> filter (not . (`Set.member` mapped) . fst) fas)
|
deleteRemaining diff mapped = diff <> (delete . snd <$> filter (not . (`Set.member` mapped) . fst) fas)
|
||||||
|
|
||||||
data Gram label = Gram { stem :: [Maybe label], base :: [Maybe label] }
|
data Gram label = Gram { stem :: [Maybe label], base :: [Maybe label] }
|
||||||
|
Loading…
Reference in New Issue
Block a user