<commit_before>//
//  DetailTableViewController.swift
//  Smashtag
//
//  Created by <NAME> on 1/6/16.
//  Copyright © 2016 USF. All rights reserved.
//

import UIKit

class DetailTableViewController: UITableViewController {
    
    private struct Detail {
        static let MediaReuseIdentifier = "Media"
        static let InfoReuseIdentifier = "Info"
    }
    
    private enum TweetDetail {
        case Media(images: MediaItem)
        case URLMention(url: Tweet.IndexedKeyword)
        case UserMention(user: Tweet.IndexedKeyword)
        case HashTag(hashTag: Tweet.IndexedKeyword)
        
        var description: String {
            switch self {
            case .Media(_):
                return "Media"
            case .URLMention(_):
                return "URLs"
            case .UserMention(_):
                return "Users"
            case .HashTag(_):
                return "Hash Tags"
            }
        }
        
        var detail: String {
            switch self {
            case .Media(let image):
                return image.url.description
            case .URLMention(let url):
                return url.keyword
            case .UserMention(let user):
                return user.keyword
            case .HashTag(let hashTag):
                return hashTag.keyword
            }
        }
        
        var identifier: String {
            switch self {
            case .Media(_):
                return Detail.MediaReuseIdentifier
            case .URLMention(_):
                return Detail.InfoReuseIdentifier
            case .UserMention(_):
                return Detail.InfoReuseIdentifier
            case .HashTag(_):
                return Detail.InfoReuseIdentifier
            }
        }
    }

    // MARK: - Model
    var tweet: Tweet? {
        didSet {
            if tweet != nil {
                initializeDetails(tweet!)
                tableView.reloadData()
            }
        }
    }
    
    private var details = [[TweetDetail]]()
    
    private func initializeDetails(tweet: Tweet) {
        if tweet.media.count > 0 {
            details.append(tweet.media.map{ .Media(images: $0) })
        }
        if tweet.urls.count > 0 {
            details.append(tweet.urls.map{ .URLMention(url: $0) })
        }
        if tweet.userMentions.count > 0 {
            details.append(tweet.userMentions.map{ .UserMention(user: $0) })
        }
        if tweet.hashtags.count > 0 {
            details.append(tweet.hashtags.map{ .HashTag(hashTag: $0) })
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.estimatedRowHeight = tableView.rowHeight
        tableView.rowHeight = UITableViewAutomaticDimension
        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false
<commit_msg>Some renaming.<commit_after>//
//  DetailTableViewController.swift
//  Smashtag
//
//  Created by <NAME> on 1/6/16.
//  Copyright © 2016 USF. All rights reserved.
//

import UIKit

class DetailTableViewController: UITableViewController {
    
    private struct Detail {
        static let MediaReuseIdentifier = "Media"
        static let InfoReuseIdentifier = "Info"
    }
    
    private enum TweetDetail {
        case Media(image: MediaItem)
        case URLMention(url: Tweet.IndexedKeyword)
        case UserMention(user: Tweet.IndexedKeyword)
        case HashTag(hashTag: Tweet.IndexedKeyword)
        
        var description: String {
            switch self {
            case .Media(_):
                return "Media"
            case .URLMention(_):
                return "URLs"
            case .UserMention(_):
                return "Users"
            case .HashTag(_):
                return "Hash Tags"
            }
        }
        
        var detail: String {
            switch self {
            case .Media(let image):
                return image.url.description
            case .URLMention(let url):
                return url.keyword
            case .UserMention(let user):
                return user.keyword
            case .HashTag(let hashTag):
                return hashTag.keyword
            }
        }
        
        var identifier: String {
            switch self {
            case .Media(_):
                return Detail.MediaReuseIdentifier
            case .URLMention(_):
                return Detail.InfoReuseIdentifier
            case .UserMention(_):
                return Detail.InfoReuseIdentifier
            case .HashTag(_):
                return Detail.InfoReuseIdentifier
            }
        }
    }

    // MARK: - Model
    var tweet: Tweet? {
        didSet {
            if tweet != nil {
                initializeDetails(tweet!)
                tableView.reloadData()
            }
        }
    }
    
    private var details = [[TweetDetail]]()
    
    private func initializeDetails(tweet: Tweet) {
        if tweet.media.count > 0 {
            details.append(tweet.media.map{ .Media(image: $0) })
        }
        if tweet.urls.count > 0 {
            details.append(tweet.urls.map{ .URLMention(url: $0) })
        }
        if tweet.userMentions.count > 0 {
            details.append(tweet.userMentions.map{ .UserMention(user: $0) })
        }
        if tweet.hashtags.count > 0 {
            details.append(tweet.hashtags.map{ .HashTag(hashTag: $0) })
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.estimatedRowHeight = tableView.rowHeight
        tableView.rowHeight = UITableViewAutomaticDimension
        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

{'fraction_non_alphanumeric': 0.08687359112190046, 'fraction_numerical': 0.005548812207386856, 'mean_word_length': 1.5111014366565085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2220481', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1544, 'n_words': 353}