<commit_before>//
//  NSMutableAttributedString+.swift
//  MyKit
//
//  Created by <NAME> on 10/15/15.
//
//

public extension NSMutableAttributedString {

    private var range: NSRange { return NSMakeRange(0, self.length) }

    #if os(iOS)
        public func addFontAttribute(value: UIFont?, range: NSRange? = nil) {
            self.addFontAttribute(value, range)
        }

        public func addColorAttribute(value: UIColor?, range: NSRange? = nil) {
            self.addColorAttribute(value, range)
        }
    #elseif os(OSX)
        public func addFontAttribute(value: NSFont?, range: NSRange? = nil) {
            self.addFontAttribute(value, range)
        }

        public func addColorAttribute(value: NSColor?, range: NSRange? = nil) {
            self.addColorAttribute(value, range)
        }
    #endif

    private func addFontAttribute(value: AnyObject?, _ range: NSRange?) {
        guard let _value = value else { return }
        self.addAttribute(NSFontAttributeName, value: _value, range: range ?? self.range)
    }

    private func addColorAttribute(value: AnyObject?, _ range: NSRange?) {
        guard let _value = value else { return }
        self.addAttribute(NSForegroundColorAttributeName, value: _value, range: range ?? self.range)
    }

    public func addAlignmentAttribute(value: NSTextAlignment, range: NSRange?) {
        let paragraph = NSMutableParagraphStyle()
        paragraph.alignment = value

        self.addParagraphAttribute(paragraph, range: range)
    }

    public func addParagraphAttribute(value: NSParagraphStyle, range: NSRange?) {
        self.addAttribute(NSParagraphStyleAttributeName, value: value, range: range ?? self.range)
    }

    public func addBaselineAttribute(value: Float, range: NSRange?) {
        self.addAttribute(NSBaselineOffsetAttributeName, value: NSNumber(float: value), range: range ?? self.range)
    }

    public func addKernAttribute(value: Float, range: NSRange?) {
        self.addAttribute(NSKernAttributeName, value: NSNumber(float: value), range: range ?? self.range)
    }
}

public func + (lhs: NSMutableAttributedString, rhs: NSMutableAttributedString) -> NSMutableAttributedString {
    return NSMutableAttributedString(attributedString: lhs).then { $0.appendAttributedString(rhs) }
}<commit_msg>Fixed NSMutableAttributedString+<commit_after>//
//  NSMutableAttributedString+.swift
//  MyKit
//
//  Created by <NAME> on 10/15/15.
//
//

public extension NSMutableAttributedString {

    private var range: NSRange { return NSMakeRange(0, self.length) }

    #if os(iOS)
        public func addFontAttribute(value: UIFont?, range: NSRange? = nil) {
            self.addFontAttribute(value, range)
        }

        public func addColorAttribute(value: UIColor?, range: NSRange? = nil) {
            self.addColorAttribute(value, range)
        }
    #elseif os(OSX)
        public func addFontAttribute(value: NSFont?, range: NSRange? = nil) {
            self.addFontAttribute(value, range)
        }

        public func addColorAttribute(value: NSColor?, range: NSRange? = nil) {
            self.addColorAttribute(value, range)
        }
    #endif

    private func addFontAttribute(value: AnyObject?, _ range: NSRange?) {
        guard let _value = value else { return }
        self.addAttribute(NSFontAttributeName, value: _value, range: range ?? self.range)
    }

    private func addColorAttribute(value: AnyObject?, _ range: NSRange?) {
        guard let _value = value else { return }
        self.addAttribute(NSForegroundColorAttributeName, value: _value, range: range ?? self.range)
    }

    public func addAlignmentAttribute(value: NSTextAlignment, range: NSRange?) {
        let paragraph = NSMutableParagraphStyle()
        paragraph.alignment = value

        self.addParagraphAttribute(paragraph, range: range)
    }

    public func addParagraphAttribute(value: NSParagraphStyle, range: NSRange?) {
        self.addAttribute(NSParagraphStyleAttributeName, value: value, range: range ?? self.range)
    }

    public func addBaselineAttribute(value: Float, range: NSRange?) {
        self.addAttribute(NSBaselineOffsetAttributeName, value: NSNumber(float: value), range: range ?? self.range)
    }

    public func addKernAttribute(value: Float, range: NSRange?) {
        self.addAttribute(NSKernAttributeName, value: NSNumber(float: value), range: range ?? self.range)
    }
}

public func + (lhs: NSMutableAttributedString, rhs: NSMutableAttributedString) -> NSMutableAttributedString {
    return NSMutableAttributedString(attributedString: lhs).then {
        $0.appendAttributedString(rhs)
    }
}
{'fraction_non_alphanumeric': 0.10304601425793908, 'fraction_numerical': 0.0034564700799308706, 'mean_word_length': 3.3433395872420264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4433641', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1299, 'n_words': 317}