<commit_before> // This module loads the handlebars template engine and adds custom extensions
 // Those are mainly helper functions that make wikitext generation easier

var handlebars = require('handlebars');

/**
 * mobo options, injected through setMoboOptions(options)
 * @type {{}}
 */
handlebars.moboSettings = {};


//////////////////////////////////////////
// Handlebars Custom Extensions         //
//////////////////////////////////////////

/**
 * Generate SMW Template Attribute
 */
handlebars.registerHelper('smw_templ_attr', function(attr) {
    'use strict';

    var result = '';
    var attributeName = attr.id || 'UNDEFINED';

    var prefix = '';
    var suffix = '';
    var contentType = 'text';
    var targetForm = '';

    /** If "oneOf" property is used, the formredlink will offer alternative forms */
    var alternativeForms = '';

    // Check if the attribute contains text or links to a page
    // This is done by checking if the format is of type "Page" or links to a Form (starts with "/")
    var format = attr.format || false;
    if (attr.items && attr.items.format) {
        format = attr.items.format;
    }

    if (format && format.toLowerCase() === 'page') {
        contentType = 'page';
    } else if (format && format.charAt(0) === '/') {
        contentType = 'form';
        var formatArray = format.split('/');
        targetForm = '|form=' + formatArray[2].replace('.json', '');
    }

    // Handle properties that link to multiple forms
    var oneOf = false;
    if (attr.oneOf && attr.oneOf[0]) {
        oneOf = attr.oneOf;
    } else if (attr.items && attr.items.oneOf && attr.items.oneOf[0]) {
        oneOf = attr.items.oneOf;
    }

    if (oneOf) {

        targetForm = '';
        contentType = 'form';

        for (var i = 0; i < oneOf.length; i += 1) {

            if (oneOf[i].format) {
                format = oneOf[i].format;
                var niceFormatArray = format.split('/');
                var niceFormat = niceFormatArray[2].replace('.json', '');

                // If the first defined form should be used as default
                // The other forms will then be offered as alternatives
                if (i === 0 && handlebars.moboSettings.firstAlternativeFormAsDefault) {
                    targetForm = '|form=' + niceFormat;
                    continue;
                }

                alternativeForms += '|alt_form[' + i + ']=' + niceFormat;
            }

        }

    }

    /** Separator for fields with multiple items / entries */
    var sep = handlebars.moboSettings.arraymapSeparator || ';';

    // Calculate Pre- and Suffix for the Field text / Link URL
    // Special Case: Namecases require manual settings
    if (attr.smw_form && attr.smw_form['values from namespace']) {
        prefix += attr.smw_form['values from namespace'] + ':';
    }
    if (attr.mobo && attr.mobo.displayPrefix) {
        prefix += attr.mobo.displayPrefix;
    }
    if (attr.mobo && attr.mobo.displaySuffix) {
        suffix += attr.mobo.displaySuffix;
    }

    var finalPropertyName = prefix + '{{{' + attributeName + '|}}}' + suffix;
    var finalPropertyArrayMap =  prefix + '@@@@' + suffix;

    // Differentiente between ArrayMaps and single attributes
    if (attr.smw_arraymap) {

        // MULTIPLE VALUES PROPERTIES (#arraymap)

        if (contentType === 'page') {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|[[' + finalPropertyArrayMap + '{{!}}@@@@]]|' + sep + '&nbsp;}}';
        } else if (contentType === 'form') {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|{{#formredlink:target=' + finalPropertyArrayMap + targetForm + alternativeForms + '|link text=@@@@ }}|' + sep + '&nbsp;}}';
        } else {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|' + finalPropertyArrayMap + '|' + sep + '&nbsp;}}';
        }<commit_msg>values from namespace hack removed<commit_after> // This module loads the handlebars template engine and adds custom extensions
 // Those are mainly helper functions that make wikitext generation easier

var handlebars = require('handlebars');

/**
 * mobo options, injected through setMoboOptions(options)
 * @type {{}}
 */
handlebars.moboSettings = {};


//////////////////////////////////////////
// Handlebars Custom Extensions         //
//////////////////////////////////////////

/**
 * Generate SMW Template Attribute
 */
handlebars.registerHelper('smw_templ_attr', function(attr) {
    'use strict';

    var result = '';
    var attributeName = attr.id || 'UNDEFINED';

    var prefix = '';
    var suffix = '';
    var contentType = 'text';
    var targetForm = '';

    /** If "oneOf" property is used, the formredlink will offer alternative forms */
    var alternativeForms = '';

    // Check if the attribute contains text or links to a page
    // This is done by checking if the format is of type "Page" or links to a Form (starts with "/")
    var format = attr.format || false;
    if (attr.items && attr.items.format) {
        format = attr.items.format;
    }

    if (format && format.toLowerCase() === 'page') {
        contentType = 'page';
    } else if (format && format.charAt(0) === '/') {
        contentType = 'form';
        var formatArray = format.split('/');
        targetForm = '|form=' + formatArray[2].replace('.json', '');
    }

    // Handle properties that link to multiple forms
    var oneOf = false;
    if (attr.oneOf && attr.oneOf[0]) {
        oneOf = attr.oneOf;
    } else if (attr.items && attr.items.oneOf && attr.items.oneOf[0]) {
        oneOf = attr.items.oneOf;
    }

    if (oneOf) {

        targetForm = '';
        contentType = 'form';

        for (var i = 0; i < oneOf.length; i += 1) {

            if (oneOf[i].format) {
                format = oneOf[i].format;
                var niceFormatArray = format.split('/');
                var niceFormat = niceFormatArray[2].replace('.json', '');

                // If the first defined form should be used as default
                // The other forms will then be offered as alternatives
                if (i === 0 && handlebars.moboSettings.firstAlternativeFormAsDefault) {
                    targetForm = '|form=' + niceFormat;
                    continue;
                }

                alternativeForms += '|alt_form[' + i + ']=' + niceFormat;
            }

        }

    }

    /** Separator for fields with multiple items / entries */
    var sep = handlebars.moboSettings.arraymapSeparator || ';';

    // Add Pre- and Suffix for the Field text / Link URL
    if (attr.mobo && attr.mobo.displayPrefix) {
        prefix += attr.mobo.displayPrefix;
    }
    if (attr.mobo && attr.mobo.displaySuffix) {
        suffix += attr.mobo.displaySuffix;
    }

    var finalPropertyName = prefix + '{{{' + attributeName + '|}}}' + suffix;
    var finalPropertyArrayMap =  prefix + '@@@@' + suffix;

    // Differentiente between ArrayMaps and single attributes
    if (attr.smw_arraymap) {

        // MULTIPLE VALUES PROPERTIES (#arraymap)

        if (contentType === 'page') {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|[[' + finalPropertyArrayMap + '{{!}}@@@@]]|' + sep + '&nbsp;}}';
        } else if (contentType === 'form') {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|{{#formredlink:target=' + finalPropertyArrayMap + targetForm + alternativeForms + '|link text=@@@@ }}|' + sep + '&nbsp;}}';
        } else {
            result = '{{#arraymap:{{{' + attributeName + '|}}}|' + sep + '|@@@@|' + finalPropertyArrayMap + '|' + sep + '&nbsp;}}';
        }
{'fraction_non_alphanumeric': 0.17518532969176745, 'fraction_numerical': 0.002080894784757446, 'mean_word_length': 2.1882255389718077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7564268', 'n_tokens_mistral': 2258, 'n_tokens_neox': 2184, 'n_words': 597}