<commit_before>//
//  BuildingTableViewController.swift
//  Test2
//
//  Created by Bilsborough, <NAME> on 11/18/15.
//  Copyright © 2015 Gonzaga University. All rights reserved.
//

import UIKit

class CategoryTableViewController: UITableViewController/*, UISearchResultsUpdating, UISearchBarDelegate, UISearchControllerDelegate*/{
    
    //Passed in variables
    var passInTextFieldTag: Int!
    
    
    //Referencing Outlets
    @IBOutlet var buildingTableView: UITableView!
    
    //Variables
    var allLocationsClicked: Bool = false
    var resultSearchController = UISearchController()
    var filteredTableData = [String]()
    var options: [String]!
    var locationOptions:[Location] = []
    var searchActive: Bool = false
    var revisitView: Bool = false
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initOptions()
        
        definesPresentationContext = true
        /*
        self.resultSearchController = ({
            let controller = UISearchController(searchResultsController: nil)
            controller.searchResultsUpdater = self
            controller.dimsBackgroundDuringPresentation = false
            controller.searchBar.sizeToFit()
            controller.searchBar.delegate = self
            //controller.buildingTableView.delegate = self
            
            self.tableView.tableHeaderView = controller.searchBar
            return controller
        })()
        
        //Reload table
        self.tableView.reloadData()*/
    }
    
    /*func searchBarShouldEndEditing(searchBar: UISearchBar) -> Bool {
        if(!resultSearchController.active)
        {
            return true
        }
        return false
    }*/
    
    /*func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
        searchActive = true
        //resultSearchController.active = false
        //searchBarCancelButtonClicked(searchBar)
        //resultSearchController.willDismissSearchController(UISearchController)
        performSegueWithIdentifier("buildingToLocation", sender: UISearchBar.self)
        print("Worked!")
    }*/
    
    /*func searchBarSearchButtonClicked(searchBar: UISearchBar) {
        //performSegueWithIdentifier("buildingToLocation", sender: resultSearchController.searchBar)
        searchActive = true
        resultSearchController.active = false
        //resultSearchController.willDismissSearchController(UISearchController)
        performSegueWithIdentifier("buildingToLocation", sender: UISearchBar.self)
        print("Worked!")
    }*/
    
    //func searchBar(
    
    
    /*func updateSearchResultsForSearchController(searchController: UISearchController)
    {
        filteredTableData.removeAll(keepCapacity: false)
        
        let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
        
        var newArray = [String]()
        for x in locations
        {
            newArray.append(x.name)
            print(x.name)
        }
                
        let array = ((options /*+ newArray*/) as NSArray).filteredArrayUsingPredicate(searchPredicate)
        filteredTableData = array as! [String]
        
        self.tableView.reloadData()
    }*/
    
    func initOptions()
    {
        options = uniqueCategoryArray(locations)
        options.sortInPlace()
        options.append("All Locations")
    }
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    func uniqueCategoryArray(inputArray: [Location]!) -> [String]!
    {
        var newArray = [String]()
        for x in inputArray
        {
            if(newArray.contains(x.category))
            {<commit_msg>Fixed Category<commit_after>//
//  BuildingTableViewController.swift
//  Test2
//
//  Created by Bilsborough, <NAME> on 11/18/15.
//  Copyright © 2015 Gonzaga University. All rights reserved.
//

import UIKit

class CategoryTableViewController: UITableViewController/*, UISearchResultsUpdating, UISearchBarDelegate, UISearchControllerDelegate*/{
    
    //Passed in variables
    var passInTextFieldTag: Int!
    
    
    //Referencing Outlets
    @IBOutlet var buildingTableView: UITableView!
    
    //Variables
    var allLocationsClicked: Bool = false
    var resultSearchController = UISearchController()
    var filteredTableData = [String]()
    var options: [String]!
    var locationOptions:[Location] = []
    var searchActive: Bool = false
    var revisitView: Bool = false
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initOptions()
        
        definesPresentationContext = true
        /*
        self.resultSearchController = ({
            let controller = UISearchController(searchResultsController: nil)
            controller.searchResultsUpdater = self
            controller.dimsBackgroundDuringPresentation = false
            controller.searchBar.sizeToFit()
            controller.searchBar.delegate = self
            //controller.buildingTableView.delegate = self
            
            self.tableView.tableHeaderView = controller.searchBar
            return controller
        })()
        
        //Reload table
        self.tableView.reloadData()*/
    }
    
    /*func searchBarShouldEndEditing(searchBar: UISearchBar) -> Bool {
        if(!resultSearchController.active)
        {
            return true
        }
        return false
    }*/
    
    /*func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
        searchActive = true
        //resultSearchController.active = false
        //searchBarCancelButtonClicked(searchBar)
        //resultSearchController.willDismissSearchController(UISearchController)
        performSegueWithIdentifier("buildingToLocation", sender: UISearchBar.self)
        print("Worked!")
    }*/
    
    /*func searchBarSearchButtonClicked(searchBar: UISearchBar) {
        //performSegueWithIdentifier("buildingToLocation", sender: resultSearchController.searchBar)
        searchActive = true
        resultSearchController.active = false
        //resultSearchController.willDismissSearchController(UISearchController)
        performSegueWithIdentifier("buildingToLocation", sender: UISearchBar.self)
        print("Worked!")
    }*/
    
    //func searchBar(
    
    
    /*func updateSearchResultsForSearchController(searchController: UISearchController)
    {
        filteredTableData.removeAll(keepCapacity: false)
        
        let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
        
        var newArray = [String]()
        for x in locations
        {
            newArray.append(x.name)
            print(x.name)
        }
                
        let array = ((options /*+ newArray*/) as NSArray).filteredArrayUsingPredicate(searchPredicate)
        filteredTableData = array as! [String]
        
        self.tableView.reloadData()
    }*/
    
    func initOptions()
    {
        options = uniqueCategoryArray(locations)
        options.append("All Locations")
        options.sortInPlace()
    }
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    func uniqueCategoryArray(inputArray: [Location]!) -> [String]!
    {
        var newArray = [String]()
        for x in inputArray
        {
            if(newArray.contains(x.category))
            {
{'fraction_non_alphanumeric': 0.08775482651545835, 'fraction_numerical': 0.0032401782098015392, 'mean_word_length': 2.3950504124656278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '420931', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1933, 'n_words': 371}