<commit_before>(function(window, undefined){
    var self = {};

    self.writeFile = function(file, contents){
        try {
            var output    = FileUtils.openFileOutputStream(file)
              , converter = FileUtils.getUnicodeConverter("UTF-8")
              , text      = converter.ConvertFromUnicode(contents)
              ;
            output.write(text, text.length);
            var fin = converter.Finish();
            if(fin.length > 0){ output.write(fin, fin.length); }
            output.close();
            return true;
        } catch(e){
            return false;
        }
    };

    self.openFileDialog = function(title){
        return showFilePicker(
                window
              , title
              , Components.interfaces.nsIFilePicker.modeSave
              , Format.TEST_CASE_EXPORT_DIRECTORY_PREF
              , function(fp){ return fp.file; }
        );
    };

    var _parseComment = function(src){
        if(src.match(/<!--\s*(.+?)\s*-->/)){
            return({type: "comment", value: RegExp.$1});
        }
        return("err1:" + src);
    };

    var _parseCommand = function(src){
        if(src.match(/<td>(.+?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*/)){
            return({type: "command", command: RegExp.$1, target: RegExp.$2, value: RegExp.$3});
        }
        return("err2:" + src);
    };

    self.collectTestCaseCommands = function(testcase){
        return(testcase.commands.reduce(function(res, cmd){
            return(res.concat(cmd));
        }, []));
    };

    self.parseTestCase = function(cmd){
        var src = getSourceForCommand(cmd)
          , res = null
          ;
        if(src.indexOf("<!--") !== -1){
            res = _parseComment(src);
        } else {
            res = _parseCommand(src);
        }
        res.result = (cmd.result !== undefined) ? cmd.result : "undefined";

        return(res);
    };

    self.getTestCase = function(){
        return(window.editor.app.getTestCase());
    };

    self.getTestCaseTitle = function(testcase){
        if(testcase === undefined){
            testcase = window.editor.app.getTestCase();
        }
        return(testcase.getTitle());
    };

    self.getTestSuite = function(){
        var app   = window.editor.app
          , suite = app.getTestSuite()
          ;

        return(suite.tests.map(function(test){
            if(!test.content){
                var t = app.getCurrentFormat().loadFile(test.getFile(), false);
                test.content = t;
            }
            test.content.commands = test.content.commands.map(function(x){<commit_msg>#6 update ide.js<commit_after>(function(window, undefined){
    var self = {};

    self.writeFile = function(file, contents){
        try {
            var output    = FileUtils.openFileOutputStream(file)
              , converter = FileUtils.getUnicodeConverter("UTF-8")
              , text      = converter.ConvertFromUnicode(contents)
              ;
            output.write(text, text.length);
            var fin = converter.Finish();
            if(fin.length > 0){ output.write(fin, fin.length); }
            output.close();
            return true;
        } catch(e){
            return false;
        }
    };

    self.openFileDialog = function(title){
        return showFilePicker(
                window
              , title
              , Components.interfaces.nsIFilePicker.modeSave
              , Format.TEST_CASE_EXPORT_DIRECTORY_PREF
              , function(fp){ return fp.file; }
        );
    };

    var parseComment = function(src){
        if(src.match(/<!--\s*(.+?)\s*-->/)){
            return({type: "comment", value: RegExp.$1});
        }
        return("err1:" + src);
    };

    var parseCommand = function(src){
        if(src.match(/<td>(.+?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*/)){
            return({type: "command", command: RegExp.$1, target: RegExp.$2, value: RegExp.$3});
        }
        return("err2:" + src);
    };

    self.collectTestCaseCommands = function(testcase){
        return(testcase.commands.reduce(function(res, cmd){
            return(res.concat(cmd));
        }, []));
    };

    self.parseTestCase = function(cmd){
        var src = getSourceForCommand(cmd)
          , res = null
          ;
        if(src.indexOf("<!--") !== -1){
            res = parseComment(src);
        } else {
            res = parseCommand(src);
        }
        res.result = (cmd.result !== undefined) ? cmd.result : "undefined";

        return(res);
    };

    self.getTestCase = function(){
        return(window.editor.app.getTestCase());
    };

    self.getTestCaseTitle = function(testcase){
        if(testcase === undefined){
            testcase = window.editor.app.getTestCase();
        }
        return(testcase.getTitle());
    };

    self.getTestSuite = function(){
        var app   = window.editor.app
          , suite = app.getTestSuite()
          ;

        return(suite.tests.map(function(test){
            if(!test.content){
                var t = app.getCurrentFormat().loadFile(test.getFile(), false);
                test.content = t;
            }
            test.content.commands = test.content.commands.map(function(x){
{'fraction_non_alphanumeric': 0.15599311795067863, 'fraction_numerical': 0.003632192697380998, 'mean_word_length': 1.7800212539851221, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4696404', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1473, 'n_words': 235}