<commit_before>/**
 *  Unbox
 *  Copyright (c) 2015-2017 <NAME>
 *  Licensed under the MIT license, see LICENSE file
 */

import Foundation

internal extension Sequence {
    func map<T>(allowInvalidElements: Bool, transform: (Iterator.Element) throws -> T) throws -> [T] {
        if !allowInvalidElements {
            return try self.map(transform)
        }

        return self.flatMap {
            return try? transform($0)
        }
    }
}<commit_msg>Replace deprecated flatMap with compactMap<commit_after>/**
 *  Unbox
 *  Copyright (c) 2015-2017 <NAME>
 *  Licensed under the MIT license, see LICENSE file
 */

import Foundation

internal extension Sequence {
    func map<T>(allowInvalidElements: Bool, transform: (Iterator.Element) throws -> T) throws -> [T] {
        if !allowInvalidElements {
            return try self.map(transform)
        }

        return compactMap {
            return try? transform($0)
        }
    }
}
{'fraction_non_alphanumeric': 0.10454065469904963, 'fraction_numerical': 0.01900739176346357, 'mean_word_length': 2.511111111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2733238', 'n_tokens_mistral': 280, 'n_tokens_neox': 259, 'n_words': 80}