1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Reverse the order of insertMapped arguments

This commit is contained in:
joshvera 2017-04-11 17:10:08 -04:00
parent a418aa43c0
commit 00f88e540f

View File

@ -45,7 +45,7 @@ rws' = do
(featureAs, featureBs, mappedDiffs, allDiffs) <- genFeaturizedTermsAndDiffs' sesDiffs
(diffs, remaining) <- findNearestNeighoursToDiff' allDiffs featureAs featureBs
diffs' <- deleteRemaining' diffs remaining
rwsDiffs <- insertMapped' diffs' mappedDiffs
rwsDiffs <- insertMapped' mappedDiffs diffs'
pure (fmap snd rwsDiffs)
ses' :: (HasField fields (Maybe FeatureVector), RWS f fields :< e) => Eff e (RWSEditScript f fields)
@ -106,11 +106,16 @@ run editDistance canCompare as bs = relay pure (\m k -> case m of
type Diff f fields = These (Term f (Record fields)) (Term f (Record fields))
insertMapped :: Foldable t => [(These Int Int, Diff f fields)] -> t (These Int Int, Diff f fields) -> [(These Int Int, Diff f fields)]
insertMapped = foldl' (\into (i, mappedTerm) -> insertDiff (i, mappedTerm) into)
insertMapped :: Foldable t => t (These Int Int, Diff f fields) -> [(These Int Int, Diff f fields)] -> [(These Int Int, Diff f fields)]
insertMapped diffs into = foldl' (\into (i, mappedTerm) -> insertDiff (i, mappedTerm) into) into diffs
deleteRemaining diffs unmappedAs = foldl' (\into (i, deletion) ->
insertDiff (This i, deletion) into)
deleteRemaining :: (Traversable t)
=> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))]
-> t (RWS.UnmappedTerm f fields)
-> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))]
deleteRemaining diffs unmappedAs =
foldl'
(\into (i, deletion) -> insertDiff (This i, deletion) into)
diffs
((termIndex &&& This . term) <$> unmappedAs)