<commit_before>/*
 * grunt-schema-markup
 * https://github.com/BenPoulson/grunt-schema-markup
 *
 * Copyright (c) 2015 <NAME>
 * Licensed under the MIT license.
 */

var definitions = {};
var path = require("path");
var cheerio = require('cheerio');

exports.setContext = function (context, grunt) {
	definitions = context;
	grunt.verbose.write("\nOverwriting the complete definitions context..\n".yellow);
	for (var prop in context)
		grunt.verbose.write("Setting definition " + prop.cyan + " to " + context[prop].cyan + "\n");
	grunt.verbose.write("\n");
};

exports.preprocess = function (grunt, src, options) {

	var contents = grunt.file.read(src);
	var $ = cheerio.load(contents, {
		normalizeWhitespace: false,
		xmlMode: false,
		decodeEntities: false
	});


	$('*').filter(function() {
		for(var k in $(this)[0].attribs){
			if(k.indexOf("schema-") === 0){
				$(this).removeAttr(k);
				$(this).attr('itemscope', '');
				$(this).attr('itemtype', 'http://schema.org/' + k.replace('schema-', ''));
			} else if(k.indexOf("prop-") === 0){
				$(this).removeAttr(k);
				$(this).attr('itemprop', k.replace('prop-', ''));
			}
		}
	});

	contents = $.html().replace(/\=\"\"/g, 	'');

	return contents;
};<commit_msg>Swap these around for a slight performance gain<commit_after>/*
 * grunt-schema-markup
 * https://github.com/BenPoulson/grunt-schema-markup
 *
 * Copyright (c) 2015 <NAME>
 * Licensed under the MIT license.
 */

var definitions = {};
var path = require("path");
var cheerio = require('cheerio');

exports.setContext = function (context, grunt) {
	definitions = context;
	grunt.verbose.write("\nOverwriting the complete definitions context..\n".yellow);
	for (var prop in context)
		grunt.verbose.write("Setting definition " + prop.cyan + " to " + context[prop].cyan + "\n");
	grunt.verbose.write("\n");
};

exports.preprocess = function (grunt, src, options) {

	var contents = grunt.file.read(src);
	var $ = cheerio.load(contents, {
		normalizeWhitespace: false,
		xmlMode: false,
		decodeEntities: false
	});


	$('*').filter(function() {
		for(var k in $(this)[0].attribs) {
			if(k.indexOf("prop-") === 0) {
				$(this).removeAttr(k);
				$(this).attr('itemprop', k.replace('prop-', ''));
			} else if(k.indexOf("schema-") === 0) {
				$(this).removeAttr(k);
				$(this).attr('itemscope', '');
				$(this).attr('itemtype', 'http://schema.org/' + k.replace('schema-', ''));
			}
		} 
	});

	contents = $.html().replace(/\=\"\"/g, 	'');

	return contents;
};
{'fraction_non_alphanumeric': 0.21514907332796132, 'fraction_numerical': 0.0056406124093473006, 'mean_word_length': 3.9071146245059287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6839303', 'n_tokens_mistral': 937, 'n_tokens_neox': 857, 'n_words': 169}