<commit_before>//
//  QRCoder.swift
//
//  Created by <NAME> on 24/04/15.
//  Copyright (c) 2015 IML. All rights reserved.
//

import Foundation
import QuartzCore

#if os(iOS)
import UIKit
public typealias QRColor = UIColor
public typealias QRImage = UIImage
#elseif os(OSX)    
import AppKit
public typealias QRColor = NSColor
public typealias QRImage = NSImage
#endif

@available(OSX 10.9, *)
@objc
open class QRCodeGenerator : NSObject {
    
    public var backgroundColor:QRColor = QRColor.white
    public var foregroundColor:QRColor = QRColor.black
    public var correctionLevel:CorrectionLevel = .M
    
    public enum CorrectionLevel : String {
        case L = "L"
        case M = "M"
        case Q = "Q"
        case H = "H"
    }
    
    private func outputImageFromFilter(filter:CIFilter) -> CIImage? {
        if #available(OSX 10.10, *) {
            return filter.outputImage
        } else {
            return filter.value(forKey: "outputImage") as? CIImage ?? nil
        }
    }
    
    private func imageWithImageFilter(inputImage:CIImage) -> CIImage? {
        if let colorFilter = CIFilter(name: "CIFalseColor") {
            colorFilter.setDefaults()
            colorFilter.setValue(inputImage, forKey: "inputImage")
            colorFilter.setValue(CIColor(cgColor: foregroundColor.cgColor), forKey: "inputColor0")
            colorFilter.setValue(CIColor(cgColor: backgroundColor.cgColor), forKey: "inputColor1")<commit_msg>Added Convenience initializers<commit_after>//
//  QRCoder.swift
//
//  Created by <NAME> on 24/04/15.
//  Copyright (c) 2015 IML. All rights reserved.
//

import Foundation
import QuartzCore

#if os(iOS)
import UIKit
public typealias QRColor = UIColor
public typealias QRImage = UIImage
#elseif os(OSX)    
import AppKit
public typealias QRColor = NSColor
public typealias QRImage = NSImage
#endif

@available(OSX 10.9, *)
@objc
open class QRCodeGenerator : NSObject {
    
    public var backgroundColor:QRColor
    public var foregroundColor:QRColor
    public var correctionLevel:CorrectionLevel
    
    public enum CorrectionLevel : String {
        case L = "L"
        case M = "M"
        case Q = "Q"
        case H = "H"
    }
    
    public override convenience init(){        
        self.init(backgroundColor: QRColor.white, foregroundColor: QRColor.black, correctionLevel: .M)
    }
    
    public convenience init(backgroundColor:QRColor, foregroundColor:QRColor) {
        self.init(backgroundColor: backgroundColor, foregroundColor: foregroundColor, correctionLevel: .M)
    }
    
    public convenience init(correctionLevel:CorrectionLevel = .M) {
        self.init(backgroundColor: QRColor.white, foregroundColor: QRColor.black, correctionLevel: correctionLevel)
    }
    
    public init(backgroundColor:QRColor, foregroundColor:QRColor, correctionLevel:CorrectionLevel){
        self.backgroundColor = backgroundColor
        self.foregroundColor = foregroundColor
        self.correctionLevel = correctionLevel
    }
    
    private func outputImageFromFilter(filter:CIFilter) -> CIImage? {
        if #available(OSX 10.10, *) {
            return filter.outputImage
        } else {
            return filter.value(forKey: "outputImage") as? CIImage ?? nil
        }
    }
    
    private func imageWithImageFilter(inputImage:CIImage) -> CIImage? {
        if let colorFilter = CIFilter(name: "CIFalseColor") {
            colorFilter.setDefaults()
            colorFilter.setValue(inputImage, forKey: "inputImage")
            colorFilter.setValue(CIColor(cgColor: foregroundColor.cgColor), forKey: "inputColor0")
            colorFilter.setValue(CIColor(cgColor: backgroundColor.cgColor), forKey: "inputColor1")
{'fraction_non_alphanumeric': 0.09267765468792219, 'fraction_numerical': 0.01026749527154823, 'mean_word_length': 3.002162162162162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5265233', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1076, 'n_words': 268}