<commit_before>//
//  NextGenDataManager.swift
//  NextGenDataManagerExample
//
//  Created by <NAME> on 2/8/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

class NextGenDataManager: NSObject {
    
    static let sharedInstance = NextGenDataManager()
    
    var manifest: NGEMediaManifestType!
    var videoMap = [String: NGEInventoryVideoType]()
    var imageMap = [String: NGEInventoryImageType]()
    var pictureGroupMap = [String: NGEPictureGroupType]()
    var metadataMap = [String: NGEInventoryMetadataType]()
    var experienceMap = [String: NGEExperienceType]()
    var presentationMap = [String: NGEPresentationType]()
    
    func loadXMLFile(filePath: String!) -> Bool {
        manifest = NGEMediaManifestType.NGEMediaManifestTypeFromFile(filePath)
        return manifest != nil
    }
    
    func outOfMovieExperienceCategories() -> [NGEExperienceType] {
        if let mainExperience = manifest.Experiences.ExperienceList.first, mainChildList = mainExperience.ExperienceChildList, mainChild = mainChildList.first {
            if let outOfMovieExperienceParent = experienceById(mainChild.ExperienceID), subChildList = outOfMovieExperienceParent.ExperienceChildList {
                var experiences: [NGEExperienceType] = []
                for subChild in subChildList {
                    if let experience = experienceById(subChild.ExperienceID) {
                        if experience.ExperienceChildList?.count > 0 {
                            experiences.append(experience)
                        }
                    }
                }
                
                return experiences
            }
        }
        
        return []
    }
    
    func videoByTrackId(videoTrackId: String) -> NGEInventoryVideoType? {
        if videoMap.count == 0 {
            if let videoList = manifest.Inventory?.VideoList {
                for video in videoList {
                    videoMap[video.VideoTrackID] = video
                }
            }
        }
        
        return videoMap[videoTrackId]
    }
    <commit_msg>Added basic TODO on modifying from assumptions to absolute values based on manifest definition.<commit_after>//
//  NextGenDataManager.swift
//  NextGenDataManagerExample
//
//  Created by <NAME> on 2/8/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

class NextGenDataManager: NSObject {
    
    static let sharedInstance = NextGenDataManager()
    
    var manifest: NGEMediaManifestType!
    var videoMap = [String: NGEInventoryVideoType]()
    var imageMap = [String: NGEInventoryImageType]()
    var pictureGroupMap = [String: NGEPictureGroupType]()
    var metadataMap = [String: NGEInventoryMetadataType]()
    var experienceMap = [String: NGEExperienceType]()
    var presentationMap = [String: NGEPresentationType]()
    
    func loadXMLFile(filePath: String!) -> Bool {
        manifest = NGEMediaManifestType.NGEMediaManifestTypeFromFile(filePath)
        return manifest != nil
    }
    
    // !!!TODO: Makes assumptions about manifest experience's structure. See if we can make it "menu manifest"
    func outOfMovieExperienceCategories() -> [NGEExperienceType] {
        if let mainExperience = manifest.Experiences.ExperienceList.first, mainChildList = mainExperience.ExperienceChildList, mainChild = mainChildList.first {
            if let outOfMovieExperienceParent = experienceById(mainChild.ExperienceID), subChildList = outOfMovieExperienceParent.ExperienceChildList {
                var experiences: [NGEExperienceType] = []
                for subChild in subChildList {
                    if let experience = experienceById(subChild.ExperienceID) {
                        if experience.ExperienceChildList?.count > 0 {
                            experiences.append(experience)
                        }
                    }
                }
                
                return experiences
            }
        }
        
        return []
    }
    
    func videoByTrackId(videoTrackId: String) -> NGEInventoryVideoType? {
        if videoMap.count == 0 {
            if let videoList = manifest.Inventory?.VideoList {
                for video in videoList {
                    videoMap[video.VideoTrackID] = video
                }
            }
        }
        
        return videoMap[videoTrackId]
    }
    
{'fraction_non_alphanumeric': 0.0784, 'fraction_numerical': 0.004571428571428572, 'mean_word_length': 2.1436781609195403, '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': '2394419', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1121, 'n_words': 256}