<commit_before>#! /usr/bin/env node

/*
 * get-editors
 * https://github.com/trofmike/get-report-editors
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */
var file = process.argv.slice(2);

var fs = require('fs');
var _ = require('underscore');
var result = '';
var stream = fs.createWriteStream('result.txt');


var readFile = function (filename) {
    fs.readFile(filename, 'utf8', function(err, file) {
        if (err) {
            console.log('Error: ' + err);
            return;
        }
        // console.log(file);
        if (file) {
            var parsedJson = JSON.parse(file);

            _.each(parsedJson.tabs["Шапка"].result.data.Cells, function(obj) {
                if (!_.isNull(obj.editor)) {
                    result = result + ('self._get_dict(u"'+ obj.code +'"),\n');
                }
            });
            stream.write(result);
        }
        
    });
};

var writeFile = function (result) {
    console.log('result =' + result);
    fs.writeFile('result.txt', result, function (err) {<commit_msg>add check structure json<commit_after>#! /usr/bin/env node

/*
 * get-editors
 * https://github.com/trofmike/get-report-editors
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */
var file = process.argv.slice(2);

var fs = require('fs');
var _ = require('underscore');
var result = '';
var stream = fs.createWriteStream('result.txt');

var checkStructure = function (file) {
    if (_.has(file, 'tabs') && _.has(file.tabs, 'Шапка') && _.has(file.tabs["Шапка"], 'result') && _.has(file.tabs["Шапка"].result, 'data') && _.has(file.tabs["Шапка"].result.data, 'Cells')) {
        return true;
    } else {
        return false;
    }
};
var readFile = function (filename) {
    fs.readFile(filename, 'utf8', function(err, file) {
        if (err) {
            console.log('Error: ' + err);
            return;
        }
        // console.log(file);
        if (file) {
            var parsedJson = JSON.parse(file);
            if (checkStructure(parsedJson)) {
                _.each(parsedJson.tabs["Шапка"].result.data.Cells, function(obj) {
                    if (!_.isNull(obj.editor)) {
                        result = result + ('self._get_dict(u"'+ obj.code +'"),\n');
                    }
                });

                stream.write(result);
            }
            else {
                console.log('В файле ' + filename + ' нарушена структура.');
            }
            
        }
        
    });
};

var writeFile = function (result) {
    console.log('result =' + result);
    fs.writeFile('result.txt', result, function (err) {
{'fraction_non_alphanumeric': 0.170083523158694, 'fraction_numerical': 0.004555808656036446, 'mean_word_length': 2.0045610034207524, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3555033', 'n_tokens_mistral': 847, 'n_tokens_neox': 826, 'n_words': 163}