<commit_before>define(["underscore", "js/core/List", "js/type/Color"], function (_, List, Color) {

    var colorArray = [
        "universal.COLOR_WHITE", 0xFFFFFF,
        "universal.COLOR_BLACK", 0x000000,
        "universal.COLOR_BLUE", 0x2244AA,
        "universal.COLOR_RED", 0xB91816,
        "universal.COLOR_GREY", 0xCCCCCC,
        "universal.COLOR_BROWN", 0x664B2F,
        "universal.COLOR_GREEN", 0x669933,
        "universal.COLOR_YELLOW", 0xFFF500,
        "universal.COLOR_TURQUOISE", 0x0AC7DF,
        "universal.COLOR_PINK", 0xFB4E81
    ];


    var productTypeToColorMap = {},
        colorMap = {},
        colors = [],
        productTypeDepartmentToSizeMap = {},
        categoryToSizeMap = {},
        departmentProductTypeMap = {},
        productTypeToDepartmentsMap = {};

    return {
        /***
         * initializes the productTypeColorCache
         * @param {js.core.List} productTypes
         */
        initProductTypeColorCache: function (productTypes) {
            var color,
                distance,
                bestColor,
                bestAppearance,
                tmpDistance,
                tmpProductType,
                colorKey;
            colors = [];
            for (var i = 1; i <= colorArray.length; i = i + 2) {
                color = Color.parse(colorArray[i]);
                colors.push(color);
                colorMap[color.toString()] = color;
            }


            productTypes.each(function (productType) {
                bestColor = null;
                productTypeToColorMap[productType.$.id] = tmpProductType = {};
                if (productType.$.appearances) {
                    productType.$.appearances.each(function (appearance) {
                        distance = Number.MAX_VALUE;
                        bestColor = null;
                        for (var i = 0; i < colors.length; i++) {
                            color = colors[i];
                            bestAppearance = null;
                            tmpDistance = color.distanceTo(appearance.getMainColor());
                            if (tmpDistance < distance) {
                                distance = tmpDistance;
                                bestColor = color;
                            }
                        }
                        colorKey = bestColor.toString();
                        if (!tmpProductType[colorKey]) {
                            tmpProductType[colorKey] = [];
                        }
                        tmpProductType[colorKey].push(appearance);
                    });
                }
            });
        },
        /***
         *
         * @param {js.core.List} productTypeDepartments
         */
        initProductTypeSizeCache: function (productTypeDepartments) {

            var departmentSizes,
                categorySizes;

            productTypeDepartments.each(function (productTypeDepartment) {
                if (productTypeDepartment.isRealDepartment()) {
                    departmentSizes = productTypeDepartmentToSizeMap[productTypeDepartment.$.name] = {};
                    productTypeDepartment.$.categories.each(function (category) {
                        categorySizes = categoryToSizeMap[category.identifier()] = {};
                        category.$.productTypes.each(function (productType) {
                            if (productType.$.sizes) {
                                productType.$.sizes.each(function (size) {
                                    if (!departmentSizes[size.$.name]) {
                                        departmentSizes[size.$.name] = {
                                            productTypes: []
                                        };
                                    }
                                    departmentSizes[size.$.name].productTypes.push(productType);
                                    if (!categorySizes[size.$.name]) {
                                        categorySizes[size.$.name] = {
                                            productTypes: []
                                        };
                                    }
                                    categorySizes[size.$.name].productTypes.push(productType);
                                });

                                departmentProductTypeMap[productTypeDepartment.$.name] = departmentProductTypeMap[productTypeDepartment.$.name] || {};
                                departmentProductTypeMap[productTypeDepartment.$.name][productType.$.id] = productTypeDepartment.$.name;
                                if (!productTypeToDepartmentsMap[productType.$.id]) {
                                    productTypeToDepartmentsMap[productType.$.id] = [];
                                }
                                productTypeToDepartmentsMap[productType.$.id].push(productTypeDepartment);
                            }
                        });
                    });
                }
            });

        },
        /***
         *
         * @param {sprd.model.ProductTypeDepartment} productTypeDepartment
         * @param {sprd.entity.DepartmentCategory} category
         * @returns {Array}
         */
        getGroupedSizes: function (productTypes, department) {

            function sizeMapToArray(sizeMap, departmentName) {
                var ret = [];
                for (var sizeName in sizeMap) {
                    if (sizeMap.hasOwnProperty(sizeName)) {
                        ret.push({
                            name: sizeName,
                            departmentName: departmentName,
                            productTypes: sizeMap[sizeName].productTypes
                        });
                    }
                }
                return ret;
            }

            var departmentSizeMap = productTypeDepartmentToSizeMap;

            if (productTypes) {
                var departmentHash,
                    key, departments;

                departmentSizeMap = {};
                productTypes.each(function (productType) {<commit_msg>removed order stuff in AppearanceUtil<commit_after>define(["underscore", "js/core/List", "js/type/Color"], function (_, List, Color) {

    var colorArray = [
        "universal.COLOR_WHITE", 0xFFFFFF,
        "universal.COLOR_BLACK", 0x000000,
        "universal.COLOR_BLUE", 0x2244AA,
        "universal.COLOR_RED", 0xB91816,
        "universal.COLOR_GREY", 0xCCCCCC,
        "universal.COLOR_BROWN", 0x664B2F,
        "universal.COLOR_GREEN", 0x669933,
        "universal.COLOR_YELLOW", 0xFFF500,
        "universal.COLOR_TURQUOISE", 0x0AC7DF,
        "universal.COLOR_PINK", 0xFB4E81
    ];


    var productTypeToColorMap = {},
        colorMap = {},
        colors = [],
        productTypeDepartmentToSizeMap = {},
        categoryToSizeMap = {},
        departmentProductTypeMap = {},
        productTypeToDepartmentsMap = {};

    return {
        /***
         * initializes the productTypeColorCache
         * @param {js.core.List} productTypes
         */
        initProductTypeColorCache: function (productTypes) {
            var color,
                distance,
                bestColor,
                bestAppearance,
                tmpDistance,
                tmpProductType,
                colorKey;
            colors = [];
            for (var i = 1; i <= colorArray.length; i = i + 2) {
                color = Color.parse(colorArray[i]);
                colors.push(color);
                colorMap[color.toString()] = color;
            }


            productTypes.each(function (productType) {
                bestColor = null;
                productTypeToColorMap[productType.$.id] = tmpProductType = {};
                if (productType.$.appearances) {
                    productType.$.appearances.each(function (appearance) {
                        distance = Number.MAX_VALUE;
                        bestColor = null;
                        for (var i = 0; i < colors.length; i++) {
                            color = colors[i];
                            bestAppearance = null;
                            tmpDistance = color.distanceTo(appearance.getMainColor());
                            if (tmpDistance < distance) {
                                distance = tmpDistance;
                                bestColor = color;
                            }
                        }
                        colorKey = bestColor.toString();
                        if (!tmpProductType[colorKey]) {
                            tmpProductType[colorKey] = [];
                        }
                        tmpProductType[colorKey].push(appearance);
                    });
                }
            });
        },
        /***
         *
         * @param {js.core.List} productTypeDepartments
         */
        initProductTypeSizeCache: function (productTypeDepartments) {

            var departmentSizes,
                categorySizes;

            productTypeDepartments.each(function (productTypeDepartment, index) {
                if (productTypeDepartment.isRealDepartment()) {
                    departmentSizes = productTypeDepartmentToSizeMap[productTypeDepartment.$.name] = {
                        order: index
                    };
                    productTypeDepartment.$.categories.each(function (category) {
                        categorySizes = categoryToSizeMap[category.identifier()] = {};
                        category.$.productTypes.each(function (productType) {
                            if (productType.$.sizes) {
                                productType.$.sizes.each(function (size) {
                                    if (!departmentSizes[size.$.name]) {
                                        departmentSizes[size.$.name] = {
                                            productTypes: []
                                        };
                                    }
                                    departmentSizes[size.$.name].productTypes.push(productType);
                                    if (!categorySizes[size.$.name]) {
                                        categorySizes[size.$.name] = {
                                            productTypes: []
                                        };
                                    }
                                    categorySizes[size.$.name].productTypes.push(productType);
                                });

                                departmentProductTypeMap[productTypeDepartment.$.name] = departmentProductTypeMap[productTypeDepartment.$.name] || {};
                                departmentProductTypeMap[productTypeDepartment.$.name][productType.$.id] = productTypeDepartment.$.name;
                                if (!productTypeToDepartmentsMap[productType.$.id]) {
                                    productTypeToDepartmentsMap[productType.$.id] = [];
                                }
                                productTypeToDepartmentsMap[productType.$.id].push(productTypeDepartment);
                            }
                        });
                    });
                }
            });

        },
        /***
         *
         * @param {sprd.model.ProductTypeDepartment} productTypeDepartment
         * @param {sprd.entity.DepartmentCategory} category
         * @returns {Array}
         */
        getGroupedSizes: function (productTypes, department) {

            function sizeMapToArray(sizeMap, departmentName) {
                var ret = [];
                for (var sizeName in sizeMap) {
                    if (sizeMap.hasOwnProperty(sizeName)) {
                        ret.push({
                            name: sizeName,
                            departmentName: departmentName,
                            productTypes: sizeMap[sizeName].productTypes
                        });
                    }
                }

                return ret;
            }

            var departmentSizeMap = productTypeDepartmentToSizeMap;

            if (productTypes) {
                var departmentHash,
                    key, departments;

                departmentSizeMap = {};
                productTypes.each(function (productType) {
{'fraction_non_alphanumeric': 0.09252610966057441, 'fraction_numerical': 0.007506527415143603, 'mean_word_length': 1.1390924956369983, 'pattern_counts': {'":': 0, '<': 9, '<?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': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2332449', 'n_tokens_mistral': 2918, 'n_tokens_neox': 2677, 'n_words': 401}