<commit_before>//
//  NSDictionary+RGAppTools.swift
//  RGAppTools
//
//  Created by RAIN on 16/2/5.
//  Copyright © 2016-2017 Smartech. All rights reserved.
//

import Foundation

extension RGAppTools where Base: NSDictionary {
    /// 检验 NSDictionary 中是否存在某个 key
    ///
    /// - Parameter key: 待检验的 key
    /// - Returns: 检验结果的布尔值
    public func isHave(key: String) -> Bool {
       return base.value(forKey: key) != nil
    }
}

//  MARK: Main Bundle
extension NSDictionary {
    /**
     获取 Main Bundle 中某个文件的内容, 创建为 NSDictionary
     
     - parameter name: 文件名
     - parameter ext:  文件扩展名
     
     - returns: 文件路径
     */
    public convenience init?(mainBundlePathForResource name: String?, ofType ext: String?) {
        guard let path = Bundle.main.path(forResource: name, ofType: ext) else {
            print("RGApptools: NSDictionary init with main bundle path for resource of type is nil")
            return nil
        }
        self.init(contentsOfFile: path)
    }
}

//  MARK: Check key exist or not
extension NSDictionary {
    /**
     检验 NSDictionary 中是否存在某个 key
     
     - parameter key: 待检验的 key
     
     - returns: 检验结果的布尔值
     */
    @available(*, deprecated, message: "Extensions directly on NSDictionary are deprecated. Use `NSDictionary.rat.isHave(key:)` instead.", renamed: "rat.isHave(key:)")
    func rat_isHaveKey(_ key: String) -> Bool {
        let keys = self.allKeys as! [String]
        for aKey: String in keys {
            if key == aKey {
                return true
            }
        }
        return false
    }
}<commit_msg>docs (NSDictionary) : update comments<commit_after>//
//  NSDictionary+RGAppTools.swift
//  RGAppTools
//
//  Created by RAIN on 16/2/5.
//  Copyright © 2016-2017 Smartech. All rights reserved.
//

import Foundation

extension RGAppTools where Base: NSDictionary {

    /// 检验 NSDictionary 中是否存在某个 key
    /// - Parameter key: 待检验的 key
    /// - Returns: 检验结果的布尔值
    public func isHave(key: String) -> Bool {
       return base.value(forKey: key) != nil
    }

}


// MARK: - Main Bundle

extension NSDictionary {

    /// 获取 Main Bundle 中某个文件的内容, 创建为 NSDictionary
    /// - Parameters:
    ///   - name: 文件名
    ///   - ext: 文件扩展名
    public convenience init?(mainBundlePathForResource name: String?, ofType ext: String?) {
        guard let path = Bundle.main.path(forResource: name, ofType: ext) else {
            print("RGApptools: NSDictionary init with main bundle path for resource of type is nil")
            return nil
        }
        self.init(contentsOfFile: path)
    }

}


// MARK: - Check key exist or not

extension NSDictionary {

    /// 检验 NSDictionary 中是否存在某个 key
    /// - Parameter key: 待检验的 key
    /// - Returns: 检验结果的布尔值
    @available(*, deprecated, message: "Extensions directly on NSDictionary are deprecated. Use `NSDictionary.rat.isHave(key:)` instead.", renamed: "rat.isHave(key:)")
    func rat_isHaveKey(_ key: String) -> Bool {
        let keys = self.allKeys as! [String]
        for aKey: String in keys {
            if key == aKey {
                return true
            }
        }
        return false
    }

}
{'fraction_non_alphanumeric': 0.10796178343949045, 'fraction_numerical': 0.007643312101910828, 'mean_word_length': 2.1284860557768925, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2650429', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1071, 'n_words': 294}