<commit_before>'use strict';

var request = require('./request'),
    util = require('util'),
    tool = require('./tool'),
    sys = require('sys'),
    events = require('events'),
    Select = require('./select');

function convertType(val) {
    if (val instanceof Date) {
        return tool.escapeXML(val.toISOString());
    }

    switch (typeof val) {
    case 'function':
        val = val.toString();
        break;
    case 'object':
        val = val.toString();
        break;
    case 'array':
        val = val.toSTring();
        break;
    case 'undefined':
        val = '';
        break;
    case 'null':
        val = '';
        break;
    }

    return tool.escapeXML(val);
}

function getAtomic(option) {
    if (option === 'add') {
        return 'add';
    }
    if (option === 'inc') {
        return 'inc';
    }
    return 'set';
}

function Collection(config) {
    if ((this instanceof Collection) === false) {
        return new Collection(config);
    }

    var wt = 'json',
        fields = {},
        uniqueKey = false,
        field,
        self = this;

    /**
     * Parse solr schema and extract available fields
     */
    if (config.schema && config.schema.schema && config.schema.schema.fields && config.schema.schema.fields instanceof Array) {
        for (field in config.schema.schema.fields) {
            if (config.schema.schema.fields.hasOwnProperty(field)) {
                fields[config.schema.schema.fields[field].name] = config.schema.schema.fields[field];
            }
        }
    }

    /**
     * Get unique key from solr schema
     * @type {*|boolean}
     */
    uniqueKey = config.schema.schema.uniqueKey || false;

    this.getName = function () {
        return config.client.name;
    };

    this.select = function (path) {
        return new Select(self, path);
    };

    this.add = function (entities, callback, options) {
        if (typeof options !== 'object') {
            options = {};
        }

        if (options.quiet === undefined) {<commit_msg>Collection provide name, client data and fields<commit_after>'use strict';

var request = require('./request'),
    util = require('util'),
    tool = require('./tool'),
    sys = require('sys'),
    events = require('events'),
    Select = require('./select');

function convertType(val) {
    if (val instanceof Date) {
        return tool.escapeXML(val.toISOString());
    }

    switch (typeof val) {
    case 'function':
        val = val.toString();
        break;
    case 'object':
        val = val.toString();
        break;
    case 'array':
        val = val.toSTring();
        break;
    case 'undefined':
        val = '';
        break;
    case 'null':
        val = '';
        break;
    }

    return tool.escapeXML(val);
}

function getAtomic(option) {
    if (option === 'add') {
        return 'add';
    }
    if (option === 'inc') {
        return 'inc';
    }
    return 'set';
}

function Collection(config) {
    if ((this instanceof Collection) === false) {
        return new Collection(config);
    }

    var wt = 'json',
        fields = {},
        uniqueKey = false,
        field,
        self = this;

    /**
     * Parse solr schema and extract available fields
     */
    if (config.schema && config.schema.schema && config.schema.schema.fields && config.schema.schema.fields instanceof Array) {
        for (field in config.schema.schema.fields) {
            if (config.schema.schema.fields.hasOwnProperty(field)) {
                fields[config.schema.schema.fields[field].name] = config.schema.schema.fields[field];
            }
        }
    }

    /**
     * Get unique key from solr schema
     * @type {*|boolean}
     */
    uniqueKey = config.schema.schema.uniqueKey || false;

    this.getName = function () {
        return config.client.name;
    };

    this.getClient = function () {
        return config.client;
    };

    this.getFields = function () {
        return fields;
    };

    this.select = function (path) {
        return new Select(self, path);
    };

    this.add = function (entities, callback, options) {
        if (typeof options !== 'object') {
            options = {};
        }

        if (options.quiet === undefined) {
{'fraction_non_alphanumeric': 0.14437367303609341, 'fraction_numerical': 0.0, 'mean_word_length': 1.981715893108298, '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': '6391210', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1193, 'n_words': 296}