<commit_before>// Originally written by: http://analyticphysics.com/Diversions/An%20Alexa%20Skills%20Kit%20%28ASK%29%20JavaScript%20Cookbook.htm
// JS code provided by: https://github.com/hsw28

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

function askWolfram(input, callback) {
    var https = require( 'https' );

    var url = 'https://api.wolframalpha.com/v2/query?input=' + input;
    url += '&format=plaintext&podindex=1,2,3';
    url += '&appid='+config.wolframAppId;
    
    var request = https.get( url, function( response ) {
        var xml = '';
        response.on( 'data', function( x ) { xml += x; } );
        response.on( 'end', function() {
            xml = xml.replace( /\n/g, ' ' );

            var pattern = /plaintext>(.*?)<\/plaintext/g;
            var answers = [];
            var msg = null;

            while ( ( match = pattern.exec( xml )) !== null ) {
                answers.push( match[1] );
            }
            
            //Determine which slot in the response to use
            if ( answers[1] === '' ) {
                msg = answers[2];
            }
            else {
                msg = answers[1];
            }

            //Callback to index.js with wolfram results (err vs msg)
            if (msg) {
                callback(null, msg);
            }
            else {
                callback('No results!',null);<commit_msg>Added new line<commit_after>// Originally written by: http://analyticphysics.com/Diversions/An%20Alexa%20Skills%20Kit%20%28ASK%29%20JavaScript%20Cookbook.htm
// JS code provided by: https://github.com/hsw28

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

function askWolfram(input, callback) {
    var https = require( 'https' );

    var url = 'https://api.wolframalpha.com/v2/query?input=' + input;
    url += '&format=plaintext&podindex=1,2,3';
    url += '&appid='+config.wolframAppId;
    
    var request = https.get( url, function( response ) {
        var xml = '';
        response.on( 'data', function( x ) { xml += x; } );
        response.on( 'end', function() {
            xml = xml.replace( /\n/g, ' ' );

            var pattern = /plaintext>(.*?)<\/plaintext/g;
            var answers = [];
            var msg = null;

            while ( ( match = pattern.exec( xml )) !== null ) {
                answers.push( match[1] );
            }
                      
            //Determine which slot in the response to use
            if ( answers[1] === '' ) {
                msg = answers[2];
            }
            else {
                msg = answers[1];
            }

            //Callback to index.js with wolfram results (err vs msg)
            if (msg) {
                callback(null, msg);
            }
            else {
                callback('No results!',null);
{'fraction_non_alphanumeric': 0.15023474178403756, 'fraction_numerical': 0.018779342723004695, 'mean_word_length': 1.6609029779058597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '567326', 'n_tokens_mistral': 870, 'n_tokens_neox': 816, 'n_words': 189}