<commit_before>//
//  TKSwipeData.swift
//  TKSwipeDataDemo
//
//  Created by <NAME> on 9/15/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation

extension String {
    subscript (i: Int) -> Character {
        return self[self.startIndex.advancedBy(i)]
    }
    
    subscript (i: Int) -> String {
        return String(self[i] as Character)
    }
    
    subscript (r: Range<Int>) -> String {
        return substringWithRange(Range(start: self.startIndex.advancedBy(r.startIndex), end: self.startIndex.advancedBy(r.endIndex)))
    }
}

struct TKSwipeData {
    var swipeData: String
    
    var cardHolder: String {
        get {
            let cardHolder = swipeData.componentsSeparatedByString("^")[1]
            if cardHolder.containsString("/") {
                let cardHolderParts = cardHolder.componentsSeparatedByString("/")
                if cardHolderParts.count > 1 {
                    return "\(cardHolderParts[1]) \(cardHolderParts[0])"
                }
                else {
                    return cardHolderParts[1]
                }
            }
            else {
                return cardHolder
            }
        }
    }
    
    var cardNumber: String {
        get {
            let charIndex = swipeData.rangeOfString("^")!
            let sIndex = swipeData.startIndex.advancedBy(2)
            let eIndex = charIndex.endIndex.advancedBy(-1)<commit_msg>Correct crash on cardholder data without "/" separator<commit_after>//
//  TKSwipeData.swift
//  TKSwipeDataDemo
//
//  Created by <NAME> on 9/15/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation

extension String {
    subscript (i: Int) -> Character {
        return self[self.startIndex.advancedBy(i)]
    }
    
    subscript (i: Int) -> String {
        return String(self[i] as Character)
    }
    
    subscript (r: Range<Int>) -> String {
        return substringWithRange(Range(start: self.startIndex.advancedBy(r.startIndex), end: self.startIndex.advancedBy(r.endIndex)))
    }
}

struct TKSwipeData {
    var swipeData: String
    
    var cardHolder: String {
        get {
            let cardHolder = swipeData.componentsSeparatedByString("^")[1]
            if cardHolder.containsString("/") {
                let cardHolderParts = cardHolder.componentsSeparatedByString("/")
                if cardHolderParts.count > 1 {
                    return "\(cardHolderParts[1]) \(cardHolderParts[0])"
                }
                else {
                    return cardHolderParts[0]
                }
            }
            else {
                return cardHolder
            }
        }
    }
    
    var cardNumber: String {
        get {
            let charIndex = swipeData.rangeOfString("^")!
            let sIndex = swipeData.startIndex.advancedBy(2)
            let eIndex = charIndex.endIndex.advancedBy(-1)
{'fraction_non_alphanumeric': 0.1089588377723971, 'fraction_numerical': 0.011068834313386372, 'mean_word_length': 1.7942028985507246, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '6072337', 'n_tokens_mistral': 876, 'n_tokens_neox': 816, 'n_words': 173}