<commit_before>const categoriesDescription = require('../description-boxes/category.json');
const gallerysDescription = require('../description-boxes/gallery.json');
const museumsDescription = require('../description-boxes/museum.json');

function createDescriptionBox (selectedFilters) {
  selectedFilters = selectedFilters || {};

  function getDescription (filterKey, jsonDescription) {
    const filter = Object.keys(selectedFilters[filterKey] || [])[0];
    if (!jsonDescription[filter].title) {
      jsonDescription[filter].title = filter;
    }
    return jsonDescription[filter];
  }

  function filterNotFoundMessage (filterType, filterKey) {
    const shouldMatch = Object.keys(selectedFilters[filterKey] || [])[0];
    console.log(filterType + ' didn\'t match, ensure the exact ' +
      filterType.toLowerCase() + ' title was used');
    console.log(filterKey + ' title should match: ', shouldMatch);
  }

  if (selectedFilters.categories) {
    const categoryDescription = getDescription('categories', categoriesDescription);
    if (categoryDescription) {
      return {category: categoryDescription};
    }
    filterNotFoundMessage('Category', 'categories');
  }

  if (selectedFilters.gallery) {
    const galleryDescription = getDescription('gallery', gallerysDescription);
    if (galleryDescription) {
      return {gallery: galleryDescription};
    }
    filterNotFoundMessage('Gallery', 'gallery');
  }<commit_msg>fix for when json description doesn't exist<commit_after>const categoriesDescription = require('../description-boxes/category.json');
const gallerysDescription = require('../description-boxes/gallery.json');
const museumsDescription = require('../description-boxes/museum.json');

function createDescriptionBox (selectedFilters) {
  selectedFilters = selectedFilters || {};

  function getDescription (filterKey, jsonDescription) {
    const filter = Object.keys(selectedFilters[filterKey] || [])[0];
    if (jsonDescription[filter] && !jsonDescription[filter].title) {
      jsonDescription[filter].title = filter;
    }
    return jsonDescription[filter];
  }

  function filterNotFoundMessage (filterType, filterKey) {
    const shouldMatch = Object.keys(selectedFilters[filterKey] || [])[0];
    console.log(filterType + ' didn\'t match, ensure the exact ' +
      filterType.toLowerCase() + ' title was used');
    console.log(filterKey + ' title should match: ', shouldMatch);
  }

  if (selectedFilters.categories) {
    const categoryDescription = getDescription('categories', categoriesDescription);
    if (categoryDescription) {
      return {category: categoryDescription};
    }
    filterNotFoundMessage('Category', 'categories');
  }

  if (selectedFilters.gallery) {
    const galleryDescription = getDescription('gallery', gallerysDescription);
    if (galleryDescription) {
      return {gallery: galleryDescription};
    }
    filterNotFoundMessage('Gallery', 'gallery');
  }
{'fraction_non_alphanumeric': 0.12589559877175024, 'fraction_numerical': 0.001364721937905152, 'mean_word_length': 4.805940594059406, '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': '2242067', 'n_tokens_mistral': 754, 'n_tokens_neox': 747, 'n_words': 161}