<commit_before>/* global */
// Exporter.js - in api/services

"use strict";

module.exports = {
    documentsToCsv
};


function documentsToCsv(documents) {
    const rows = [[
        'Authors',
        'Ttile',
        'Source',
        'Year',
        'DOI',
        'Type',
        'Source type',
        'Citations',
        'IF',
        'SNIP',
        'SJR'
    ]].concat(documents.map(d => {
        const document = d.toJSON();
        const doc = [];
        doc.push(document.authorsStr);
        doc.push(document.title);
        doc.push(document.source.title);
        doc.push(document.year);
        doc.push(document.doi);
        doc.push(document.documenttype.label);
        doc.push(document.source.sourcetype.label);
        doc.push(Array.isArray(document.scopusCitations) ? document.scopusCitations.map(s => s.year + ':' + s.value).join(' - ') : '');
        doc.push(document.IF);
        doc.push(document.SNIP);
        doc.push(document.SJR);

        return doc;
    }));

    let csv = 'data:text/csv;charset=utf-8,';<commit_msg>Fixed bug for invited talks<commit_after>/* global DocumentTypes */
// Exporter.js - in api/services

"use strict";

module.exports = {
    documentsToCsv
};


function documentsToCsv(documents) {
    const rows = [[
        'Authors',
        'Ttile',
        'Source',
        'Year',
        'DOI',
        'Type',
        'Source type',
        'Citations',
        'IF',
        'SNIP',
        'SJR'
    ]].concat(documents.map(d => {
        const document = d.toJSON();
        const doc = [];
        doc.push(document.authorsStr);
        doc.push(document.title);

        let source;
        if (document.type === DocumentTypes.INVITED_TALK)
            source = document.itSource;
        else
            source = document.source ? document.source.title : '';

        doc.push(source);
        doc.push(document.year);
        doc.push(document.doi);
        doc.push(document.documenttype ? document.documenttype.label : '');
        doc.push(document.sourceTypeObj ? document.sourceTypeObj.label : '');
        doc.push(Array.isArray(document.scopusCitations) ? document.scopusCitations.reduce((total, s) => total + s.value, 0) : '');
        doc.push(document.IF);
        doc.push(document.SNIP);
        doc.push(document.SJR);

        return doc;
    }));

    let csv = 'data:text/csv;charset=utf-8,';
{'fraction_non_alphanumeric': 0.15604026845637584, 'fraction_numerical': 0.0012583892617449664, 'mean_word_length': 2.0853816300129364, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2325127', 'n_tokens_mistral': 773, 'n_tokens_neox': 741, 'n_words': 119}