mirror of
https://github.com/github/semantic.git
synced 2025-01-03 13:02:37 +03:00
RWS uses compare instead of constructing insertions/deletions itself.
This commit is contained in:
parent
ef2715f4f0
commit
8237a6aafd
@ -56,8 +56,8 @@ rws :: forall f fields.
|
|||||||
-> [Diff f (Record fields)] -- ^ The resulting list of similarity-matched diffs.
|
-> [Diff f (Record fields)] -- ^ The resulting list of similarity-matched diffs.
|
||||||
rws compare canCompare as bs
|
rws compare canCompare as bs
|
||||||
| null as, null bs = []
|
| null as, null bs = []
|
||||||
| null as = inserting . eraseFeatureVector <$> bs
|
| null as = compare . That . eraseFeatureVector <$> bs
|
||||||
| null bs = deleting . eraseFeatureVector <$> as
|
| null bs = compare . This . eraseFeatureVector <$> as
|
||||||
| otherwise =
|
| otherwise =
|
||||||
-- Construct a State who's final value is a list of (Int, Diff leaf (Record fields))
|
-- Construct a State who's final value is a list of (Int, Diff leaf (Record fields))
|
||||||
-- and who's final state is (Int, IntMap UmappedTerm, IntMap UmappedTerm)
|
-- and who's final state is (Int, IntMap UmappedTerm, IntMap UmappedTerm)
|
||||||
@ -124,7 +124,7 @@ rws compare canCompare as bs
|
|||||||
(These Int Int, Diff f (Record fields))
|
(These Int Int, Diff f (Record fields))
|
||||||
insertion previous unmappedA unmappedB (UnmappedTerm j _ b) = do
|
insertion previous unmappedA unmappedB (UnmappedTerm j _ b) = do
|
||||||
put (previous, unmappedA, IntMap.delete j unmappedB)
|
put (previous, unmappedA, IntMap.delete j unmappedB)
|
||||||
pure (That j, inserting b)
|
pure (That j, compare (That b))
|
||||||
|
|
||||||
-- | Finds the most-similar unmapped term to the passed-in term, if any.
|
-- | Finds the most-similar unmapped term to the passed-in term, if any.
|
||||||
--
|
--
|
||||||
@ -151,7 +151,7 @@ rws compare canCompare as bs
|
|||||||
deleteRemaining diffs (_, unmappedA, _) = foldl' (\into (i, deletion) ->
|
deleteRemaining diffs (_, unmappedA, _) = foldl' (\into (i, deletion) ->
|
||||||
insertDiff (This i, deletion) into)
|
insertDiff (This i, deletion) into)
|
||||||
diffs
|
diffs
|
||||||
((termIndex &&& deleting . term) <$> unmappedA)
|
((termIndex &&& compare . This . term) <$> unmappedA)
|
||||||
|
|
||||||
-- Possibly replace terms in a diff.
|
-- Possibly replace terms in a diff.
|
||||||
replaceIfEqual :: Term f (Record fields) -> Term f (Record fields) -> Maybe (Diff f (Record fields))
|
replaceIfEqual :: Term f (Record fields) -> Term f (Record fields) -> Maybe (Diff f (Record fields))
|
||||||
|
Loading…
Reference in New Issue
Block a user