<commit_before>package mainApplication;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import parser.Node;
import parser.Parser;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import view.View;
import workspace.Workspace;

public class Controller {
	
	private List<Workspace> myWorkspaces;
	private Parser myParser;
	private int myActive;
	private Workspace myActiveWS;
	private GUI myView;
	//TEMPORARY, REMOVE STAGE
	public Stage myStage;
	
	public Controller(Stage s){//TEMPORARY
		myStage = s;
		myWorkspaces = new ArrayList<>();

		myParser = new Parser();
	}
	
	public void parseAndEvaluate(String s) throws Exception{
		List<Node> list = myParser.parse(s);
		myActiveWS.evaluate(list);
	}
	
	public int createWorkspace(GUI gui){
		int i = 0;
		if(myWorkspaces != null)
			i = myWorkspaces.size();
		myActiveWS=new Workspace(i);
		myActiveWS.addObserver(gui);
		myActiveWS.createTurtle(0);

		myWorkspaces.add(myActiveWS);
		
		return myWorkspaces.size()-1;
	}
	
	public void setActive(int id){
		myActive = id;
		myActiveWS = myWorkspaces.get(myActive);
	}
	
	public Map<String,Double> getVariables(){
		return myActiveWS.getVariables();
	}
	
	public Map<Integer, Color> getColors(){
		return myActiveWS.getColors();
	}
	public void clear(){
		myActiveWS.clear();
	}
	
	

	
	public void saveMem(String s){
	    File f=new File(s+".logo");
	    try {
            f.createNewFile();
       
            myActiveWS.writeMem(f);<commit_msg>updated controller<commit_after>package mainApplication;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import parser.Node;
import parser.Parser;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import view.View;
import workspace.Workspace;

public class Controller {
	
	private List<Workspace> myWorkspaces;
	private Parser myParser;
	private int myActive;
	private Workspace myActiveWS;
	private GUI myView;
	//TEMPORARY, REMOVE STAGE
	public Stage myStage;
	
	public Controller(Stage s){//TEMPORARY
		myStage = s;
		myWorkspaces = new ArrayList<>();

		myParser = new Parser();
	}
	
	public void parseAndEvaluate(String s) throws Exception{
		List<Node> list = myParser.parse(s);
		myActiveWS.evaluate(list);
	}
	
	public int createWorkspace(GUI gui){
		int i = 0;
		if(myWorkspaces != null)
			i = myWorkspaces.size();
		myActiveWS=new Workspace(i);
		myActiveWS.addObserver(gui);
		myActiveWS.createTurtle(0);

		myWorkspaces.add(myActiveWS);
		
		return myWorkspaces.size()-1;
	}
	
	public void setActive(int id){
		myActive = id;
		myActiveWS = myWorkspaces.get(myActive);
	}
	
	public Map<String,Double> getVariables(){
		return myActiveWS.getVariables();
	}
	
	public Map<Integer, Color> getColors(){
		return myActiveWS.getColors();
	}
	public void clear(){
		myActiveWS.clear();
	}
	
	

	
	public void saveMem(File f){
	    try {
       
            myActiveWS.writeMem(f);
{'fraction_non_alphanumeric': 0.1110766366739063, 'fraction_numerical': 0.001861619609059882, 'mean_word_length': 4.276595744680851, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3086800', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1050, 'n_words': 248}