<commit_before>package rliota.util;


import java.io.*;
import java.util.*;

public class JSParser {

    private static final char NEW_LINE = '\n';
    private static final String REGEX_DOT = "\\.";
    private static final String SEPARATOR = File.separator;

    private FileWriter outputFile = null;
    private HashMap<String, File> namespaceResourceMap = new HashMap<String, File>();
    private ArrayList<String> pathsToIgnore = new ArrayList<String>();

    public void compile(String srcPath, String destinationPath)throws IOException{
        this.compile(srcPath, destinationPath, null);
    }

    public void compile(String rootPath, String destinationPath, ArrayList<String> pathsToIgnore) throws IOException{
        File rootDir = new File(rootPath);
        if(rootDir.isDirectory()){
            if(pathsToIgnore != null){
                this.pathsToIgnore = pathsToIgnore;
            }
            this.outputFile = new FileWriter(destinationPath);
            String namespace = rootDir.getName().trim();

            String[] pathStr = destinationPath.split(SEPARATOR);
            String functionName = pathStr[pathStr.length-1];
            functionName = functionName.split("[.]")[0];
            String header = "//Generated on " + new Date() + "\nfunction initialize_" + functionName + "(){";
            this.outputFile.write(header + NEW_LINE + "window." + namespace + " = {};");
            this.processDirectory(rootDir, namespace);
            this.assembleJSFiles();
            this.outputFile.write("}");<commit_msg>Fix for issue 2: Windows file separators are escape characters in regular expressions, and because Java regex doesn't do posix, now just checking against an escaped backslash and front slash characters.<commit_after>package rliota.util;


import java.io.*;
import java.util.*;

public class JSParser {

    private static final char NEW_LINE = '\n';
    private static final String REGEX_DOT = "\\.";
    private static final String SEPARATOR = "[\\/]";

    private FileWriter outputFile = null;
    private HashMap<String, File> namespaceResourceMap = new HashMap<String, File>();
    private ArrayList<String> pathsToIgnore = new ArrayList<String>();

    public void compile(String srcPath, String destinationPath)throws IOException{
        this.compile(srcPath, destinationPath, null);
    }

    public void compile(String rootPath, String destinationPath, ArrayList<String> pathsToIgnore) throws IOException{
        File rootDir = new File(rootPath);
        if(rootDir.isDirectory()){
            if(pathsToIgnore != null){
                this.pathsToIgnore = pathsToIgnore;
            }
            this.outputFile = new FileWriter(destinationPath);
            String namespace = rootDir.getName().trim();

            String[] pathStr = destinationPath.split(SEPARATOR);
            String functionName = pathStr[pathStr.length-1];
            functionName = functionName.split("[.]")[0];
            String header = "//Generated on " + new Date() + "\nfunction initialize_" + functionName + "(){";
            this.outputFile.write(header + NEW_LINE + "window." + namespace + " = {};");
            this.processDirectory(rootDir, namespace);
            this.assembleJSFiles();
            this.outputFile.write("}");
{'fraction_non_alphanumeric': 0.11236297198538368, 'fraction_numerical': 0.0015225334957369061, 'mean_word_length': 3.0158924205378974, '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': '1757750', 'n_tokens_mistral': 835, 'n_tokens_neox': 816, 'n_words': 232}