<commit_before>'use strict';

async function loadZips(zipURLs, options = {}) {
    const JSZip = await API.require('jszip');
    const superagent = await API.require('superagent');
    var jszip = new JSZip();
    var spectraDataSet = [];
    for (let zipURL of zipURLs) {
        let zipFiles = await superagent.get(zipURL, {responseType: 'arraybuffer'})
            .withCredentials()
            .responseType('blob');
        var zip = await jszip.loadAsync(zipFiles.body);
        let filesToProcess = Object.keys(zip.files).filter( filename => filename.match(/\.[0-9]+$/));
        for (const filename of filesToProcess) {
            let fileData=await zip.files[filename].async('string');
            let result = xyParser(fileData, {arrayType: 'xxyy'});
            let spectrum = SD.NMR.fromXY(result[0], result[1], {
                dataType: 'IR',
                xUnit: 'waveNumber',
                yUnit: ''
            });
            if (options.filter) options.filter(spectrum.sd);
            spectrum.sd.info = {};
            spectrum.sd.filename = filename;
            spectraDataSet.push(spectrum);
        }
    }
    return spectraDataSet;
}

<commit_msg>Add xyParser<commit_after>'use strict';

async function loadZips(zipURLs, options = {}) {
    const JSZip = await API.require('jszip');
    const superagent = await API.require('superagent');
    const xyParser = await API.require('https://www.lactame.com/lib/xy-parser/1.3.0/xy-parser.min.js');
    var jszip = new JSZip();
    var spectraDataSet = [];
    for (let zipURL of zipURLs) {
        let zipFiles = await superagent.get(zipURL, {responseType: 'arraybuffer'})
            .withCredentials()
            .responseType('blob');
        var zip = await jszip.loadAsync(zipFiles.body);
        let filesToProcess = Object.keys(zip.files).filter( filename => filename.match(/\.[0-9]+$/));
        for (const filename of filesToProcess) {
            let fileData=await zip.files[filename].async('string');
            let result = xyParser(fileData, {arrayType: 'xxyy'});
            let spectrum = SD.NMR.fromXY(result[0], result[1], {
                dataType: 'IR',
                xUnit: 'waveNumber',
                yUnit: ''
            });
            if (options.filter) options.filter(spectrum.sd);
            spectrum.sd.info = {};
            spectrum.sd.filename = filename;
            spectraDataSet.push(spectrum);
        }
    }
    return spectraDataSet;
}


{'fraction_non_alphanumeric': 0.1387423935091278, 'fraction_numerical': 0.004462474645030426, 'mean_word_length': 2.2705570291777186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '2945639', 'n_tokens_mistral': 726, 'n_tokens_neox': 715, 'n_words': 151}