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:
parent
a418aa43c0
commit
00f88e540f
19
src/RWS.hs
19
src/RWS.hs
@ -45,7 +45,7 @@ rws' = do
|
|||||||
(featureAs, featureBs, mappedDiffs, allDiffs) <- genFeaturizedTermsAndDiffs' sesDiffs
|
(featureAs, featureBs, mappedDiffs, allDiffs) <- genFeaturizedTermsAndDiffs' sesDiffs
|
||||||
(diffs, remaining) <- findNearestNeighoursToDiff' allDiffs featureAs featureBs
|
(diffs, remaining) <- findNearestNeighoursToDiff' allDiffs featureAs featureBs
|
||||||
diffs' <- deleteRemaining' diffs remaining
|
diffs' <- deleteRemaining' diffs remaining
|
||||||
rwsDiffs <- insertMapped' diffs' mappedDiffs
|
rwsDiffs <- insertMapped' mappedDiffs diffs'
|
||||||
pure (fmap snd rwsDiffs)
|
pure (fmap snd rwsDiffs)
|
||||||
|
|
||||||
ses' :: (HasField fields (Maybe FeatureVector), RWS f fields :< e) => Eff e (RWSEditScript f fields)
|
ses' :: (HasField fields (Maybe FeatureVector), RWS f fields :< e) => Eff e (RWSEditScript f fields)
|
||||||
@ -106,13 +106,18 @@ 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))
|
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 :: Foldable t => t (These Int Int, Diff f fields) -> [(These Int Int, Diff f fields)] -> [(These Int Int, Diff f fields)]
|
||||||
insertMapped = foldl' (\into (i, mappedTerm) -> insertDiff (i, mappedTerm) into)
|
insertMapped diffs into = foldl' (\into (i, mappedTerm) -> insertDiff (i, mappedTerm) into) into diffs
|
||||||
|
|
||||||
deleteRemaining diffs unmappedAs = foldl' (\into (i, deletion) ->
|
deleteRemaining :: (Traversable t)
|
||||||
insertDiff (This i, deletion) into)
|
=> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))]
|
||||||
diffs
|
-> t (RWS.UnmappedTerm f fields)
|
||||||
((termIndex &&& This . term) <$> unmappedAs)
|
-> [(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)
|
||||||
|
|
||||||
-- | Inserts an index and diff pair into a list of indices and diffs.
|
-- | Inserts an index and diff pair into a list of indices and diffs.
|
||||||
insertDiff :: (These Int Int, These (Term f (Record fields)) (Term f (Record fields))) -> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))] -> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))]
|
insertDiff :: (These Int Int, These (Term f (Record fields)) (Term f (Record fields))) -> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))] -> [(These Int Int, These (Term f (Record fields)) (Term f (Record fields)))]
|
||||||
|
Loading…
Reference in New Issue
Block a user