<commit_before>package voogasalad_GucciGames.gameAuthoring.gui.gaedialog.mapobjectsettings.xml;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Label;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;

import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.dialogcomponents.DialogTableView;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.dialogcomponents.TableElement;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.mapobjsettings.ObjParamPane;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ActionParams;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ObjParam;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ObjType;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.RuleParams;

public class ParamObjParser {
	
	private Set<ObjParam> allMapObjCharParams = new HashSet<ObjParam>();
	
	private Set<ObjParam> allPlayerCharParams = new HashSet<ObjParam>();
	
	private Set<ObjParam> allOutcomeParams = new HashSet<ObjParam>();
	
	private Set<ObjParam> allConditionParams = new HashSet<ObjParam>();
	
	Set<RuleParams> allRules = new HashSet<RuleParams>();
	
	Set<ActionParams> allActions = new HashSet<ActionParams>();
	
	private static final String mainPath = "src/voogasalad_GucciGames/gameAuthoring/gui/gaedialog/mapobjectsettings/xml/";
	private static final String mapObjCharPath = mainPath + "mapObjCharDependencies.xml";
	private static final String playerCharPath = mainPath + "playerCharDependencies.xml";
	private static final String outcomePath = mainPath + "outcomeDependencies.xml";
	private static final String conditionPath = mainPath + "conditionDependencies.xml";
	private static final String actionPath = mainPath + "actionDependencies.xml";
	private static final String rulePath = mainPath + "ruleDependencies.xml";
	
	public ParamObjParser(){
		parseAll();
	}
	
	public Set<ObjParam> getMapObjChars(){
		return allMapObjCharParams;
	}
	
	public Set<ObjParam> getPlayerChars(){
		return allPlayerCharParams;
	}
	
	public Set<ObjParam> getOutcomes(){
		return allOutcomeParams;
	}
	
	public Set<ObjParam> getConditions(){
		return allConditionParams;
	}
	
	public Set<RuleParams> getRules(){
		return allRules;
	}
	
	public Set<ActionParams> getActions(){
		return allActions;
	}
	
	private void parseAll(){
		parseOutcomes();
		parseMapObjChar();
		parsePlayerChar();
		parseCondition();
		parseRule();
		parseAction();
		
	}
	
	private void parseAction(){
		
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
		
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        ActionSAXHandler handler = new ActionSAXHandler();
	        saxParser.parse(new 
	        		File(actionPath), 
	        		handler);
	        List<ActionParams> list = handler.getActionParams();	
	        this.allActions = new HashSet<ActionParams>(list);
	         
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }
		
		
		
	}
	
	private void parseRule(){
		
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
		
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        RulesSAXHandler handler = new RulesSAXHandler();
	        saxParser.parse(new 
	        		File(rulePath), 
	        		handler);
	        List<RuleParams> list = handler.getRuleParams();	
	        this.allRules = new HashSet<RuleParams>(list);
	         
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }

		
	}
	
	private void parse(String path, Set<ObjParam> set, ObjType type){
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        CharacteristicsSAXHandler handler = new CharacteristicsSAXHandler(type);
	        saxParser.parse(new 
	        		File(path), 
	        		handler);
	       List<ObjParam> list = handler.getObjParams();
	       list.forEach(e -> {
	    	   System.out.println("added: " + e.getName());
	       });
	       set = new HashSet<ObjParam>(list);
	       System.out.println("size " + set.size());
	           
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }
	    System.out.println("done");
	}
	
	private void parseMapObjChar(){
		parse(mapObjCharPath, this.allMapObjCharParams, ObjType.MAP_CHAR);
		System.out.println("size 2: " + this.allMapObjCharParams.size());
	}
	
	private void parsePlayerChar(){
		parse(this.playerCharPath, this.allPlayerCharParams, ObjType.PLAYER_CHAR);
		
	}
	
	private void parseOutcomes(){
		parse(this.outcomePath, this.allOutcomeParams, ObjType.OUTCOME);
		
	}
	
	private void parseCondition(){
		parse(this.conditionPath, this.allConditionParams, ObjType.CONDITION);
	}
	
	
	
	
	

}<commit_msg>udpates<commit_after>package voogasalad_GucciGames.gameAuthoring.gui.gaedialog.mapobjectsettings.xml;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Label;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;

import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.dialogcomponents.DialogTableView;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.dialogcomponents.TableElement;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.mapobjsettings.ObjParamPane;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ActionParams;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ObjParam;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.ObjType;
import voogasalad_GucciGames.gameAuthoring.gui.gaedialog.paramObjects.RuleParams;

public class ParamObjParser {
	
	private Set<ObjParam> allMapObjCharParams /*= new HashSet<ObjParam>()*/;
	
	private Set<ObjParam> allPlayerCharParams = new HashSet<ObjParam>();
	
	private Set<ObjParam> allOutcomeParams = new HashSet<ObjParam>();
	
	private Set<ObjParam> allConditionParams = new HashSet<ObjParam>();
	
	Set<RuleParams> allRules = new HashSet<RuleParams>();
	
	Set<ActionParams> allActions = new HashSet<ActionParams>();
	
	private static final String mainPath = "src/voogasalad_GucciGames/gameAuthoring/gui/gaedialog/mapobjectsettings/xml/";
	private static final String mapObjCharPath = mainPath + "mapObjCharDependencies.xml";
	private static final String playerCharPath = mainPath + "playerCharDependencies.xml";
	private static final String outcomePath = mainPath + "outcomeDependencies.xml";
	private static final String conditionPath = mainPath + "conditionDependencies.xml";
	private static final String actionPath = mainPath + "actionDependencies.xml";
	private static final String rulePath = mainPath + "ruleDependencies.xml";
	
	public ParamObjParser(){
		parseAll();
	}
	
	public Set<ObjParam> getMapObjChars(){
		return allMapObjCharParams;
	}
	
	public Set<ObjParam> getPlayerChars(){
		return allPlayerCharParams;
	}
	
	public Set<ObjParam> getOutcomes(){
		return allOutcomeParams;
	}
	
	public Set<ObjParam> getConditions(){
		return allConditionParams;
	}
	
	public Set<RuleParams> getRules(){
		return allRules;
	}
	
	public Set<ActionParams> getActions(){
		return allActions;
	}
	
	private void parseAll(){
		parseOutcomes();
		parseMapObjChar();
		parsePlayerChar();
		parseCondition();
		parseRule();
		parseAction();
		
	}
	
	private void parseAction(){
		
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
		
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        ActionSAXHandler handler = new ActionSAXHandler();
	        saxParser.parse(new 
	        		File(actionPath), 
	        		handler);
	        List<ActionParams> list = handler.getActionParams();	
	        allActions = new HashSet<ActionParams>(list);
	         
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }
	    return;
		
		
		
	}
	
	private void parseRule(){
		
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
		
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        RulesSAXHandler handler = new RulesSAXHandler();
	        saxParser.parse(new 
	        		File(rulePath), 
	        		handler);
	        List<RuleParams> list = handler.getRuleParams();	
	        allRules = new HashSet<RuleParams>(list);
	         
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }
	    return;

		
	}
	
	private void parse(String path, Set<ObjParam> set, ObjType type){
		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
	    try {
	        SAXParser saxParser = saxParserFactory.newSAXParser();
	 
	        CharacteristicsSAXHandler handler = new CharacteristicsSAXHandler(type);
	        saxParser.parse(new 
	        		File(path), 
	        		handler);
	       List<ObjParam> list = handler.getObjParams();
	       list.forEach(e -> {
	    	   System.out.println("added: " + e.getName());
	       });
	       set = new HashSet<ObjParam>(list);
	       System.out.println("size: " + set.size());
	           
	    } catch (ParserConfigurationException | SAXException | IOException ex) {
	        ex.printStackTrace();
	    }
	    System.out.println("done");
		System.out.println("size 3: " + allMapObjCharParams.size());

	    return;
	}
	
	private void parseMapObjChar(){
		parse(mapObjCharPath, allMapObjCharParams, ObjType.MAP_CHAR);
		System.out.println("size 2: " + this.allMapObjCharParams.size());
	}
	
	private void parsePlayerChar(){
		parse(this.playerCharPath, allPlayerCharParams, ObjType.PLAYER_CHAR);
		
	}
	
	private void parseOutcomes(){
		parse(this.outcomePath, allOutcomeParams, ObjType.OUTCOME);
		
	}
	
	private void parseCondition(){
		parse(this.conditionPath, allConditionParams, ObjType.CONDITION);
	}
	
	
	
	
	

}
{'fraction_non_alphanumeric': 0.09903609903609904, 'fraction_numerical': 0.0002835002835002835, 'mean_word_length': 4.0636363636363635, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, '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': '4049858', 'n_tokens_mistral': 3476, 'n_tokens_neox': 3112, 'n_words': 582}