<commit_before>var Scientilla = Scientilla || {};

Scientilla.user = {
   getAliases: function() {
        var firstLetter = function (string) {
            if (!string) return "";
            return string.charAt(0).toUpperCase();
        };
        var capitalize = function (string) {
            if (!string) return "";
            return _.capitalize(string.toLowerCase());
//                return str.replace(/\w\S*/g, function (txt) {
//                    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
//                });
        };
        var aliases = [];
        if (_.isEmpty(this.name) || _.isEmpty(this.surname))
            return aliases;
        var first_name = capitalize(this.name);
        var last_name = capitalize(this.surname);
        var initial_first_name = firstLetter(first_name);
        aliases.push(first_name + " " + last_name);
        aliases.push(last_name + " " + first_name);
        aliases.push(last_name + " " + initial_first_name + ".");
        aliases.push(initial_first_name + ". " + last_name + "");
        aliases = _.uniq(aliases);
        return aliases;
    },

    getUcAliases: function() {
        var aliases = this.getAliases();
        var ucAliases = _.map(aliases, function(a) { return a.toUpperCase();});
        return ucAliases;
    },
    
    getDisplayName: function() {
        var name = this.name ? this.name : "";
        var surname = this.surname ? this.surname : "";
        var fullName = _.trim(name + " " + surname);
        return fullName;
    }
};

//sTodo: evaluating wheter to reformat in a constructor style
Scientilla.reference = {
    create: function(referenceData, owner) {
        var fields = [
            'authors',
            'title',
            'status'
        ];
        var reference = _.pick(referenceData, fields);
        reference.owner = owner;
        _.extend(reference, Scientilla.reference);
        return reference;
    },
    getAuthors: function () {
            if (!this.authors) return [];

            return this.authors.replace(/\s+et all\s*$/i, '').split(',').map(_.trim);
        },
        getUcAuthors: function() {
            var authors = this.getAuthors();
            var ucAuthors = _.map(authors, function(a) { return a.toUpperCase();});
            return ucAuthors;
        },
        hasRealOwner: function() {
            return _.isObject(this.owner);
        },
        getDisplayName: function() {
            return this.getDisplayName();
        }
};

Scientilla.membership = {
    getDisplayName: function() {
        //sTODO: to be removed when deep populate is implemented
        if (_.isFunction(this.user.getDisplayName))
            return this.user.getDisplayName();
        else
            return '';
    }
};<commit_msg>Added function to create a new group reference.<commit_after>var Scientilla = Scientilla || {};

Scientilla.user = {
    getAliases: function () {
        var firstLetter = function (string) {
            if (!string)
                return "";
            return string.charAt(0).toUpperCase();
        };
        var capitalize = function (string) {
            if (!string)
                return "";
            return _.capitalize(string.toLowerCase());
//                return str.replace(/\w\S*/g, function (txt) {
//                    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
//                });
        };
        var aliases = [];
        if (_.isEmpty(this.name) || _.isEmpty(this.surname))
            return aliases;
        var first_name = capitalize(this.name);
        var last_name = capitalize(this.surname);
        var initial_first_name = firstLetter(first_name);
        aliases.push(first_name + " " + last_name);
        aliases.push(last_name + " " + first_name);
        aliases.push(last_name + " " + initial_first_name + ".");
        aliases.push(initial_first_name + ". " + last_name + "");
        aliases = _.uniq(aliases);
        return aliases;
    },
    getUcAliases: function () {
        var aliases = this.getAliases();
        var ucAliases = _.map(aliases, function (a) {
            return a.toUpperCase();
        });
        return ucAliases;
    },
    getDisplayName: function () {
        var name = this.name ? this.name : "";
        var surname = this.surname ? this.surname : "";
        var fullName = _.trim(name + " " + surname);
        return fullName;
    }
};

//sTodo: evaluating wheter to reformat in a constructor style
Scientilla.reference = {
    create: function (referenceData, owner) {
        var fields = [
            'authors',
            'title',
            'status'
        ];
        var reference = _.pick(referenceData, fields);
        reference.owner = owner;
        _.extend(reference, Scientilla.reference);
        return reference;
    },
    getAuthors: function () {
        if (!this.authors)
            return [];

        return this.authors.replace(/\s+et all\s*$/i, '').split(',').map(_.trim);
    },
    getUcAuthors: function () {
        var authors = this.getAuthors();
        var ucAuthors = _.map(authors, function (a) {
            return a.toUpperCase();
        });
        return ucAuthors;
    },
    hasRealOwner: function () {
        return _.isObject(this.owner);
    },
    getDisplayName: function () {
        return this.getDisplayName();
    },
    getNewGroupReference: function (groupId) {
        return {
            title: "",
            authors: "",
            groupOwner: groupId
        };
    }
};

Scientilla.membership = {
    getDisplayName: function () {
        //sTODO: to be removed when deep populate is implemented
        if (_.isFunction(this.user.getDisplayName))
            return this.user.getDisplayName();
        else
            return '';
    }
};
{'fraction_non_alphanumeric': 0.1343540340615861, 'fraction_numerical': 0.001032169275761225, 'mean_word_length': 1.901197604790419, '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': '3279206', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1628, 'n_words': 346}