<commit_before>//
//  NSManagedObjectContextExtension.swift
//  SGYSwiftUtility
//
//  Created by <NAME> on 2/13/16.
//
//

import Foundation
import CoreData

extension NSManagedObjectContext {
    
    func existingObject<T: NSManagedObject>(with objectID: NSManagedObjectID) throws -> T {
        // Force cast since object not found will throw and if an object is found of the wrong type the caller messed up.
        return try existingObject(with: objectID) as! T
    }
    
    func fetch<T: NSManagedObject>(_ request: NSFetchRequest<T>) throws -> T? {
        // We only expect one entry so limit request
        request.fetchLimit = 1
        return try fetch(request).first
    }
}<commit_msg>Modified NSManagedObjectContext to make extended functions public.<commit_after>//
//  NSManagedObjectContextExtension.swift
//  SGYSwiftUtility
//
//  Created by <NAME> on 2/13/16.
//
//

import Foundation
import CoreData

extension NSManagedObjectContext {
    
    public func existingObject<T: NSManagedObject>(with objectID: NSManagedObjectID) throws -> T {
        // Force cast since object not found will throw and if an object is found of the wrong type the caller messed up.
        return try existingObject(with: objectID) as! T
    }
    
    public func fetch<T: NSManagedObject>(_ request: NSFetchRequest<T>) throws -> T? {
        // We only expect one entry so limit request
        request.fetchLimit = 1
        return try fetch(request).first
    }
}
{'fraction_non_alphanumeric': 0.08486082824168364, 'fraction_numerical': 0.008146639511201629, 'mean_word_length': 2.9202127659574466, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5394399', 'n_tokens_mistral': 416, 'n_tokens_neox': 402, 'n_words': 146}