<commit_before>//
// Xcore
// Copyright © 2017 Xcore
// MIT license, see LICENSE file for details
//

import Foundation

// MARK: - Namespace

public enum Currency {}

// MARK: - SymbolsProvider

extension Currency {
    public typealias SymbolsProvider = CurrencySymbolsProvider
}

public protocol CurrencySymbolsProvider {
    var currencySymbol: String { get }

    /// The character the receiver uses as a grouping separator.
    ///
    /// For example, the grouping separator used in the United States is the comma
    /// (`"10,000"`) whereas in France it is the space (`"10 000"`).
    var groupingSeparator: String { get }

    /// The character the receiver uses as a decimal separator.
    ///
    /// For example, the decimal separator used in the United States is the period
    /// (`"10,000.00"`) whereas in France it is the comma (`"10 000,00"`).
    var decimalSeparator: String { get }
}

// MARK: - SymbolsOptions

extension Currency {
    public struct SymbolsOptions: OptionSet {
        public let rawValue: Int

        public init(rawValue: Int) {
            self.rawValue = rawValue
        }

        public static let currencySymbol = Self(rawValue: 1 << 0)
        public static let groupingSeparator = Self(rawValue: 1 << 1)
        public static let decimalSeparator = Self(rawValue: 1 << 2)
        public static let specialCharacters: Self = [
            currencySymbol,
            groupingSeparator
        ]

        public static let all: Self = [
            currencySymbol,
            groupingSeparator,
            decimalSeparator
        ]
    }
}

// MARK: - String Extension

extension String {
    /// A function to remove specified currency symbols (`$ , .`) from `self`.
    ///
    /// ```swift
    /// $2,000.88 → 200088   // "$2,000.8".trimmingCurrencySymbols(.all)
    /// $2,000.88 → 2,000.88 // "$2,000.8".trimmingCurrencySymbols(.currencySymbol)
    /// $2,000.88 → $2000.88 // "$2,000.8".trimmingCurrencySymbols(.groupingSeparator)
    /// $2,000.88 → $2,00088 // "$2,000.8".trimmingCurrencySymbols(.decimalSeparator)
    /// $2,000.88 → 2000.88  // "$2,000.8".trimmingCurrencySymbols([.currencySymbol, .groupingSeparator])
    /// $2,000.88 → 2000.88  // "$2,000.8".trimmingCurrencySymbols(.specialCharacters)
    /// ```
    public func trimmingCurrencySymbols(_ options: Currency.SymbolsOptions, provider: Currency.SymbolsProvider) -> String {
        guard !options.isEmpty else { return self }

        var pattern = ""

        if options.contains(.currencySymbol) {
            pattern += "\(provider.currencySymbol)"
        }

        if options.contains(.groupingSeparator) {
            pattern += "\(provider.groupingSeparator)"
        }

        if options.contains(.decimalSeparator) {
            pattern += "\(provider.decimalSeparator)"
        }
<commit_msg>Fixed comments<commit_after>//
// Xcore
// Copyright © 2017 Xcore
// MIT license, see LICENSE file for details
//

import Foundation

// MARK: - Namespace

public enum Currency {}

// MARK: - SymbolsProvider

extension Currency {
    public typealias SymbolsProvider = CurrencySymbolsProvider
}

public protocol CurrencySymbolsProvider {
    var currencySymbol: String { get }

    /// The character the receiver uses as a grouping separator.
    ///
    /// For example, the grouping separator used in the United States is the comma
    /// (`"10,000"`) whereas in France it is the space (`"10 000"`).
    var groupingSeparator: String { get }

    /// The character the receiver uses as a decimal separator.
    ///
    /// For example, the decimal separator used in the United States is the period
    /// (`"10,000.00"`) whereas in France it is the comma (`"10 000,00"`).
    var decimalSeparator: String { get }
}

// MARK: - SymbolsOptions

extension Currency {
    public struct SymbolsOptions: OptionSet {
        public let rawValue: Int

        public init(rawValue: Int) {
            self.rawValue = rawValue
        }

        public static let currencySymbol = Self(rawValue: 1 << 0)
        public static let groupingSeparator = Self(rawValue: 1 << 1)
        public static let decimalSeparator = Self(rawValue: 1 << 2)
        public static let specialCharacters: Self = [
            currencySymbol,
            groupingSeparator
        ]

        public static let all: Self = [
            currencySymbol,
            groupingSeparator,
            decimalSeparator
        ]
    }
}

// MARK: - String Extension

extension String {
    /// A function to remove specified currency symbols (`$ , .`) from `self`.
    ///
    /// ```swift
    /// $2,000.88 → 200088   // "$2,000.88".trimmingCurrencySymbols(.all)
    /// $2,000.88 → 2,000.88 // "$2,000.88".trimmingCurrencySymbols(.currencySymbol)
    /// $2,000.88 → $2000.88 // "$2,000.88".trimmingCurrencySymbols(.groupingSeparator)
    /// $2,000.88 → $2,00088 // "$2,000.88".trimmingCurrencySymbols(.decimalSeparator)
    /// $2,000.88 → 2000.88  // "$2,000.88".trimmingCurrencySymbols([.currencySymbol, .groupingSeparator])
    /// $2,000.88 → 2000.88  // "$2,000.88".trimmingCurrencySymbols(.specialCharacters)
    /// ```
    public func trimmingCurrencySymbols(_ options: Currency.SymbolsOptions, provider: Currency.SymbolsProvider) -> String {
        guard !options.isEmpty else { return self }

        var pattern = ""

        if options.contains(.currencySymbol) {
            pattern += "\(provider.currencySymbol)"
        }

        if options.contains(.groupingSeparator) {
            pattern += "\(provider.groupingSeparator)"
        }

        if options.contains(.decimalSeparator) {
            pattern += "\(provider.decimalSeparator)"
        }

{'fraction_non_alphanumeric': 0.12511013215859032, 'fraction_numerical': 0.048986784140969165, 'mean_word_length': 2.4151624548736463, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, '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': '1919253', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1597, 'n_words': 455}