<commit_before>//
//  ValueTransformers.swift
//  Helium
//
//  Created by <NAME> on 4/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation

// Convert a numeric to an HMS string and back
class hmsTransformer: NSValueTransformer {
	
	// flag indicating transformation is read-write
	internal override class func allowsReverseTransformation() -> Bool {
		return true
	}

	// by default returns value
	internal override func transformedValue(value: AnyObject?) -> AnyObject? {
		if var secs : NSTimeInterval = value as? NSTimeInterval {
			print("secs \(secs)")
			let h = Int(secs / 3600)
			secs -= NSTimeInterval(h*3600)
			let m = Int(secs / 60)
			secs -= NSTimeInterval(m*60)
			print("\(h):\(m):\(secs)")

			//	return optional hms components
			return String(format:"%@%@%02.f",
			              (h > 0 ? String(format:"%d:",h) : ""),
			              (m > 0 ? String(format:"%02d:",m) : ""),
			              secs)
		}
		return nil
	}

	// by default raises an exception if +allowsReverseTransformation returns NO and otherwise invokes transformedValue:<commit_msg>disabled log noise<commit_after>//
//  ValueTransformers.swift
//  Helium
//
//  Created by <NAME> on 4/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation

// Convert a numeric to an HMS string and back
class hmsTransformer: NSValueTransformer {
	
	// flag indicating transformation is read-write
	internal override class func allowsReverseTransformation() -> Bool {
		return true
	}

	// by default returns value
	internal override func transformedValue(value: AnyObject?) -> AnyObject? {
		if var secs : NSTimeInterval = value as? NSTimeInterval {
			let h = Int(secs / 3600)
			secs -= NSTimeInterval(h*3600)
			let m = Int(secs / 60)
			secs -= NSTimeInterval(m*60)

			//	return optional hms components
			return String(format:"%@%@%02.f",
			              (h > 0 ? String(format:"%d:",h) : ""),
			              (m > 0 ? String(format:"%02d:",m) : ""),
			              secs)
		}
		return nil
	}

	// by default raises an exception if +allowsReverseTransformation returns NO and otherwise invokes transformedValue:
{'fraction_non_alphanumeric': 0.1267474370922647, 'fraction_numerical': 0.02516309412861137, 'mean_word_length': 2.903636363636364, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5308422', 'n_tokens_mistral': 779, 'n_tokens_neox': 662, 'n_words': 202}