<commit_before>//
//  QuizletTermDefinition+CoreDataClass.swift
//  FlashcardHero
//
//  Created by <NAME> on 11/3/16.
//  Copyright © 2016 Zero Mu, LLC. All rights reserved.
//

import Foundation
import CoreData


public class QuizletTermDefinition: QuizletSet {

}<commit_msg>first draft of QuizletTermDefinition CoreData object<commit_after>//
//  QuizletTermDefinition+CoreDataClass.swift
//  FlashcardHero
//
//  Created by <NAME> on 11/3/16.
//  Copyright © 2016 Zero Mu, LLC. All rights reserved.
//

import Foundation
import CoreData


public class QuizletTermDefinition: QuizletSet {

    //TODO: have this object load the image from url when imageUrl is set or changed
    
    convenience init(withQuizletTermResult: QuizletGetTermResult, relatedSet: QuizletSet, context: NSManagedObjectContext){
        
        if let ent = NSEntityDescription.entity(forEntityName: "QuizletTermDefinition", in: context) {
            self.init(entity: ent, insertInto: context)
            
            //using the FlickrPhotoResult, populate this object
            if  let id = withQuizletTermResult.id,
                let term = withQuizletTermResult.term,
                let definition = withQuizletTermResult.definition,
                let rank = withQuizletTermResult.rank {
                
                self.id = Int64(id)
                self.term = term
                self.definition = definition
                self.rank = Int64(rank)
                
                //image is optional or blank
                if let image = withQuizletTermResult.image {
                    
                    //TODO: add validation
                    //TODO: Don't hard code this
                    self.imageHeight = image["image_height"] as! Int64
                    self.imageUrl = image["image_url"] as? String
                    self.imageWidth = image["image_width"] as! Int64
                }

                //add the related set
                self.quizletSet = relatedSet
                
            } else {
                //TODO: throw an error because everything wasn't as expected
            }
        } else {
            fatalError("Unable to find Entity name! (QuizletTermDefinition)")
        }
        
    }
}
{'fraction_non_alphanumeric': 0.07654650645304852, 'fraction_numerical': 0.011570983533600357, 'mean_word_length': 1.7481662591687042, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1885356', 'n_tokens_mistral': 626, 'n_tokens_neox': 579, 'n_words': 167}