<commit_before>/**
 * Utils.c
 * Some useful applicable of libRay.
 * Author <NAME> (<EMAIL>)
 * 05/05/2015 Ukraine Kharkiv
 *  _         _ _ _
 * | |       (_|_) |
 * | | _____  _ _| |__   __ _
 * | |/ / _ \| | | '_ \ / _` |
 * |   < (_) | | | |_) | (_| |
 * |_|\_\___/| |_|_.__/ \__,_|
 *          _/ |
 *         |__/
 **/

#include <Utils.h>
#include <RString_Consts.h>

rbool processLine(pointer context, pointer string, size_t iterator) {
    $(string, m(trimAfterString, RCString)), RS("//")); // trim comment
    if(((RCString*)string)->size != 0) { // if not fully comment
        RArray *keyValue = $(string, m(substringsSeparatedByString, RCString)), RS(" = "));
        if(keyValue != nil) {
            RCString *key   = $(keyValue, m(elementAtIndex, RArray)), 0);
            RCString *value = $(keyValue, m(lastObject, RArray)));

            // adding
            $(context, m(setObjectForKey, RDictionary)), value, key);

            $(keyValue, m(setDestructorDelegate, RArray)), nil);
            deleter(keyValue, RArray);
        }
    }
    return yes;
}

RDictionary * stringDictionaryFromFile(char *filename) {
    RCString *locales = stringFromFile(filename);

    if(locales != nil) {
        RDictionary *result = makeRDictionary();
        if(result != nil) {
            REnumerateDelegate delegate;<commit_msg>stringDictionaryFromFile changed to separatedByStringWithShield<commit_after>/**
 * Utils.c
 * Some useful applicable of libRay.
 * Author <NAME> (<EMAIL>)
 * 05/05/2015 Ukraine Kharkiv
 *  _         _ _ _
 * | |       (_|_) |
 * | | _____  _ _| |__   __ _
 * | |/ / _ \| | | '_ \ / _` |
 * |   < (_) | | | |_) | (_| |
 * |_|\_\___/| |_|_.__/ \__,_|
 *          _/ |
 *         |__/
 **/

#include <Utils.h>
#include <RString_Consts.h>

rbool processLine(pointer context, pointer string, size_t iterator) {
    $(string, m(trimAfterString, RCString)), RS("//")); // trim comment
    if(((RCString*)string)->size != 0) { // if not fully comment
        RArray *keyValue = $(string, m(separatedByStringWithShield, RCString)), RS(" = "), RS("\\"));
        if(keyValue != nil) {
            RCString *key   = $(keyValue, m(elementAtIndex, RArray)), 0);
            RCString *value = $(keyValue, m(lastObject, RArray)));

            // adding
            $(context, m(setObjectForKey, RDictionary)), value, key);

            $(keyValue, m(setDestructorDelegate, RArray)), nil);
            deleter(keyValue, RArray);
        }
    }
    return yes;
}

RDictionary * stringDictionaryFromFile(char *filename) {
    RCString *locales = stringFromFile(filename);

    if(locales != nil) {
        RDictionary *result = makeRDictionary();
        if(result != nil) {
            REnumerateDelegate delegate;
{'fraction_non_alphanumeric': 0.17116788321167883, 'fraction_numerical': 0.0072992700729927005, 'mean_word_length': 2.396530359355638, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '7131141', 'n_tokens_mistral': 921, 'n_tokens_neox': 884, 'n_words': 171}