<commit_before>//
//  SessionDataItem.swift
//  M3U8
//
//  Created by <NAME> on 8/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

public struct SessionDataItem: Item {
    
    public let dataID: String
    public let value: String?
    public let uri: String?
    public let language: String?
    
    public init(dataID: String, value: String? = nil, uri: String? = nil, language: String? = nil) {
        self.dataID = dataID
        self.value = value
        self.uri = uri
        self.language = language
    }
    
    public init?(string: String) {
        return nil
    }
    
}

extension SessionDataItem {
    
    public var description: String {
        return ""
    }
    
}<commit_msg>Green tests on Session Data Item<commit_after>//
//  SessionDataItem.swift
//  M3U8
//
//  Created by <NAME> on 8/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

public struct SessionDataItem: Item {
    
    public let dataID: String
    public let value: String?
    public let uri: String?
    public let language: String?
    
    public init(dataID: String, value: String? = nil, uri: String? = nil, language: String? = nil) {
        self.dataID = dataID
        self.value = value
        self.uri = uri
        self.language = language
    }
    
    public init?(string: String) {
        let attributes = string.m3u8Attributes
        guard let dataID = attributes["DATA-ID"] else {
            return nil
        }
        self.dataID = dataID
        self.value = attributes["VALUE"]
        self.uri = attributes["URI"]
        self.language = attributes["LANGUAGE"]
    }
    
}

extension SessionDataItem {
    
    public var description: String {
        var components = ["#EXT-X-SESSION-DATA:DATA-ID=\"\(dataID)\""]
        if let value = value {
            components.append("VALUE=\"\(value)\"")
        }
        if let uri = uri {
            components.append("URI=\"\(uri)\"")
        }
        if let language = language {
            components.append("LANGUAGE=\"\(language)\"")
        }
        return ",".join(components)
    }
    
}
{'fraction_non_alphanumeric': 0.11855670103092783, 'fraction_numerical': 0.011246485473289597, 'mean_word_length': 1.9735376044568245, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3595225', 'n_tokens_mistral': 645, 'n_tokens_neox': 625, 'n_words': 178}