<commit_before>//
//  Created by <NAME>
//  http://www.jessesquires.com
//
//
//  Documentation
//  http://cocoadocs.org/docsets/JSQDataSourcesKit
//
//
//  GitHub
//  https://github.com/jessesquires/JSQDataSourcesKit
//
//
//  License
//  Copyright (c) 2015 <NAME>
//  Released under an MIT license: http://opensource.org/licenses/MIT
//

import Foundation
import UIKit


extension UITableView {

    public func registerNibs(nibs: [UINib], forReuseIdentifiers identifiers: [String]) {
        assert(nibs.count == identifiers.count, "Arrays of nibs and identifiers must have equal counts")

        for index in 0..<nibs.count {
            registerNib(nibs[index], forCellReuseIdentifier: identifiers[index])
        }
    }

    public func registerClasses(classes: [AnyClass], forReuseIdentifiers identifiers: [String]) {
        assert(classes.count == identifiers.count, "Arrays of classes and identifiers must have equal counts")

        for index in 0..<classes.count {
            registerClass(classes[index], forCellReuseIdentifier: identifiers[index])
        }
    }

}


public protocol TableViewCellFactoryType {

    typealias DataItem
    typealias Cell: UITableViewCell

    func cellForItem(item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell

    func configureCell(cell: Cell, forItem item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell

}


public struct TableViewCellFactory<Cell: UITableViewCell, DataItem>: TableViewCellFactoryType {

    typealias CellConfigurationClosure = (Cell, DataItem, UITableView, NSIndexPath) -> Cell

    private let reuseIdentifier: String
    private let cellConfigurator: CellConfigurationClosure

    public init(reuseIdentifier: String, cellConfigurator: CellConfigurationClosure) {
        self.reuseIdentifier = reuseIdentifier
        self.cellConfigurator = cellConfigurator
    }

    public func cellForItem(item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell {
        let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as Cell
        return configureCell(cell, forItem: item, inTableView: tableView, atIndexPath: indexPath)
    }

    public func configureCell(cell: Cell, forItem item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell {
        return self.cellConfigurator(cell, item, tableView, indexPath)
    }

}


public class TableViewDataSource <SectionCollection: CollectionType, CellFactory: TableViewCellFactoryType, DataItem
                                    where
                                    SectionCollection.Index == Int,
                                    SectionCollection.Generator.Element: CollectionType,
                                    SectionCollection.Generator.Element.Generator.Element == DataItem,
                                    SectionCollection.Generator.Element.Index == Int,
                                    CellFactory.DataItem == DataItem>: NSObject, UITableViewDataSource {

    public var sections: SectionCollection

    public let cellFactory: CellFactory

    public init(sections: SectionCollection, cellFactory: CellFactory) {
        self.sections = sections
        self.cellFactory = cellFactory
    }

    // MARK: table view data source

    public func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return countElements(sections)
    }

    public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return countElements(sections[section])
    }

    public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        return cellFactory.cellForItem(sections[indexPath.section][indexPath.row], inTableView: tableView, atIndexPath: indexPath)
    }

}<commit_msg>finish initial table view data source<commit_after>//
//  Created by <NAME>
//  http://www.jessesquires.com
//
//
//  Documentation
//  http://cocoadocs.org/docsets/JSQDataSourcesKit
//
//
//  GitHub
//  https://github.com/jessesquires/JSQDataSourcesKit
//
//
//  License
//  Copyright (c) 2015 <NAME>quires
//  Released under an MIT license: http://opensource.org/licenses/MIT
//

import Foundation
import UIKit


public protocol TableViewCellFactoryType {

    typealias DataItem
    typealias Cell: UITableViewCell

    func cellForItem(item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell

    func configureCell(cell: Cell, forItem item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell

}


public struct TableViewCellFactory<Cell: UITableViewCell, DataItem>: TableViewCellFactoryType {

    typealias CellConfigurationClosure = (Cell, DataItem, UITableView, NSIndexPath) -> Cell

    private let reuseIdentifier: String
    private let cellConfigurator: CellConfigurationClosure

    public init(reuseIdentifier: String, cellConfigurator: CellConfigurationClosure) {
        self.reuseIdentifier = reuseIdentifier
        self.cellConfigurator = cellConfigurator
    }

    public func cellForItem(item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell {
        let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as Cell
        return configureCell(cell, forItem: item, inTableView: tableView, atIndexPath: indexPath)
    }

    public func configureCell(cell: Cell, forItem item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell {
        return self.cellConfigurator(cell, item, tableView, indexPath)
    }

}


public class TableViewDataSourceProvider <SectionCollection: CollectionType, CellFactory: TableViewCellFactoryType, DataItem
                                            where
                                            SectionCollection.Index == Int,
                                            SectionCollection.Generator.Element: CollectionType,
                                            SectionCollection.Generator.Element.Generator.Element == DataItem,
                                            SectionCollection.Generator.Element.Index == Int,
                                            CellFactory.DataItem == DataItem> {

    public var sections: SectionCollection

    public let cellFactory: CellFactory

    public var dataSource: UITableViewDataSource { return bridgedDataSource }

    private let bridgedDataSource: BridgedTableViewDataSource!

    public init(sections: SectionCollection, cellFactory: CellFactory) {
        self.sections = sections
        self.cellFactory = cellFactory

        self.bridgedDataSource = BridgedTableViewDataSource(
            numberOfSections: {
                [unowned self] () -> Int in
                return countElements(self.sections)
            },
            numberOfRowsInSection: {
                [unowned self] (section) -> Int in
                return countElements(self.sections[section])
            },
            cellForRowAtIndexPath: {
                [unowned self] (tableView, indexPath) -> UITableViewCell in
                return self.cellFactory.cellForItem(sections[indexPath.section][indexPath.row], inTableView: tableView, atIndexPath: indexPath)
        })
    }

}


private class BridgedTableViewDataSource: NSObject, UITableViewDataSource {

    typealias NumberOfSectionsHandler = () -> Int
    typealias NumberOfRowsIntSectionHandler = (Int) -> Int
    typealias CellForRowAtIndexPathHandler = (UITableView, NSIndexPath) -> UITableViewCell

    private let numberOfSections: NumberOfSectionsHandler
    private let numberOfRowsInSection: NumberOfRowsIntSectionHandler
    private let cellForRowAtIndexPath: CellForRowAtIndexPathHandler

    init(numberOfSections: NumberOfSectionsHandler, numberOfRowsInSection: NumberOfRowsIntSectionHandler, cellForRowAtIndexPath: CellForRowAtIndexPathHandler) {
        self.numberOfSections = numberOfSections
        self.numberOfRowsInSection = numberOfRowsInSection
        self.cellForRowAtIndexPath = cellForRowAtIndexPath
    }

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return numberOfSections()
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return numberOfRowsInSection(section)
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        return cellForRowAtIndexPath(tableView, indexPath)
    }

}
{'fraction_non_alphanumeric': 0.07666551206558134, 'fraction_numerical': 0.0011546010853250202, 'mean_word_length': 3.120837297811608, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4152190', 'n_tokens_mistral': 2344, 'n_tokens_neox': 2166, 'n_words': 533}