<commit_before>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * The model for a learner result.
 */
export class LearnResult {

    /**
     * Constructor.
     *
     * @param obj - The object to create a learn result from.
     */
    constructor(obj) {

        /**
         * The algorithm that is used.
         * @type {string}
         */
        this.algorithm = obj.algorithm;

        /**
         * The browser that is used.
         * @type {string}
         */
        this.browser = obj.browser;

        /**
         * The hypothesis.
         * @type {object}
         */
        this.hypothesis = obj.hypothesis;

        /**
         * The project id of the learn result.
         * @type{number}
         */
        this.project = obj.project;

        /**
         * The id revision pair of the reset symbol.
         * @type {*}
         */
        this.resetSymbol = obj.resetSymbol;

        /**
         * The alphabet the process has been learned with.
         * @type {{id:number,revision:number}[]}
         */
        this.sigma = obj.sigma;

        /**
         * The cumulated statistics.
         * @type {*}
         */
        this.statistics = obj.statistics;

        /**
         * The steps of the learn process.
         * @type {{eqOracle:Object, stepNo:number, statistics:Object, hypothesis:Object}}
         */
        this.steps = obj.steps;

        /**
         * Sigma.
         * @type {*}
         */
        this.symbols = obj.symbols;

        /**
         * The test number.
         * @type {number}
         */
        this.testNo = obj.testNo;

        /**
         * The id of the user.
         * @type {number}
         */
        this.user = obj.user;

        /**
         * If the learner encountered an error.
         * @type {boolean}
         */
        this.error = obj.error;

        /**
         * The description of the error that occurred.
         * @type {string}
         */
        this.errorText = obj.errorText;

        // convert ns to ms
        LearnResult.convertNsToMs(this.statistics.duration);

        if (this.steps) {
            this.steps.forEach(step => LearnResult.convertNsToMs(step.statistics.duration));
        }
    }

    static convertNsToMs(input) {
        input.total    = Math.ceil(input.total    / 1000000);
        input.learner  = Math.ceil(input.learner  / 1000000);
        input.eqOracle = Math.ceil(input.eqOracle / 1000000);
    }

}<commit_msg>made comments of learn results visible again<commit_after>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * The model for a learner result.
 */
export class LearnResult {

    /**
     * Constructor.
     *
     * @param obj - The object to create a learn result from.
     */
    constructor(obj) {

        /**
         * The algorithm that is used.
         * @type {string}
         */
        this.algorithm = obj.algorithm;

        /**
         * The browser that is used.
         * @type {string}
         */
        this.browser = obj.browser;

        /**
         * The hypothesis.
         * @type {object}
         */
        this.hypothesis = obj.hypothesis;

        /**
         * The project id of the learn result.
         * @type{number}
         */
        this.project = obj.project;

        /**
         * The id revision pair of the reset symbol.
         * @type {*}
         */
        this.resetSymbol = obj.resetSymbol;

        /**
         * The alphabet the process has been learned with.
         * @type {{id:number,revision:number}[]}
         */
        this.sigma = obj.sigma;

        /**
         * The cumulated statistics.
         * @type {*}
         */
        this.statistics = obj.statistics;

        /**
         * The steps of the learn process.
         * @type {{eqOracle:Object, stepNo:number, statistics:Object, hypothesis:Object}}
         */
        this.steps = obj.steps;

        /**
         * Sigma.
         * @type {*}
         */
        this.symbols = obj.symbols;

        /**
         * The test number.
         * @type {number}
         */
        this.testNo = obj.testNo;

        /**
         * The id of the user.
         * @type {number}
         */
        this.user = obj.user;

        /**
         * If the learner encountered an error.
         * @type {boolean}
         */
        this.error = obj.error;

        /**
         * The description of the error that occurred.
         * @type {string}
         */
        this.errorText = obj.errorText;

        /**
         * The comment of the learn result.
         * @type {string}
         */
        this.comment = obj.comment;

        // convert ns to ms
        LearnResult.convertNsToMs(this.statistics.duration);

        if (this.steps) {
            this.steps.forEach(step => LearnResult.convertNsToMs(step.statistics.duration));
        }
    }

    static convertNsToMs(input) {
        input.total    = Math.ceil(input.total    / 1000000);
        input.learner  = Math.ceil(input.learner  / 1000000);
        input.eqOracle = Math.ceil(input.eqOracle / 1000000);
    }

}
{'fraction_non_alphanumeric': 0.11195722618276086, 'fraction_numerical': 0.009397278029812054, 'mean_word_length': 1.560348403152219, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2554083', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1671, 'n_words': 496}