<commit_before>"use strict";

const _ = require("underscore");

function Message(requiredArguments, optionalKeyboard, optionalTrackingData, timestamp, token) {
	this.timestamp = timestamp;
	this.token = token;
	this.trackingData = this._parseTrackingData(optionalTrackingData);
	this.keyboard = !optionalKeyboard ? null : optionalKeyboard;

	this._verifyNonNull(this, requiredArguments);
	Object.freeze(this);
}

Message.fromJson = function(jsonMessage, timestamp, token) {
	throw new Error("not implemented");
};

Message.getType = function() {
	throw new Error("not implemented");
};

Message.prototype.toJson = function() {
	throw new Error("not implemented");
};

Message.prototype._verifyNonNull = function(object, requiredArguments) {
	requiredArguments.forEach(argument => {
		if (!_.has(object, argument) || !_.result(object, argument, null)) {
			throw new Error(`Missing required argument ${argument}`);
		}
	});
};

Message.prototype._parseTrackingData = function(optionalTrackingData) {
	if (!optionalTrackingData) return {};
	if (_.isObject(optionalTrackingData)) return optionalTrackingData;
	
	let trackingData = null;
	try {<commit_msg>More flexible messages<commit_after>"use strict";

const _ = require("underscore");

function Message(requiredArguments, optionalKeyboard, optionalTrackingData, timestamp, token) {
	this.timestamp = timestamp;
	this.token = token;
	this.trackingData = this._parseTrackingData(optionalTrackingData);
	this.keyboard = !optionalKeyboard ? null : optionalKeyboard;

	this._verifyNonNull(this, requiredArguments);
	// Object.freeze(this);
}

Message.fromJson = function(jsonMessage, timestamp, token) {
	throw new Error("not implemented");
};

Message.getType = function() {
	throw new Error("not implemented");
};

Message.prototype.toJson = function() {
	throw new Error("not implemented");
};

Message.prototype._verifyNonNull = function(object, requiredArguments) {
	requiredArguments.forEach(argument => {
		if (!_.has(object, argument) || !_.result(object, argument, null)) {
			throw new Error(`Missing required argument ${argument}`);
		}
	});
};

Message.prototype._parseTrackingData = function(optionalTrackingData) {
	if (!optionalTrackingData) return {};
	if (_.isObject(optionalTrackingData)) return optionalTrackingData;
	
	let trackingData = null;
	try {
{'fraction_non_alphanumeric': 0.12953367875647667, 'fraction_numerical': 0.0, 'mean_word_length': 6.332278481012659, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7112521', 'n_tokens_mistral': 660, 'n_tokens_neox': 655, 'n_words': 146}