<commit_before>(function () {
    angular
        .module('dpDataSelection')
        .factory('dataSelectionApiDcatd', dataSelectionApiDcatdFactory);

    dataSelectionApiDcatdFactory.$inject = ['$window', '$q', '$filter', 'sharedConfig', 'api'];

    function dataSelectionApiDcatdFactory ($window, $q, $filter, sharedConfig, api) {
        const propertyName = {
            theme: '/properties/dcat:theme/items',
            format: '/properties/dcat:distribution/items/properties/dct:format',
            owner: '/properties/ams:owner',
            distributionType: '/properties/dcat:distribution/items/properties/ams:distributionType',
            serviceType: '/properties/dcat:distribution/items/properties/ams:serviceType'
        };

        return {
            query: query
        };

        function query (config, activeFilters, page, searchText = '', geometryFilter = undefined, catalogFilters = {}) {
            const deferred = $q.defer(),
                searchParams = {
                    offset: (page - 1) * config.MAX_ITEMS_PER_PAGE,
                    limit: config.MAX_ITEMS_PER_PAGE
                },
                queryTheme = activeFilters.groups && `eq=theme:${activeFilters.groups}`,
                queryFormat = activeFilters.formats && `eq=${activeFilters.formats}`,
                queryOwner = activeFilters.owners && `eq=${activeFilters.owners}`,
                queryDistributionType = activeFilters.distributionTypes && `eq=${activeFilters.distributionTypes}`,
                queryServiceType = activeFilters.serviceTypes && `eq=${activeFilters.serviceTypes}`;

            if (searchText) {
                // Optional search text
                searchParams.q = searchText;
            }

            if (queryTheme) {
                // optional thema/groups filter
                searchParams[propertyName.theme] = queryTheme;
            }

            if (queryFormat) {
                // optional format filter
                searchParams[propertyName.format] = queryFormat;
            }

            if (queryOwner) {
                // optional owner filter
                searchParams[propertyName.owner] = queryOwner;
            }

            if (queryDistributionType) {
                // optional distribution type filter
                searchParams[propertyName.distributionType] = queryDistributionType;
            }

            if (queryServiceType) {
                // optional service type filter
                searchParams[propertyName.serviceType] = queryServiceType;
            }

            if (!Object.keys(catalogFilters).length) {
                deferred.reject();
            } else {
                api.getByUri(config.ENDPOINT_PREVIEW, searchParams).then(data => {
                    const count = data['void:documents'];
                    if (count) {
                        const results = data['dcat:dataset'];
                        deferred.resolve({
                            numberOfPages: Math.ceil(count / config.MAX_ITEMS_PER_PAGE),
                            numberOfRecords: count,
                            filters: formatFilters(data['ams:facet_info'], catalogFilters),
                            data: formatData(config, results)
                        });
                    } else {
                        deferred.reject();
                    }
                }, deferred.reject);
            }
            return deferred.promise;
        }

        function getFacetOptions (facet, filterCatalog, namespace) {
            return Object.keys(facet).map(option => {
                const id = namespace ? option.replace(`${namespace}:`, '') : option;
                const catalogOption = filterCatalog.filter(item => item.id === id)[0];
                return {
                    id: id,
                    label: catalogOption ? catalogOption.label : '${option} niet gevonden',
                    count: facet[option]
                };<commit_msg>fix for issue with tabs not visible in homepage search BAC-1307<commit_after>(function () {
    angular
        .module('dpDataSelection')
        .factory('dataSelectionApiDcatd', dataSelectionApiDcatdFactory);

    dataSelectionApiDcatdFactory.$inject = ['$window', '$q', '$filter', 'sharedConfig', 'api'];

    function dataSelectionApiDcatdFactory ($window, $q, $filter, sharedConfig, api) {
        const propertyName = {
            theme: '/properties/dcat:theme/items',
            format: '/properties/dcat:distribution/items/properties/dct:format',
            owner: '/properties/ams:owner',
            distributionType: '/properties/dcat:distribution/items/properties/ams:distributionType',
            serviceType: '/properties/dcat:distribution/items/properties/ams:serviceType'
        };

        return {
            query: query
        };

        function query (config, activeFilters, page, searchText = '', geometryFilter = undefined, catalogFilters = {}) {
            const deferred = $q.defer(),
                searchParams = {
                    offset: (page - 1) * config.MAX_ITEMS_PER_PAGE,
                    limit: config.MAX_ITEMS_PER_PAGE
                },
                queryTheme = activeFilters.groups && `eq=theme:${activeFilters.groups}`,
                queryFormat = activeFilters.formats && `eq=${activeFilters.formats}`,
                queryOwner = activeFilters.owners && `eq=${activeFilters.owners}`,
                queryDistributionType = activeFilters.distributionTypes && `eq=${activeFilters.distributionTypes}`,
                queryServiceType = activeFilters.serviceTypes && `eq=${activeFilters.serviceTypes}`;

            if (searchText) {
                // Optional search text
                searchParams.q = searchText;
            }

            if (queryTheme) {
                // optional thema/groups filter
                searchParams[propertyName.theme] = queryTheme;
            }

            if (queryFormat) {
                // optional format filter
                searchParams[propertyName.format] = queryFormat;
            }

            if (queryOwner) {
                // optional owner filter
                searchParams[propertyName.owner] = queryOwner;
            }

            if (queryDistributionType) {
                // optional distribution type filter
                searchParams[propertyName.distributionType] = queryDistributionType;
            }

            if (queryServiceType) {
                // optional service type filter
                searchParams[propertyName.serviceType] = queryServiceType;
            }

            api.getByUri(config.ENDPOINT_PREVIEW, searchParams).then(data => {
                const count = data['void:documents'];
                if (count) {
                    const results = data['dcat:dataset'];
                    deferred.resolve({
                        numberOfPages: Math.ceil(count / config.MAX_ITEMS_PER_PAGE),
                        numberOfRecords: count,
                        filters: !Object.keys(catalogFilters).length ? {} :
                          formatFilters(data['ams:facet_info'], catalogFilters),
                        data: formatData(config, results)
                    });
                } else {
                    deferred.reject();
                }
            }, deferred.reject);

            return deferred.promise;
        }

        function getFacetOptions (facet, filterCatalog, namespace) {
            return Object.keys(facet).map(option => {
                const id = namespace ? option.replace(`${namespace}:`, '') : option;
                const catalogOption = filterCatalog.filter(item => item.id === id)[0];
                return {
                    id: id,
                    label: catalogOption ? catalogOption.label : '${option} niet gevonden',
                    count: facet[option]
                };
{'fraction_non_alphanumeric': 0.10388460078451221, 'fraction_numerical': 0.0010122738200683285, 'mean_word_length': 1.6702702702702703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4671513', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1822, 'n_words': 347}