<commit_before>//
//  LinkTaskNode.swift
//  UsbongKit
//
//  Created by <NAME> on 18/11/2015.
//  Copyright © 2015 Usbong Social Systems, Inc. All rights reserved.
//

import Foundation

public struct LinkTaskNodeTask {
    public let identifier: String
    public let value: String
    
    public init(identifier: String, value: String) {
        self.identifier = identifier
        self.value = value
    }
}

public class LinkTaskNode: TaskNode {
    public var indexOffset: Int = 1
    public var currentSelectedIndex: Int = -1 // -1 means none
    public var trueIndex: Int {
        if currentSelectedIndex >= 0 {
            return indexOffset + currentSelectedIndex
        } else {
            return -1
        }
    }
    public var currentSelectedModule: LinkTaskNodeModule? {
        let index = trueIndex
        if index >= 0 && index < modules.count {
            return modules[index] as? LinkTaskNodeModule
        }
        return nil
    }
    
    public init(text: String, tasks: [LinkTaskNodeTask]) {
        var currentModules = [TaskNodeModule]()
        currentModules.append(TextTaskNodeModule(text: text))
        
        // Test tasks
        for task in tasks {
            currentModules.append(LinkTaskNodeModule(task: task))
        }
        
        super.init(modules: currentModules)
    }
}

public class LinkTaskNodeModule: TaskNodeModule {
    public init(task: LinkTaskNodeTask) {
        super.init(content: ["taskValue": NSString(string: task.value), "taskIdentifier": NSString(string: task.identifier)])
    }
    
    public var taskValue: String {
        get {
            return (content["taskValue"] as? NSString ?? "") as String
        }
        set {
            content["taskValue"] = NSString(string: newValue)<commit_msg>Remove unnecessary debug comment<commit_after>//
//  LinkTaskNode.swift
//  UsbongKit
//
//  Created by <NAME> on 18/11/2015.
//  Copyright © 2015 Usbong Social Systems, Inc. All rights reserved.
//

import Foundation

public struct LinkTaskNodeTask {
    public let identifier: String
    public let value: String
    
    public init(identifier: String, value: String) {
        self.identifier = identifier
        self.value = value
    }
}

public class LinkTaskNode: TaskNode {
    public var indexOffset: Int = 1
    public var currentSelectedIndex: Int = -1 // -1 means none
    public var trueIndex: Int {
        if currentSelectedIndex >= 0 {
            return indexOffset + currentSelectedIndex
        } else {
            return -1
        }
    }
    public var currentSelectedModule: LinkTaskNodeModule? {
        let index = trueIndex
        if index >= 0 && index < modules.count {
            return modules[index] as? LinkTaskNodeModule
        }
        return nil
    }
    
    public init(text: String, tasks: [LinkTaskNodeTask]) {
        var currentModules = [TaskNodeModule]()
        currentModules.append(TextTaskNodeModule(text: text))
        
        for task in tasks {
            currentModules.append(LinkTaskNodeModule(task: task))
        }
        
        super.init(modules: currentModules)
    }
}

public class LinkTaskNodeModule: TaskNodeModule {
    public init(task: LinkTaskNodeTask) {
        super.init(content: ["taskValue": NSString(string: task.value), "taskIdentifier": NSString(string: task.identifier)])
    }
    
    public var taskValue: String {
        get {
            return (content["taskValue"] as? NSString ?? "") as String
        }
        set {
            content["taskValue"] = NSString(string: newValue)
{'fraction_non_alphanumeric': 0.0927748102333427, 'fraction_numerical': 0.010120888389091932, 'mean_word_length': 2.285318559556787, 'pattern_counts': {'":': 4, '<': 7, '<?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': '7311187', 'n_tokens_mistral': 985, 'n_tokens_neox': 955, 'n_words': 274}