<commit_before>var lineReader = require('line-reader');

function parseFeature(file, callback) {
    output = {suite: [], last: false};
    lineCount =  0;
    lineReader.eachLine(file, function(line, last) {
        lineCount++;
        if(last){
            output.last = true;
        }
        output.line = getDescriptiveLine(file, lineCount);
        handleLine(line, callback);

    });
}


function handleLine(line, callback) {
    if(lineIsIt(line)) {
        var regex = new RegExp("IT ([^\n]*)", "gi");
        output.description = convertLine(line, regex, "IT");
        callback(output);
    } else if (lineIsDescribe(line)) {
        var regex = new RegExp("DESCRIBE ([^\n]*)", "gi");
        output.suite.push(convertLine(line, regex, "DESCRIBE"));
    } else if (lineIsEnd(line)) {
        output.suite.pop();
    }
}

function convertLine(line, matcher, replace) {
    var match = line.match(matcher)[0];
    var regex = new RegExp( '('+ replace +')', 'gi' );
    return match.replace(regex, "").trim();
}

function lineIsIt(line) {
    return line.match(/IT ([^\n]*)/gi)<commit_msg>refactored parser<commit_after>var lineReader = require('line-reader');

function parseFeature(file, callback) {
    output = {suite: [], last: false};
    lineCount =  0;
    lineReader.eachLine(file, function(line, last) {
        lineCount++;
        if(last){
            output.last = true;
        }
        output.line = getDescriptiveLine(file, lineCount);
        handleLine(line, callback);

    });
}


function handleLine(line, callback) {
    if(lineIsIt(line)) {
        output.description = convertLine(line, "IT");
        callback(output);
    } else if (lineIsDescribe(line)) {
        output.suite.push(convertLine(line, "DESCRIBE"));
    } else if (lineIsEnd(line)) {
        output.suite.pop();
    }
}

function convertLine(line, replace) {
    var regex = new RegExp( '('+ replace +')', 'gi' );
    return line.replace(regex, "").trim();
}

function lineIsIt(line) {
    return line.match(/IT ([^\n]*)/gi)
{'fraction_non_alphanumeric': 0.16863905325443787, 'fraction_numerical': 0.0014792899408284023, 'mean_word_length': 2.9474708171206228, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2089374', 'n_tokens_mistral': 656, 'n_tokens_neox': 644, 'n_words': 134}