<commit_before>//
//  ResultController.swift
//  MenuReader
//
//  Created by RN-079 on 2017/01/04.
//  Copyright © 2017年 RN-079. All rights reserved.
//

import UIKit
import RxSwift

class ResultController: ViewController {
    @IBOutlet weak var tableView1 : UITableView!
    @IBOutlet weak var tableView2 : UITableView!
    @IBOutlet weak var indicator: UIActivityIndicatorView!

    let model = ResultModel()
    var results = [String]()
    
    // params.
    var image : UIImage!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setTableView()
        
        // データを取得する.
        getData()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    private func getData() {
        indicator.startAnimating()
        model.createRequest(image: image)
    }
    
    private func setTableView() {
        tableView1.tableFooterView = UIView()
        tableView1.delegate = self
        tableView1.dataSource = self
        
        tableView2.tableFooterView = UIView()
        tableView2.delegate = self
        tableView2.dataSource = self
        
        model.delegate = self
    }
}

extension ResultController : ResultModelDelegate {
    func complete(result: String?) {
        indicator.stopAnimating()
        guard let contentArray = result?.components(separatedBy: "\n") else {return}
        results = contentArray
        
        print("results = \(results)")
        
        tableView1.reloadData()<commit_msg>content<commit_after>//
//  ResultController.swift
//  MenuReader
//
//  Created by RN-079 on 2017/01/04.
//  Copyright © 2017年 RN-079. All rights reserved.
//

import UIKit
import RxSwift

class ResultController: ViewController {
    @IBOutlet weak var tableView1 : UITableView!
    @IBOutlet weak var tableView2 : UITableView!
    @IBOutlet weak var indicator: UIActivityIndicatorView!

    let model = ResultModel()
    var results = [String]()
    
    // params.
    var image : UIImage!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setTableView()
        
        // データを取得する.
        getData()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    private func getData() {
        indicator.startAnimating()
        model.createRequest(image: image)
    }
    
    private func setTableView() {
        tableView1.tableFooterView = UIView()
        tableView1.delegate = self
        tableView1.dataSource = self
        
        tableView2.tableFooterView = UIView()
        tableView2.delegate = self
        tableView2.dataSource = self
        
        model.delegate = self
    }
}

extension ResultController : ResultModelDelegate {
    func complete(result: String?) {
        indicator.stopAnimating()
        guard let contentArray = result?.components(separatedBy: "\n") else {return}
        
        for content in contentArray {
            if (content.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) == "") {
                continue
            }
            
            results.append(content)
        }
        
        print("results = \(results)")
        
        tableView1.reloadData()
{'fraction_non_alphanumeric': 0.09096553865259237, 'fraction_numerical': 0.016764979819931698, 'mean_word_length': 2.11003861003861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3201497', 'n_tokens_mistral': 953, 'n_tokens_neox': 903, 'n_words': 206}