<commit_before>"use strict";
const _ = require('underscore');
const config = require('config');
const shortid = require('shortid');
const moment = require('moment');
const boolean = require('boolean');

const taskHelper = require('./helpers/task');
const requestFactory = require("./requestFactory").requestFactory;
const cacheHelper = require('./helpers/cache');
const log = require("./helpers/logger");
const operator = require("./helpers/operator");


/**
 * normalizeTask - takes each task object generated from config and builds
 * a normalized key:value pair object. Any business logic should be done here.
 * The normalized object is then used to generate a request
 * object for the specific api resource (analyze or task) based
 * on the "api_resource" key.
 *
 * @param [{tasks}] - array of task objects from config
 * @param "analysis_type" - freqDist or timeSeries
 * @param "mergedName" - task name or undefined (if a merged task)
 * @param "globalFilter" - filter specified at global level - applied to all tasks
 *
 */
const normalizeTask = function normalizeTask(tasks, analysis_type, mergedName, globalFilter) {

    let allTasks = [];
    let cacheId = cacheHelper.create();

    tasks.map(function(task){

        let requestParams = {
            analysis_type: task.type || analysis_type
        };

        if(_.has(task,'index')){
            requestParams.index = task.index;
        }

        if(_.has(task,'api_resource')){
            requestParams.api_resource = task.api_resource;
        }

        if(_.has(task,'target')){
            requestParams.target = task.target;
        }

        if(_.has(task,'threshold')){
            requestParams.threshold = task.threshold;
        }

        if(_.has(task,'interval')){
            requestParams.interval = task.interval;
        }

        if(_.has(task,'span')){<commit_msg>Fix incorrect type key now replaced by analysis_type.<commit_after>"use strict";
const _ = require('underscore');
const config = require('config');
const shortid = require('shortid');
const moment = require('moment');
const boolean = require('boolean');

const taskHelper = require('./helpers/task');
const requestFactory = require("./requestFactory").requestFactory;
const cacheHelper = require('./helpers/cache');
const log = require("./helpers/logger");
const operator = require("./helpers/operator");


/**
 * normalizeTask - takes each task object generated from config and builds
 * a normalized key:value pair object. Any business logic should be done here.
 * The normalized object is then used to generate a request
 * object for the specific api resource (analyze or task) based
 * on the "api_resource" key.
 *
 * @param [{tasks}] - array of task objects from config
 * @param "analysis_type" - freqDist or timeSeries
 * @param "mergedName" - task name or undefined (if a merged task)
 * @param "globalFilter" - filter specified at global level - applied to all tasks
 *
 */
const normalizeTask = function normalizeTask(tasks, analysis_type, mergedName, globalFilter) {

    let allTasks = [];
    let cacheId = cacheHelper.create();

    tasks.map(function(task){

        let requestParams = {
            analysis_type: task.analysis_type || analysis_type
        };

        if(_.has(task,'index')){
            requestParams.index = task.index;
        }

        if(_.has(task,'api_resource')){
            requestParams.api_resource = task.api_resource;
        }

        if(_.has(task,'target')){
            requestParams.target = task.target;
        }

        if(_.has(task,'threshold')){
            requestParams.threshold = task.threshold;
        }

        if(_.has(task,'interval')){
            requestParams.interval = task.interval;
        }

        if(_.has(task,'span')){
{'fraction_non_alphanumeric': 0.12503318290416776, 'fraction_numerical': 0.0, 'mean_word_length': 3.145214521452145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5479572', 'n_tokens_mistral': 1004, 'n_tokens_neox': 981, 'n_words': 296}