<commit_before>import Foundation

extension String {
    
    subscript (i: Int) -> Character {
        return self[self.intIndex(at: i)!]
    }
    
    var length: Int {
        get {
            return self.characters.count
        }
    }
    
    func intIndex (at: Int) -> Index? {
        
        if at < 0 || at >= self.length {
            return nil
        }
        
        return self.index(self.startIndex, offsetBy: at)
    }
    
    func indexOf (target : Character) -> Int? {
        
        var index:Int?
        var current = 0
        
        for c in self.lowercased().characters {
            if (c == target) {
                index = current
                break
            }
            current += 1
        }
        return index
    }
    
    func lastIndexOf(target: Character) -> Int? {
        var index : Int?
        let str = self.lowercased()
        
        for i in (0...str.length-1).reversed() {
            if (self[i] == target) {
                index = i
                break
            }
        }
        return index
    }
    
    func substring(to: Int) -> String? {
        if to < 0 {
            return nil
        }
        
        let range = self.startIndex..<self.intIndex(at: to)!
        return self.substring(with: range)
        
    }
    
    func substring(from: Int, to: Int) -> String? {
        
        if from > to || from < 0 || to < 0  {
            return nil
        }
        
        let range = self.index(self.startIndex, offsetBy: from)..<self.index(self.startIndex, offsetBy: to)
        return self.substring(with: range)
    }
    
    func split(separator:String) -> [String] {
        return self.components(separatedBy: separator)
    }
    
    func replace(this: String, to:String) -> String {
        return self.replacingOccurrences(of: this, with: to)
    }
    
    func trim () -> String {
        return self.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
    }
}<commit_msg>+ indexOf fixed<commit_after>import Foundation

extension String {
    
    subscript (i: Int) -> Character {
        return self[self.intIndex(at: i)!]
    }
    
    var length: Int {
        get {
            return self.characters.count
        }
    }
    
    func intIndex (at: Int) -> Index? {
        
        if at < 0 || at >= self.length {
            return nil
        }
        
        return self.index(self.startIndex, offsetBy: at)
    }
    
    func indexOf (target : Character) -> Int? {
        
        var index:Int?
        var current = 0
        
        for c in self.characters {
            if (c == target) {
                index = current
                break
            }
            current += 1
        }
        return index
    }
    
    func lastIndexOf(target: Character) -> Int? {
        var index : Int?
        
        for i in (0...self.length-1).reversed() {
            if (self[i] == target) {
                index = i
                break
            }
        }
        return index
    }
    
    func substring(to: Int) -> String? {
        if to < 0 {
            return nil
        }
        
        let range = self.startIndex..<self.intIndex(at: to)!
        return self.substring(with: range)
        
    }
    
    func substring(from: Int, to: Int) -> String? {
        
        if from > to || from < 0 || to < 0  {
            return nil
        }
        
        let range = self.index(self.startIndex, offsetBy: from)..<self.index(self.startIndex, offsetBy: to)
        return self.substring(with: range)
    }
    
    func split(separator:String) -> [String] {
        return self.components(separatedBy: separator)
    }
    
    func replace(this: String, with:String) -> String {
        return self.replacingOccurrences(of: this, with: with)
    }
    
    func trim () -> String {
        return self.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
    }
}
{'fraction_non_alphanumeric': 0.10614525139664804, 'fraction_numerical': 0.004062976130015236, 'mean_word_length': 1.3321492007104796, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '2318471', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1139, 'n_words': 283}