mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +03:00
Generalize genFeaturizedTermsAndDiffs over the record types.
This commit is contained in:
parent
5d09c824fe
commit
bf0b959df1
@ -214,9 +214,9 @@ insertion previous unmappedA unmappedB (UnmappedTerm j _ b) = do
|
||||
put (previous, unmappedA, IntMap.delete j unmappedB)
|
||||
pure (That j, That b)
|
||||
|
||||
genFeaturizedTermsAndDiffs :: (Functor syntax, HasField fields FeatureVector)
|
||||
=> RWSEditScript syntax (Record fields) (Record fields)
|
||||
-> ([UnmappedTerm syntax (Record fields)], [UnmappedTerm syntax (Record fields)], [MappedDiff syntax (Record fields) (Record fields)], [TermOrIndexOrNone (UnmappedTerm syntax (Record fields))])
|
||||
genFeaturizedTermsAndDiffs :: (Functor syntax, HasField fields1 FeatureVector, HasField fields2 FeatureVector)
|
||||
=> RWSEditScript syntax (Record fields1) (Record fields2)
|
||||
-> ([UnmappedTerm syntax (Record fields1)], [UnmappedTerm syntax (Record fields2)], [MappedDiff syntax (Record fields1) (Record fields2)], [TermOrIndexOrNone (UnmappedTerm syntax (Record fields2))])
|
||||
genFeaturizedTermsAndDiffs sesDiffs = let Mapping _ _ a b c d = foldl' combine (Mapping 0 0 [] [] [] []) sesDiffs in (reverse a, reverse b, reverse c, reverse d)
|
||||
where combine (Mapping counterA counterB as bs mappedDiffs allDiffs) diff = case diff of
|
||||
This term -> Mapping (succ counterA) counterB (featurize counterA term : as) bs mappedDiffs (None : allDiffs)
|
||||
|
Loading…
Reference in New Issue
Block a user