<commit_before>'use strict';

app.factory('ResultsService', function($http, SELECT_SERVICE_URL) {
  return {
    getResults: function(options) {
      options = {
        query: options.query ? options.query : '',
        lang: options.lang ? options.lang : 'en',
        rows: options.rows ? options.rows : 4,
        section: options.section ?
          'khresmoi_sections_sectionType_facet:' +
          options.section.toUpperCase() : '',
        filters: parseFilters(options.filters),
      };
      return $http.get(SELECT_SERVICE_URL, {
        params: {
          facet: true,
          indent: 'off',
          group: true,
          docType: 'html',
          'f.khresmoi_sections_sectionType_facet.facet.limit': 50,
          'f.khresmoi_sections_sectionType_facet.facet.mincount': 1,
          'facet.field': [
            'khresmoi_sections_sectionType_facet',
            'health_topics_facet',
            'readability_difficult_facet',
            'readability_easy_facet',
          ],
          'group.field': 'domain',
          facetsToFetch: ' khresmoi_sections_cleanedBody_facet' +
          ' khresmoi_sections_cleanedTitle_facet' +
          ' khresmoi_sections_internalLink_facet' +
          ' khresmoi_sections_sectionType_facet' +
          ' readability_difficult_facet' +
          ' readability_easy_facet' +
          ' is_certified_facet',
          q: options.query,
          fq: [
            'docType:html',
            options.section,
            options.filters,
          ],
          searchLanguage: options.lang,
          wt: 'json',
        },
      });
    },
  };
});

function parseFilters(filters) {
  if (typeof filters !== 'string') {
    return '';
  }
  var filtersArray = filters.split(' ');
  filtersArray = filtersArray.map(function(s) {
    return '(hon_label_' + s + '_facet:true)';
  });
  filters = filtersArray.join(' OR ');
  return filters;
}<commit_msg>fix: questions results are the same as khresmoi<commit_after>'use strict';

app.factory('ResultsService', function($http, SELECT_SERVICE_URL) {
  return {
    getResults: function(options) {
      options = {
        query: options.query ? options.query : '',
        lang: options.lang ? options.lang : 'en',
        rows: options.rows ? options.rows : 4,
        section: options.section ?
          'khresmoi_sections_sectionType_facet:' +
          options.section.toUpperCase() : '',
        filters: parseFilters(options.filters),
      };
      return $http.get(SELECT_SERVICE_URL, {
        headers: {
          'X-Requested-With': 'XMLHttpRequest',
        },
        params: {
          facet: true,
          indent: 'off',
          group: true,
          docType: 'html',
          'f.khresmoi_sections_sectionType_facet.facet.limit': 50,
          'f.khresmoi_sections_sectionType_facet.facet.mincount': 1,
          'facet.field': [
            'khresmoi_sections_sectionType_facet',
            'health_topics_facet',
            'readability_difficult_facet',
            'readability_easy_facet',
          ],
          'group.field': 'domain',
          facetsToFetch: ' khresmoi_sections_cleanedBody_facet' +
          ' khresmoi_sections_cleanedTitle_facet' +
          ' khresmoi_sections_internalLink_facet' +
          ' khresmoi_sections_sectionType_facet' +
          ' readability_difficult_facet' +
          ' readability_easy_facet' +
          ' is_certified_facet',
          q: parseMore(options.query),
          fq: [
            'docType:html',
            options.section,
            options.filters,
          ],
          searchLanguage: options.lang,
          wt: 'json',
        },
      });
    },
  };
});

function parseFilters(filters) {
  if (typeof filters !== 'string') {
    return '';
  }
  var filtersArray = filters.split(' ');
  filtersArray = filtersArray.map(function(s) {
    return '(hon_label_' + s + '_facet:true)';
  });
  filters = filtersArray.join(' OR ');
  return filters;
}

var customHttpParamSerializer = function(params) {
  if (!params) { return ''; }
  var parts = [];
  var value;
  for (var param in params) {
    if (params.hasOwnProperty(param)) {
      value = params[param];
      if (value === null || typeof value === undefined) { return; }
      if (Array.isArray(value)) {
        parts.concat(serializeArray(value, param));
      } else {
        parts.push(encodeUriQuery(param) + '=' +
            encodeUriQuery(serializeValue(value)));
      }
    }
  }
  return parts.join('&');
};

function encodeUriQuery(val) {
  return encodeURIComponent(val).
    replace(/%40/gi, '@').
    replace(/%3A/gi, ':').
    replace(/%24/g, '$').
    replace(/%2C/gi, ',');
}

function serializeValue(v) {
  if (typeof v === 'object') {
    return v instanceof Date ? v.toISOString() : v;
  }
  return v;
}

function serializeArray(value, param) {
  var parts = [];
  value.forEach(function(v) {
    parts.push(encodeUriQuery(param)  + '=' +
      encodeUriQuery(serializeValue(v)));
  });
  return parts;
}

function parseMore(query) {
  return query.replace(/\?/g, '\\?');
}
{'fraction_non_alphanumeric': 0.13467614533965244, 'fraction_numerical': 0.002764612954186414, 'mean_word_length': 2.3366271409749673, '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': '5196177', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1586, 'n_words': 255}