<commit_before>//
//  LoopSuggested.swift
//  RileyLink
//
//  Created by <NAME> on 7/28/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public struct LoopSuggested {
    let timestamp: NSDate
    let rate: Double
    let duration: NSTimeInterval
    let correction: Double
    let eventualBG: Int
    let bg: Int
    let reason: String?
    let tick: Int?
    
    public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, correction: Double = 0, eventualBG: Int, bg: Int, reason: String?, tick: Int?) {
        self.timestamp = timestamp
        self.rate = rate
        self.duration = duration
        self.correction = correction
        self.eventualBG = eventualBG
        self.bg = bg
        self.reason = reason
        self.tick = tick
    }
    
    public var dictionaryRepresentation: [String: AnyObject] {

        var rval = [String: AnyObject]()

        rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)

        if let tick = tick {
            let tickStr: String
            if tick > 0 {
                tickStr = "+\(tick)"
            } else if tick < 0 {
                tickStr = "-\(tick)"
            } else {
                tickStr = "0"
            }
            rval["tick"] = tickStr
        }

        rval["rate"] = rate
        rval["duration"] = duration / 60.0
        rval["bg"] = bg
        rval["correction"] = correction
        rval["eventualBG"] = eventualBG

        if let reason = reason {
            rval["reason"] = reason
        }

        return rval
    }
}<commit_msg>Make correction optional in LoopSuggested<commit_after>//
//  LoopSuggested.swift
//  RileyLink
//
//  Created by <NAME> on 7/28/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public struct LoopSuggested {
    let timestamp: NSDate
    let rate: Double
    let duration: NSTimeInterval
    let eventualBG: Int
    let bg: Int
    let reason: String?
    let tick: Int?
    let correction: Double?

    public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: Int, bg: Int, reason: String? = nil, tick: Int? = nil, correction: Double? = nil) {
        self.timestamp = timestamp
        self.rate = rate
        self.duration = duration
        self.eventualBG = eventualBG
        self.bg = bg
        self.reason = reason
        self.tick = tick
        self.correction = correction
    }
    
    public var dictionaryRepresentation: [String: AnyObject] {

        var rval = [String: AnyObject]()

        rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)

        if let tick = tick {
            let tickStr: String
            if tick > 0 {
                tickStr = "+\(tick)"
            } else if tick < 0 {
                tickStr = "-\(tick)"
            } else {
                tickStr = "0"
            }
            rval["tick"] = tickStr
        }

        rval["rate"] = rate
        rval["duration"] = duration / 60.0
        rval["bg"] = bg
        rval["eventualBG"] = eventualBG

        if let reason = reason {
            rval["reason"] = reason
        }

        if let correction = correction {
            rval["correction"] = correction
        }


        return rval
    }
}
{'fraction_non_alphanumeric': 0.10482631417153397, 'fraction_numerical': 0.009529664924684907, 'mean_word_length': 1.7529610829103215, 'pattern_counts': {'":': 0, '<': 9, '<?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': '130714', 'n_tokens_mistral': 974, 'n_tokens_neox': 912, 'n_words': 272}