<commit_before>//
//  IDFYMockGenerator.swift
//  iDecide4U
//
//  Created by <NAME> on 01/05/2015.
//  Copyright (c) 2015 <EMAIL>. All rights reserved.
//

import Foundation
import CoreData

private let managedObjectContext = IDFYCoreDataStack.sharedCoreDataStack().managedObjectContext!
private let optionListEntityName = IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName
private let lastUsedListName = "iDecide4u.lastUsedListName"

class IDFYMockGenerator {
  
  class func wipeOutDatabase() {
    let fetchRequest = NSFetchRequest(entityName: optionListEntityName)
    var error: NSError?
    let fetchResult = managedObjectContext.executeFetchRequest(fetchRequest, error: &error) as! [IDFYManagedOptionList]
    if let error = error {
      println("Error loading option list from data base: " + error.description)
      abort()
    }
    for managedOptionList : IDFYManagedOptionList in fetchResult {
      managedObjectContext.deleteObject(managedOptionList)
    }
    NSUserDefaults.standardUserDefaults().removeObjectForKey(lastUsedListName)
  }
  
  class func createMockDatabaseEntries() {
    let list1 = NSEntityDescription.insertNewObjectForEntityForName(IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName, inManagedObjectContext: managedObjectContext) as? IDFYManagedOptionList
    list1!.name = "Meals"
    list1!.options = ["Burger", "Pizza", "Lasagne"]
    let list2 = NSEntityDescription.insertNewObjectForEntityForName(IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName, inManagedObjectContext: managedObjectContext) as? IDFYManagedOptionList
    list2!.name = "Evening events"
    list2!.options = ["cinema", "billard", "going out"]
    NSUserDefaults.standardUserDefaults().setObject(list1?.name, forKey: lastUsedListName)
  }
  
}<commit_msg>IDFY-18: Add example lists (which can later be used in production as well).<commit_after>//
//  IDFYMockGenerator.swift
//  iDecide4U
//
//  Created by <NAME> on 01/05/2015.
//  Copyright (c) 2015 <EMAIL>. All rights reserved.
//

import Foundation
import CoreData

private let managedObjectContext = IDFYCoreDataStack.sharedCoreDataStack().managedObjectContext!
private let optionListEntityName = IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName
private let lastUsedListName = "iDecide4u.lastUsedListName"

class IDFYMockGenerator {
  
  class func wipeOutDatabase() {
    let fetchRequest = NSFetchRequest(entityName: optionListEntityName)
    var error: NSError?
    let fetchResult = managedObjectContext.executeFetchRequest(fetchRequest, error: &error) as! [IDFYManagedOptionList]
    if let error = error {
      println("Error loading option list from data base: " + error.description)
      abort()
    }
    for managedOptionList : IDFYManagedOptionList in fetchResult {
      managedObjectContext.deleteObject(managedOptionList)
    }
    NSUserDefaults.standardUserDefaults().removeObjectForKey(lastUsedListName)
  }
  
  class func createMockDatabaseEntries() {
    
    let list1 = NSEntityDescription.insertNewObjectForEntityForName(IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName, inManagedObjectContext: managedObjectContext) as? IDFYManagedOptionList
    list1!.name = "meals"
    list1!.options = ["pizza", "lasagne", "vegetable gratin", "bread", "spinach and potatoes"]
    
    let list2 = NSEntityDescription.insertNewObjectForEntityForName(IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName, inManagedObjectContext: managedObjectContext) as? IDFYManagedOptionList
    list2!.name = "evening activities"
    list2!.options = ["cinema", "billard", "go for a meal"]
    
    let list3 = NSEntityDescription.insertNewObjectForEntityForName(IDFYCoreDataStack.sharedCoreDataStack().optionListEntityName, inManagedObjectContext: managedObjectContext) as? IDFYManagedOptionList
    list3!.name = "vacation"
    list3!.options = ["Hawaii", "Bali", "Australia"]
    
//    NSUserDefaults.standardUserDefaults().setObject("", forKey: lastUsedListName)
  }
  
}
{'fraction_non_alphanumeric': 0.09145427286356822, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 5.313880126182966, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5158029', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1140, 'n_words': 240}