<commit_before>const _ = require('lodash');

module.exports = {

  randomize: (array, amount) => {
    // let x = 0;
    // let randomResult = [];
    // while (x < amount) {
    //   let randomIndex = Math.floor(Math.random() * (array.length - 0) + 0);
    //   randomResult.push(array[randomIndex]);
    //   x += 1;
    // }
    let shuffledArray = _.shuffle(array);

    return shuffledArray.slice(0, amount);
  },

  categoriesList:  [
    'General Knowledge',
    'Entertainment: Books',
    'Entertainment: Film',
    'Entertainment: Music',
    'Entertainment: Television',
    'Entertainment: Video Games',
    'Entertainment: Board Games',
    'Entertainment: Japanese Anime & Manga',
    'Entertainment: Cartoon & Animations',
    'Science & Nature',
    'Science: Computers',
    'Science: Mathematics',
    'Mythology',
    'Sports',
    'Geography',
    'History',
    'Politics',
    'Art',
    'Celebrities',
    'Animals',
    'Vehicles',
  ],
  
  getRandomCategories: () => {
    return module.exports.randomize(module.exports.categoriesList, 5);
  },

  getRandomQuestions: (cate, questions) => {

    let result = [];
    const questionsList = _.filter(questions, function(question) {
      return question.category === cate;
    });<commit_msg>(fix) shuffle function scope<commit_after>const _ = require('lodash');

module.exports = {

  randomize: (array, amount) => {
    return _.shuffle(array).slice(0, amount);
  },

  categoriesList:  [
    'General Knowledge',
    'Entertainment: Books',
    'Entertainment: Film',
    'Entertainment: Music',
    'Entertainment: Television',
    'Entertainment: Video Games',
    'Entertainment: Board Games',
    'Entertainment: Japanese Anime & Manga',
    'Entertainment: Cartoon & Animations',
    'Science & Nature',
    'Science: Computers',
    'Science: Mathematics',
    'Mythology',
    'Sports',
    'Geography',
    'History',
    'Politics',
    'Art',
    'Celebrities',
    'Animals',
    'Vehicles',
  ],

  getRandomCategories: () => {
    return module.exports.randomize(module.exports.categoriesList, 5);
  },

  getRandomQuestions: (cate, questions) => {

    let result = [];
    const questionsList = _.filter(questions, function(question) {
      return question.category === cate;
    });
{'fraction_non_alphanumeric': 0.1555360281195079, 'fraction_numerical': 0.0035149384885764497, 'mean_word_length': 3.087971274685817, 'pattern_counts': {'":': 0, '<': 4, '<?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': '3912135', 'n_tokens_mistral': 744, 'n_tokens_neox': 694, 'n_words': 151}