<commit_before>/* Main */

$("#input").focus();

$("#input").keydown(function(e) {
	if (e.which == 13) {  // enter
		e.preventDefault();
	}
	else if (e.which == 32) {  // space
		feed($(this).val())

		$(this).val("")
		e.preventDefault();
	}
	else if (e.which == 190) {  // period
		alert('period');

		e.preventDefault();
	}
});

/* API functions */

function feed(term) {
	var row = buildHistoryRow(term);
	$("#history").append(row);

	var url = "/_models/" + window.MODEL_ID + "/feed/" + term;
	$.postq("feed", url, function(data) {
		updateHistoryRow(row, data);
	});
}

/* Utility functions */

function buildHistoryRow(term) {
	return $("<tr><td class='term'>" +
	          term + "</td><td class='prediction'>" +
	          "<img src='/static/img/loading.gif' />" +
	          "</td></tr>");
}

function updateHistoryRow(row, prediction) {
	row.children(".prediction").text(prediction);
}<commit_msg>Progress on UI<commit_after>/* Main */

$("#input").focus();

$("#input").keydown(function(e) {
	if (e.which == 13) {  // enter
		e.preventDefault();
	}
	else if (e.which == 32 || e.which == 190) {  // space or period
		val = $(this).val();
		if (val.length) feed(val);

		if (e.which == 190) {  // period
			reset();
		}

		$(this).val("");
		e.preventDefault();
	}
});

/* API functions */

function feed(term) {
	var row = buildHistoryRow(term);
	$("#history").append(row);

	var url = "/_models/" + window.MODEL_ID + "/feed/" + term;
	$.postq("api", url, function(data) {
		updateHistoryRow(row, data);
	});
}

function reset() {
	row = buildHistoryRowEmpty();
	$("#history").append(row);

	var url = "/_models/" + window.MODEL_ID + "/reset";
	$.postq("api", url, function(data) {});
}

/* DOM functions */

function updateHistoryRow(row, prediction) {
	row.children(".prediction").text(prediction);
}

/* Utility functions */

function buildHistoryRow(term) {
	return $("<tr><td class='term'>" +
	          term + "</td><td class='prediction'>" +
	          "<img src='/static/img/loading.gif' />" +
	          "</td></tr>");
}

function buildHistoryRowEmpty() {
	return $("<tr><td></td></tr>");
}
{'fraction_non_alphanumeric': 0.23744075829383887, 'fraction_numerical': 0.008056872037914692, 'mean_word_length': 3.370600414078675, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '6156895', 'n_tokens_mistral': 785, 'n_tokens_neox': 749, 'n_words': 147}