<commit_before>//
//  Lempel.swift
//  Lempel
//
//  Created by <NAME> on 17/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import zlib

struct LempelSettings {
    static let chunkSize: Int32 = 1024
    static let defaultMemoryLevel: Int32 = 8
    static let defaultWindowsBits: Int32 = 15
    static let defaultWindowsBitsWithGZipHeader = 16 + LempelSettings.defaultWindowsBits
}

enum LempelError: ErrorType {
    case DataError(msg: String)
    case GzipError(msg: String)
    case SystemError(msg: String)
    
    private init(code: Int32) {
        let msg: String
        switch code {
        case Z_STREAM_ERROR:
            msg = "Stream Error: he stream structure was inconsistent (for example if next_in or next_out was NULL)"
            
        case Z_DATA_ERROR:
            msg = "Data Error: The input data was corrupted (input stream not conforming to the zlib format or incorrect check value)"
            
        case Z_MEM_ERROR:
            msg = "Mem Error: There was not enough memory."
            
        case Z_BUF_ERROR:
            msg = "Buf Error: No progress is possible or there was not enough room in the output buffer when Z_FINISH is used."
            
        case Z_VERSION_ERROR:
            msg = "Version Error"
            
        default:
            msg = "Unknown Error"
        }
        self = LempelError.GzipError(msg: "Error inflating Payload: \(msg)")
    }
}

extension NSData {
    func decompressGzip(windowBits: Int32 = LempelSettings.defaultWindowsBitsWithGZipHeader) throws -> NSData {<commit_msg>Added public<commit_after>//
//  Lempel.swift
//  Lempel
//
//  Created by <NAME> on 17/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import zlib

struct LempelSettings {
    static let chunkSize: Int32 = 1024
    static let defaultMemoryLevel: Int32 = 8
    static let defaultWindowsBits: Int32 = 15
    static let defaultWindowsBitsWithGZipHeader = 16 + LempelSettings.defaultWindowsBits
}

public enum LempelError: ErrorType {
    case DataError(msg: String)
    case GzipError(msg: String)
    case SystemError(msg: String)
    
    private init(code: Int32) {
        let msg: String
        switch code {
        case Z_STREAM_ERROR:
            msg = "Stream Error: he stream structure was inconsistent (for example if next_in or next_out was NULL)"
            
        case Z_DATA_ERROR:
            msg = "Data Error: The input data was corrupted (input stream not conforming to the zlib format or incorrect check value)"
            
        case Z_MEM_ERROR:
            msg = "Mem Error: There was not enough memory."
            
        case Z_BUF_ERROR:
            msg = "Buf Error: No progress is possible or there was not enough room in the output buffer when Z_FINISH is used."
            
        case Z_VERSION_ERROR:
            msg = "Version Error"
            
        default:
            msg = "Unknown Error"
        }
        self = LempelError.GzipError(msg: "Error inflating Payload: \(msg)")
    }
}

public extension NSData {
    public func decompressGzip(windowBits: Int32 = LempelSettings.defaultWindowsBitsWithGZipHeader) throws -> NSData {
{'fraction_non_alphanumeric': 0.07053682896379526, 'fraction_numerical': 0.018102372034956304, 'mean_word_length': 2.300720906282183, 'pattern_counts': {'":': 0, '<': 7, '<?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': '68713', 'n_tokens_mistral': 945, 'n_tokens_neox': 880, 'n_words': 318}