<commit_before><?php
// The file name
$dir = "..\\..\\JSON-Graph-Data\\";
$fileName = getFileName();
$extension = ".json";
$myFile = $dir . $fileName . $extension;

// If it exists add a number to the end (stops removal of graphs)
if (file_exists($myFile)) {
	$endingToFile = "(0)";
	$numberInEnding = 0;
	$newFileName = $dir . $fileName . $endingToFile . $extension;

	while (file_exists($newFileName)) {
		// Add one to the number in the ending
		$numberInEnding++;

		// Set the ending to the number surrounded by brackets
		$endingToFile = "(" . (string)$numberInEnding . ")";

		// Set the new file name to incude the number
		$newFileName = $dir . $fileName . $endingToFile . $extension;
	}

	// Set the file name to the new one
	$myFile = $newFileName;
}

// Open the file
$fh = fopen($myFile, "w");

// Write the data
fwrite($fh, $_POST["myData"]);

// Close the file
fclose($fh);

function getFileName() {
	$name;

	// Get the name of the graph
	$name = explode('"', $_POST["myData"])[3];

	// Get the ending to it
	$name .= " " . getEnding(explode('"', $_POST["myData"])[7]);

	return $name;
}


function getEnding($graphType) {
	if ($graphType == "pie") {
		return "pie chart";
	} else if ($graphType == "bar") {
		return "bar graph";
	} else {
		return "";
	}
}
?><commit_msg>Add proper saving of line and scatter graphs<commit_after><?php
// The file name
$dir = "..\\..\\JSON-Graph-Data\\";
$fileName = getFileName();
$extension = ".json";
$myFile = $dir . $fileName . $extension;

// If it exists add a number to the end (stops removal of graphs)
if (file_exists($myFile)) {
	$endingToFile = "(0)";
	$numberInEnding = 0;
	$newFileName = $dir . $fileName . $endingToFile . $extension;

	while (file_exists($newFileName)) {
		// Add one to the number in the ending
		$numberInEnding++;

		// Set the ending to the number surrounded by brackets
		$endingToFile = "(" . (string)$numberInEnding . ")";

		// Set the new file name to incude the number
		$newFileName = $dir . $fileName . $endingToFile . $extension;
	}

	// Set the file name to the new one
	$myFile = $newFileName;
}

// Open the file
$fh = fopen($myFile, "w");

// Write the data
fwrite($fh, $_POST["myData"]);

// Close the file
fclose($fh);

function getFileName() {
	$name;

	// Get the name of the graph
	$name = explode('"', $_POST["myData"])[3];

	// Get the ending to it
	$name .= " " . getEnding(explode('"', $_POST["myData"])[7], explode('"', $_POST["myData"])[11]);

	return $name;
}


function getEnding($graphType, $lineType) {
	if ($graphType == "pie") {
		return "pie chart";
	} else if ($graphType == "bar") {
		return "bar graph";
	} else if ($graphType == "line") {
		if ($lineType == "seperate") {
			return "line graph";
		} else if ($lineType == "cummulative") {
			return "cummulative line graph";
		}
	} else if ($graphType == "scatter") {
		return "scatter graph";
	} 

	// Return a blank string if it hasn't found a correct graph match
	return "";
}
?>
{'fraction_non_alphanumeric': 0.18083305113443957, 'fraction_numerical': 0.0033863867253640365, 'mean_word_length': 3.496194824961948, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1993313', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1021, 'n_words': 322}