<commit_before>//
//  Cypher.swift
//  Theo
//
//  Created by <NAME> on 10/7/14.
//  Copyright (c) 2014 Theo. All rights reserved.
//

import Foundation

let TheoCypherColumns: String = "columns"
let TheoCypherData: String    = "data"

public struct CypherMeta: Printable {
    
    let columns: Array<String> = Array<String>()
    let data: Array<AnyObject> = Array<AnyObject>()
    
    init(dictionary: Dictionary<String, AnyObject>) {
        
        for (key, value) in dictionary {
            
            switch key {
                case TheoCypherColumns:
                    self.columns = value as Array
                case TheoCypherData:
                    self.data = value as Array
                default:
                    ""
            }
        }
    }
    
    public var description: String {
        return "Columns: \(columns), data \(data)"
    }
}

public class Cypher {

    var meta: CypherMeta?
    private(set) var data: Array<Dictionary<String, AnyObject>> = Array<Dictionary<String, AnyObject>>()
    
    public required init(metaData: Dictionary<String, Array<AnyObject>>?) {
    
        if let dictionaryData: [String:[AnyObject]] = metaData {

            self.meta = CypherMeta(dictionary: dictionaryData)
            
            if let metaForCypher: CypherMeta = self.meta {
                
                let keys = metaForCypher.columns

                for arrayValues in metaForCypher.data as Array<Array<AnyObject>> {
                    
                    for (index, value) in enumerate(arrayValues) {

                        var cypherDictionary: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
                        let cypherDictionaryKey: String = metaForCypher.columns[index]

                        cypherDictionary[cypherDictionaryKey] = value

                        self.data.append(cypherDictionary)
                    }
                }
            }
        }
    }
    
    public convenience init() {
        self.init(metaData: nil)
    }
}

// MARK: - Printable

extension Cypher: Printable {
    
    public var description: String {
        
        var returnString: String = ""
            
            for value: Dictionary<String, AnyObject> in self.data {
                
                for (returnStringKey, returnKeyValue) in value {
                    returnString += " \(returnStringKey): \(returnKeyValue)"
                }
            }<commit_msg>property access and fixed issue with bad return data<commit_after>//
//  Cypher.swift
//  Theo
//
//  Created by <NAME> on 10/7/14.
//  Copyright (c) 2014 Theo. All rights reserved.
//

import Foundation

let TheoCypherColumns: String = "columns"
let TheoCypherData: String    = "data"

public struct CypherMeta: Printable {
    
    let columns: Array<String> = Array<String>()
    let data: Array<AnyObject> = Array<AnyObject>()
    
    init(dictionary: Dictionary<String, AnyObject>) {
        
        for (key, value) in dictionary {
            
            switch key {
                case TheoCypherColumns:
                    self.columns = value as Array
                case TheoCypherData:
                    self.data = value as Array
                default:
                    ""
            }
        }
    }
    
    public var description: String {
        return "Columns: \(columns), data \(data)"
    }
}

public class Cypher {

    var meta: CypherMeta?
    public private(set) var data: Array<Dictionary<String, AnyObject>> = Array<Dictionary<String, AnyObject>>()
    
    public required init(metaData: Dictionary<String, Array<AnyObject>>?) {
    
        if let dictionaryData: [String:[AnyObject]] = metaData {

            self.meta = CypherMeta(dictionary: dictionaryData)
            
            if let metaForCypher: CypherMeta = self.meta {
                
                let keys = metaForCypher.columns

                for arrayValues in metaForCypher.data as Array<Array<AnyObject>> {

                    var cypherDictionary: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
                    
                    for (index, value) in enumerate(arrayValues) {

                        let cypherDictionaryKey: String = metaForCypher.columns[index]
                        
                        cypherDictionary[cypherDictionaryKey] = value
                    }
                    
                    self.data.append(cypherDictionary)
                }
            }
        }
    }
    
    public convenience init() {
        self.init(metaData: nil)
    }
}

// MARK: - Printable

extension Cypher: Printable {
    
    public var description: String {
        
        var returnString: String = ""
            
            for value: Dictionary<String, AnyObject> in self.data {
                
                for (returnStringKey, returnKeyValue) in value {
                    returnString += " \(returnStringKey): \(returnKeyValue)"
                }
            }
{'fraction_non_alphanumeric': 0.08867585380467345, 'fraction_numerical': 0.0035949670461354103, 'mean_word_length': 1.5616368286445013, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '4305853', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1258, 'n_words': 325}