<commit_before>var videoID = process.argv[2];
if(!videoID) {
	console.error("No Video ID!");
	process.exit(1);
}


var db = require("./lib/database.js")();
/* Create a new table, overwrite if exists */
db.createCommentsTable(videoID, true);
db.createRepliesTable(videoID, true);

var commentStream = require("youtube-comment-stream")(videoID);
var JSONStream = require('json-stream');
var totalComments = 0;
var commentBuffer = [];

var jsonStream = new JSONStream();

jsonStream.on('data', function(comment) {
	commentBuffer.push(comment);
	if(++totalComments % 500 == 0) {
		console.log("-- Scraped " + totalComments + " comments so far");
		db.insertComments(commentBuffer, videoID);
		commentBuffer = [];
	}
});

jsonStream.on('end', function() {
	db.insertComments(commentBuffer, videoID);
	console.log("\nScraped " + totalComments + " comments total.");
});
<commit_msg>include replies in the comment count<commit_after>var videoID = process.argv[2];
if(!videoID) {
	console.error("No Video ID!");
	process.exit(1);
}


var db = require("./lib/database.js")();
/* Create a new table, overwrite if exists */
db.createCommentsTable(videoID, true);
db.createRepliesTable(videoID, true);

var commentStream = require("youtube-comment-stream")(videoID);
var JSONStream = require('json-stream');
var totalComments = 0;
var commentBuffer = [];

var jsonStream = new JSONStream();

jsonStream.on('data', function(comment) {
	commentBuffer.push(comment);
	//count the replies for the comment as well
	totalComments += 1 + (comment.hasReplies ? comment.replies.length : 0);
	
	if(totalComments % 500 === 0) {
		console.log("-- Scraped " + totalComments + " comments so far");
		db.insertComments(commentBuffer, videoID);
		commentBuffer = [];
	}
});

jsonStream.on('end', function() {
	db.insertComments(commentBuffer, videoID);
	console.log("\nScraped " + totalComments + " comments total.");
});

{'fraction_non_alphanumeric': 0.16578669482576558, 'fraction_numerical': 0.008447729672650475, 'mean_word_length': 5.316666666666666, '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': '2285793', 'n_tokens_mistral': 630, 'n_tokens_neox': 592, 'n_words': 138}