<commit_before>//  Copyright (c) 2015 <NAME>. All rights reserved.

public struct DictionaryDifferentiator<Key: Hashable, Value: Equatable> {
	public static func differentiate(#before: Dictionary<Key, Value>, after: Dictionary<Key, Value>) -> UnorderedDifferential<(Key, Value)> {
		let (beforeKeys, afterKeys) = (Set(before.keys), Set(after.keys))
		let changedKeys = Set(lazy(beforeKeys.intersect(afterKeys))
			.filter { before[$0] != after[$0] })

		return UnorderedDifferential(inserted: after[afterKeys.subtract(beforeKeys).union(changedKeys)], deleted: before[beforeKeys.subtract(afterKeys).union(changedKeys)])
	}
}<commit_msg>Dictionary differentials are computed parameterized by equality.<commit_after>//  Copyright (c) 2015 <NAME>. All rights reserved.

public struct DictionaryDifferentiator<Key: Hashable, Value: Equatable> {
	public static func differentiate(#before: Dictionary<Key, Value>, after: Dictionary<Key, Value>, equals: (Value, Value) -> Bool) -> UnorderedDifferential<(Key, Value)> {
		let (beforeKeys, afterKeys) = (Set(before.keys), Set(after.keys))
		let changedKeys = Set(lazy(beforeKeys.intersect(afterKeys))
			.filter { !((before[$0] &&& after[$0]).map(equals) ?? (before[$0] == nil && after[$0] == nil)) })

		return UnorderedDifferential(inserted: after[afterKeys.subtract(beforeKeys).union(changedKeys)], deleted: before[beforeKeys.subtract(afterKeys).union(changedKeys)])
	}
}


import Prelude
{'fraction_non_alphanumeric': 0.15164220824598182, 'fraction_numerical': 0.009783368273934312, 'mean_word_length': 6.911602209944752, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2756419', 'n_tokens_mistral': 456, 'n_tokens_neox': 418, 'n_words': 98}