<commit_before>(function() {
    Backbone.BatchCollection = Backbone.Collection.extend({
        isNew: function() {
            var isNew = this.all(function(model) {
                return !_.has(model, 'id');
            });
            return isNew;
        },
        isChanged: function() {
            var isChanged = this.some(function(model) {
                return model.hasChanged();
            });
            return isChanged;
        },
        save: function(options) {
            // initialize options
            if (_.isUndefined(options)) {
                options = {};
            }
            _.defaults(options, {
                url: this.url,
                contentType: 'application/json',
                silent: false,
                data: this.toJSON()
            });

            // check collection status
            if (this.isEmpty()) {
                return this.batchDelete(options);
            }
            else if (this.isNew()) {
                return this.batchAdd(options);
            }
            else {
                return this.batchUpdate(options);
            }
        },
        batch: function(options) {
            // create parameters
            var ajaxOptions = {
                type: options.type,
                url: options.url,
                data: JSON.stringify(options.data),
                contentType: options.contentType,
                success: options.success,
                error: options.error,
                complete: options.complete,
                context: this
            };
<commit_msg>Support url as a function<commit_after>(function() {
    Backbone.BatchCollection = Backbone.Collection.extend({
        isNew: function() {
            var isNew = this.all(function(model) {
                return !_.has(model, 'id');
            });
            return isNew;
        },
        isChanged: function() {
            var isChanged = this.some(function(model) {
                return model.hasChanged();
            });
            return isChanged;
        },
        save: function(options) {
            // initialize options
            if (_.isUndefined(options)) {
                options = {};
            }
            _.defaults(options, {
                url: _.result(this, 'url'),
                contentType: 'application/json',
                silent: false,
                data: this.toJSON()
            });

            // check collection status
            if (this.isEmpty()) {
                return this.batchDelete(options);
            }
            else if (this.isNew()) {
                return this.batchAdd(options);
            }
            else {
                return this.batchUpdate(options);
            }
        },
        batch: function(options) {
            // create parameters
            var ajaxOptions = {
                type: options.type,
                url: options.url,
                data: JSON.stringify(options.data),
                contentType: options.contentType,
                success: options.success,
                error: options.error,
                complete: options.complete,
                context: this
            };

{'fraction_non_alphanumeric': 0.10284463894967177, 'fraction_numerical': 0.0, 'mean_word_length': 1.1534320323014804, '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': '941436', 'n_tokens_mistral': 765, 'n_tokens_neox': 726, 'n_words': 155}