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

public struct PredicateSet<Element: Hashable> {
	public let predicate: Element -> Bool
	
	public init() {
		predicate = { _ in false }
	}
	
	public init(_ predicate: Element -> Bool) {
		self.predicate = predicate
	}
	
	public init<T>(_ predicate: Element -> T?) {
		self.predicate = { element in
			return predicate(element) != nil
		}
	}
	
	public init(_ set: Set<Element>) {
		predicate = { set.contains($0) }
	}
	
	public init(_ set: Multiset<Element>) {
		predicate = { set.contains($0) }
	}

	public func contains(element: Element) -> Bool {
		return predicate(element)
	}
	
	public func union(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) || set.contains($0) }
	}
	
	public func intersection(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) && set.contains($0) }
	}
	
	public func complement(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) && !set.contains($0) }
	}
	
	public func difference(set: PredicateSet) -> PredicateSet {
		return PredicateSet { !(self.predicate($0) && set.contains($0)) }
	}
}

public func +<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.union(rhs)
}

public func -<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.difference(rhs)
}

public func &<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.intersection(rhs)
}<commit_msg>Documentation.<commit_after>//  Copyright (c) 2015 <NAME>. All rights reserved.

public struct PredicateSet<Element: Hashable> {
	// MARK: Constructors
	
	/// Constructs an empty `PredicateSet`.
	public init() {
		predicate = { _ in false }
	}
	
	/// Constructs a `PredicateSet` from a boolean predicate.
	public init(_ predicate: Element -> Bool) {
		self.predicate = predicate
	}
	
	/// Constructs a `PredicateSet` from an optional predicate.
	public init<T>(_ predicate: Element -> T?) {
		self.predicate = { element in
			return predicate(element) != nil
		}
	}
	
	/// Constructs a `PredicateSet` from a `Set`.
	public init(_ set: Set<Element>) {
		predicate = { set.contains($0) }
	}
	
	/// Constructs a `PredicateSet` from a `Multiset`.
	public init(_ set: Multiset<Element>) {
		predicate = { set.contains($0) }
	}
	
	// MARK: Properties
	
	// The set's predicate.
	public let predicate: Element -> Bool
	
	// MARK: Primitive operations
	
	/// True iff predicate is true for `element`. (In other words, whether `element` is contained within the possibly infinite PredicateSet.)
	public func contains(element: Element) -> Bool {
		return predicate(element)
	}
	
	// MARK: Algebraic operations
	
	/// Returns the union of the receiver and `set`.
	public func union(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) || set.contains($0) }
	}
	
	/// Returns the intersection of the receiver and `set`.
	public func intersection(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) && set.contains($0) }
	}
	
	/// Returns the relative complement of the receiver and `set`.
	public func complement(set: PredicateSet) -> PredicateSet {
		return PredicateSet { self.predicate($0) && !set.contains($0) }
	}
	
	/// Returns the symmetric difference of the receiver and `set`.
	public func difference(set: PredicateSet) -> PredicateSet {
		return PredicateSet { !(self.predicate($0) && set.contains($0)) }
	}
}


// MARK: - Operators

/// Returns the union of `lhs` and `rhs`.
public func +<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.union(rhs)
}

/// Returns the symmetric difference of `lhs` and `rhs`.
public func -<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.difference(rhs)
}

/// Returns the intersection of `lhs` and `rhs`.
public func &<T>(lhs: PredicateSet<T>, rhs: PredicateSet<T>) -> PredicateSet<T> {
	return lhs.intersection(rhs)
}
{'fraction_non_alphanumeric': 0.14565053898220107, 'fraction_numerical': 0.007019303083479569, 'mean_word_length': 3.883720930232558, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 59, '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': '6236221', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1291, 'n_words': 364}