<commit_before>'use strict';

var util = require('util');
var __ = require('underscore');

var base = require('./base');

/**
 * @constructor
 */
function WinParser() {
    base.call(this);
    this._ipv4Regex = /^([0-9]{1,3}\.){3}[0-9]{1,3}$/;
}

util.inherits(WinParser, base);

/**
 * Process output's header
 * @param {string} line - A line from system ping
 */
WinParser.prototype._processHeader = function (line) {
    // XXX: Expect to find [****] when pinging domain like google.com
    //      Read fixture/win/**/* for the detail
    var isPingNumeric = line.indexOf('[') === -1;

    // Get host and numeric_host
    var tokens = line.split(' ');

    if (isPingNumeric) {
        // For those missing [***], get the first token which match IPV4 regex
        this._response.host = __.find(tokens, function (t) {
            return this._ipv4Regex.test(t);
        }, this);
        this._response.numeric_host = this._response.host;
    } else {
        // For those has [***], anchor with such token
        var numericHost = __.find(tokens, function (t) {
            return t.indexOf('[') !== -1;
        }, this);
        var numericHostIndex = tokens.indexOf(numericHost);

        this._response.numeric_host = numericHost.slice(1, -1);
        this._response.host = tokens[numericHostIndex - 1];
    }

    this._changeState(this.STATES.BODY);
};

/**
 * Process output's body
 * @param {string} line - A line from system ping
 */
WinParser.prototype._processBody = function (line) {
    var tokens = line.split(' ');
    var kvps = __.filter(tokens, function (token) {
        // Sometime it shows <1ms
        return token.indexOf('=') >= 0 || token.indexOf('<') >= 0;
    });

    // refs #65: Support system like french which has an extra space
    kvps = __.map(kvps, function (kvp) {
        var ret = kvp;
        var kvpIndex = tokens.indexOf(kvp);
        var nextIndex = kvpIndex + 1;

        // Append the missing *ms*
        if (nextIndex < tokens.length) {
            if (tokens[nextIndex] === 'ms') {<commit_msg>fix win parser to parse [*] not devided with space<commit_after>'use strict';

var util = require('util');
var __ = require('underscore');

var base = require('./base');

/**
 * @constructor
 */
function WinParser() {
    base.call(this);
    this._ipv4Regex = /^([0-9]{1,3}\.){3}[0-9]{1,3}$/;
}

util.inherits(WinParser, base);

/**
 * Process output's header
 * @param {string} line - A line from system ping
 */
WinParser.prototype._processHeader = function (line) {
    // XXX: Expect to find [****] when pinging domain like google.com
    //      Read fixture/win/**/* for the detail
    var isPingNumeric = line.indexOf('[') === -1;

    // Get host and numeric_host
    var tokens = line.split(' ');

    if (isPingNumeric) {
        // For those missing [***], get the first token which match IPV4 regex
        this._response.host = __.find(tokens, function (t) {
            return this._ipv4Regex.test(t);
        }, this);
        this._response.numeric_host = this._response.host;
    } else {
        // For those has [***], anchor with such token
        var numericHost = __.find(tokens, function (t) {
            return t.indexOf('[') !== -1;
        }, this);
        var numericHostIndex = tokens.indexOf(numericHost);
        var match = /\[(.*)\]/.exec(numericHost);

        if (match) {
            this._response.numeric_host = match[1];
        }
        this._response.host = tokens[numericHostIndex - 1];
    }

    this._changeState(this.STATES.BODY);
};

/**
 * Process output's body
 * @param {string} line - A line from system ping
 */
WinParser.prototype._processBody = function (line) {
    var tokens = line.split(' ');
    var kvps = __.filter(tokens, function (token) {
        // Sometime it shows <1ms
        return token.indexOf('=') >= 0 || token.indexOf('<') >= 0;
    });

    // refs #65: Support system like french which has an extra space
    kvps = __.map(kvps, function (kvp) {
        var ret = kvp;
        var kvpIndex = tokens.indexOf(kvp);
        var nextIndex = kvpIndex + 1;

        // Append the missing *ms*
        if (nextIndex < tokens.length) {
            if (tokens[nextIndex] === 'ms') {
{'fraction_non_alphanumeric': 0.1577820085673489, 'fraction_numerical': 0.010709186101856259, 'mean_word_length': 2.464962901896125, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '760564', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1297, 'n_words': 356}