<commit_before>//
//  VoteHandler.swift
//  Voter
//
//  Created by <NAME> on 14/12/14.
//  Copyright (c) 2014 Lambda Academy. All rights reserved.
//

import UIKit


class VoteManager: NSObject {
    var votes : Array<Vote> = [] //
    
    // https://github.com/hpique/SwiftSingleton
    class var sharedInstance: VoteManager {
        struct Singleton {
            static let instance = VoteManager()
        }

        return Singleton.instance
    }
    
    func makeVote(vote: Vote) {
        self.votes.addVote(vote)
        
//        println("Votes: \(self.votes)")
//        println("Median: \(self.median)")
//        println()
    }


    func likes() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Like
        }
    }
    
    func neutrals() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Neutral
        }
    }
    
    func hates() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Hate
        }
    }
    
    var median: Vote {
        var grouppedVotes  = [self.likes(), self.hates(), self.neutrals()]
        grouppedVotes.sort({ $0.count < $1.count })
        if (grouppedVotes[0].count == 0) {
            grouppedVotes.removeAtIndex(0)
        }

        if let median = grouppedVotes[1].last {
            return median
        } else {
            return Vote.None
        }
    }
    
    // average
}
<commit_msg>removed minor bug<commit_after>//
//  VoteHandler.swift
//  Voter
//
//  Created by <NAME> on 14/12/14.
//  Copyright (c) 2014 Lambda Academy. All rights reserved.
//

import UIKit


class VoteManager: NSObject {
    var votes : Array<Vote> = [] //
    
    // https://github.com/hpique/SwiftSingleton
    class var sharedInstance: VoteManager {
        struct Singleton {
            static let instance = VoteManager()
        }

        return Singleton.instance
    }
    
    func makeVote(vote: Vote) {
        self.votes.append(vote)
        
//        println("Votes: \(self.votes)")
//        println("Median: \(self.median)")
//        println()
    }


    func likes() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Like
        }
    }
    
    func neutrals() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Neutral
        }
    }
    
    func hates() -> Array<Vote> {
        return self.votes.filter {
            $0 == Vote.Hate
        }
    }
    
    var median: Vote {
        var grouppedVotes  = [self.likes(), self.hates(), self.neutrals()]
        grouppedVotes.sort({ $0.count < $1.count })
        if (grouppedVotes[0].count == 0) {
            grouppedVotes.removeAtIndex(0)
        }

        if let median = grouppedVotes[1].last {
            return median
        } else {
            return Vote.None
        }
    }
    
    // average
}

{'fraction_non_alphanumeric': 0.1316987740805604, 'fraction_numerical': 0.013309982486865149, 'mean_word_length': 1.5207413945278023, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '645860', 'n_tokens_mistral': 975, 'n_tokens_neox': 915, 'n_words': 186}