<commit_before>/**
 * Calculates the specificity of CSS selectors
 * http://www.w3.org/TR/css3-selectors/#specificity
 *
 * Returns an array of objects with the following properties:
 *  - selector: the input
 *  - specificity: e.g. 0,1,0,0
 */

var calculate = function(input) {
	var selectors,
		selector,
		i,
		len,
		results = [];

	// Separate input by commas
	selectors = input.split(',');

	for (i = 0, len = selectors.length; i < len; i += 1) {
		selector = selectors[i];
		if (selector.length > 0) {
			results.push(calculateSingle(selector));
		}
	}

	return results;
};

// Calculate the specificity for a selector by dividing it into simple selectors and counting them
var calculateSingle = function(input) {
	var selector = input,
		findMatch,
		typeCount = {
			'a': 0,
			'b': 0,
			'c': 0
		},
		// The following regular expressions assume that selectors matching the preceding regular expressions have been removed
		attributeRegex = /(\[[^\]]+\])/g,
		idRegex = /(#[^\s\+>~\.\[:]+)/g,
		classRegex = /(\.[^\s\+>~\.\[:]+)/g,
		pseudoElementRegex = /(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/g,
		pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g,
		elementRegex = /([^\s\+>~\.\[:]+)/g;

	// Find matches for a regular expression in a string and push their details to parts
	// Type is "a" for IDs, "b" for classes, attributes and pseudo-classes and "c" for elements and pseudo-elements
	findMatch = function(regex, type) {
		var matches, i, len, match, index, length;
		if (regex.test(selector)) {
			matches = selector.match(regex);
			for (i = 0, len = matches.length; i < len; i += 1) {<commit_msg>Remove duplicate selector vars<commit_after>/**
 * Calculates the specificity of CSS selectors
 * http://www.w3.org/TR/css3-selectors/#specificity
 *
 * Returns an array of objects with the following properties:
 *  - selector: the input
 *  - specificity: e.g. 0,1,0,0
 */

var calculate = function(input) {
	var selectors,
		selector,
		i,
		len,
		results = [];

	// Separate input by commas
	selectors = input.split(',');

	for (i = 0, len = selectors.length; i < len; i += 1) {
		selector = selectors[i];
		if (selector.length > 0) {
			results.push(calculateSingle(selector));
		}
	}

	return results;
};

// Calculate the specificity for a selector by dividing it into simple selectors and counting them
var calculateSingle = function(selector) {
	var findMatch,
		typeCount = {
			a: 0,
			b: 0,
			c: 0
		},
		// The following regular expressions assume that selectors matching the preceding regular expressions have been removed
		attributeRegex = /(\[[^\]]+\])/g,
		idRegex = /(#[^\s\+>~\.\[:]+)/g,
		classRegex = /(\.[^\s\+>~\.\[:]+)/g,
		pseudoElementRegex = /(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/g,
		pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g,
		elementRegex = /([^\s\+>~\.\[:]+)/g;

	// Find matches for a regular expression in a string and push their details to parts
	// Type is "a" for IDs, "b" for classes, attributes and pseudo-classes and "c" for elements and pseudo-elements
	findMatch = function(regex, type) {
		var matches, i, len, match, index, length;
		if (regex.test(selector)) {
			matches = selector.match(regex);
			for (i = 0, len = matches.length; i < len; i += 1) {
{'fraction_non_alphanumeric': 0.17835178351783518, 'fraction_numerical': 0.008610086100861008, 'mean_word_length': 3.35475234270415, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2304127', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1090, 'n_words': 333}