<commit_before>var fs = require('fs'),
		sizeOf = require('image-size'),
		common = require('./common'),
		TEASER_IMAGE_PATTERN = '.+-teaser',
		PORTFOLIO_OUT_FILE = '_data/portfolio.json',
		rootDirectory = process.argv[2];

function getImageSize(image) {
	var imageSize = sizeOf(image);
	return imageSize.width.toString() + 'x' + imageSize.height.toString();
}

function removeExtension(image) {
	return image.replace(/\.[^/.]+$/, "");
}

if(!rootDirectory) {
	console.log('Specify a directory');
	return;
}

rootDirectory = rootDirectory.replace(/\\/g, '/');

var results = [];
common.walk(rootDirectory, results, function(error) {
	if(error) {
		throw error;
	}

	results = results.filter(function(value) {
		return value.search(TEASER_IMAGE_PATTERN) === -1;
	});

	var portfolio = {};
	results.forEach(function(value) {
		var splitValues = value.split('/'),
				group = splitValues[2];

		portfolio[group] = portfolio[group] || [];
		portfolio[group].push({
			title: removeExtension(splitValues[3]),
			size: getImageSize(value)
		});
	});

	fs.writeFile(PORTFOLIO_OUT_FILE, JSON.stringify(portfolio, null, 2), function(err) {
		if(err) {
			return console.log(err);
		}
		console.log(PORTFOLIO_OUT_FILE + ' successfully created.');
	});
});<commit_msg>Fixed splitting path.<commit_after>var fs = require('fs'),
		sizeOf = require('image-size'),
		common = require('./common'),
		TEASER_IMAGE_PATTERN = '.+-teaser',
		PORTFOLIO_OUT_FILE = '_data/portfolio.json',
		rootDirectory = process.argv[2];

function getImageSize(image) {
	var imageSize = sizeOf(image);
	return imageSize.width.toString() + 'x' + imageSize.height.toString();
}

function removeExtension(image) {
	return image.replace(/\.[^/.]+$/, "");
}

function splitPath(path) {
	return path.split(/\/+/g);
}

if(!rootDirectory) {
	console.log('Specify a directory');
	return;
}

rootDirectory = rootDirectory.replace(/\\/g, '/');

var results = [];
common.walk(rootDirectory, results, function(error) {
	if(error) {
		throw error;
	}

	results = results.filter(function(value) {
		return value.search(TEASER_IMAGE_PATTERN) === -1;
	});

	var portfolio = {};
	results.forEach(function(value) {
		var splitValues = splitPath(value),
				group = splitValues[2];

		portfolio[group] = portfolio[group] || [];
		portfolio[group].push({
			title: removeExtension(splitValues[3]),
			size: getImageSize(value)
		});
	});

	fs.writeFile(PORTFOLIO_OUT_FILE, JSON.stringify(portfolio, null, 2), function(err) {
		if(err) {
			return console.log(err);
		}
		console.log(PORTFOLIO_OUT_FILE + ' successfully created.');
	});
});
{'fraction_non_alphanumeric': 0.1803405572755418, 'fraction_numerical': 0.003869969040247678, 'mean_word_length': 4.7317073170731705, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6060247', 'n_tokens_mistral': 941, 'n_tokens_neox': 881, 'n_words': 150}