<commit_before>'use strict';

module.exports = function (grunt) {
  grunt.registerMultiTask('split', function () {
    var options = this.options();

    var path = require('path');
    var _ = require('lodash');

    var basePath = path.join(options.srcFolder, options.academicYear.replace('/', '-'), options.semester);
    var normalizePath = path.join(basePath, grunt.config('normalize').options.destFileName);
    var normalized = grunt.file.readJSON(normalizePath);

    var moduleCodes = _.pluck(normalized, 'ModuleCode');
    grunt.file.write(
      path.join(basePath, options.destModuleCodes),
      JSON.stringify(moduleCodes, null, options.jsonSpace)
    );

    var moduleTitles = _.pluck(normalized, 'ModuleTitle');
    grunt.file.write(
      path.join(basePath, options.destModuleList),
      JSON.stringify(_.object(moduleCodes, moduleTitles), null, options.jsonSpace)
    );

    var moduleInformation = [];

    normalized.forEach(function (mod) {
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode + '.json'),
        JSON.stringify(mod, null, options.jsonSpace)
      );

      var info = _.pick(mod, [
        'ModuleCode',
        'ModuleTitle',
        'Department',
        'ModuleDescription',
        'CrossModule',
        'ModuleCredit',
        'Workload',
        'Prerequisite',
        'Preclusion',
        'Corequisite',
        'ExamDate',
        'Types',
        'Lecturers',
        'LecturePeriods',
        'TutorialPeriods'
      ]);
      moduleInformation.push(info);
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'index.json'),
        JSON.stringify(info, null, options.jsonSpace)
      );

      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'corsbiddingstats.json'),
        JSON.stringify(mod.CorsBiddingStats || [], null, options.jsonSpace)
      );
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'ivle.json'),
        JSON.stringify(mod.IVLE || [], null, options.jsonSpace)
      );
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'timetable.json'),
        JSON.stringify(mod.Timetable || [], null, options.jsonSpace)
      );
    });

    grunt.file.write(
      path.join(basePath, options.destModuleInformation),
      JSON.stringify(moduleInformation, null, options.jsonSpace)
    );
  });
};<commit_msg>Added timetable splitting task<commit_after>'use strict';

module.exports = function (grunt) {
  grunt.registerMultiTask('split', function () {
    var options = this.options();

    var path = require('path');
    var _ = require('lodash');

    var basePath = path.join(options.srcFolder, options.academicYear.replace('/', '-'), options.semester);
    var normalizePath = path.join(basePath, grunt.config('normalize').options.destFileName);
    var normalized = grunt.file.readJSON(normalizePath);

    var moduleCodes = _.pluck(normalized, 'ModuleCode');
    grunt.file.write(
      path.join(basePath, options.destModuleCodes),
      JSON.stringify(moduleCodes, null, options.jsonSpace)
    );

    var moduleTitles = _.pluck(normalized, 'ModuleTitle');
    grunt.file.write(
      path.join(basePath, options.destModuleList),
      JSON.stringify(_.object(moduleCodes, moduleTitles), null, options.jsonSpace)
    );

    var moduleInformation = [];

    normalized.forEach(function (mod) {
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode + '.json'),
        JSON.stringify(mod, null, options.jsonSpace)
      );

      var info = _.pick(mod, [
        'ModuleCode',
        'ModuleTitle',
        'Department',
        'ModuleDescription',
        'CrossModule',
        'ModuleCredit',
        'Workload',
        'Prerequisite',
        'Preclusion',
        'Corequisite',
        'ExamDate',
        'Types',
        'Lecturers',
        'LecturePeriods',
        'TutorialPeriods'
      ]);
      moduleInformation.push(info);
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'index.json'),
        JSON.stringify(info, null, options.jsonSpace)
      );

      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'corsbiddingstats.json'),
        JSON.stringify(mod.CorsBiddingStats || [], null, options.jsonSpace)
      );
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'ivle.json'),
        JSON.stringify(mod.IVLE || [], null, options.jsonSpace)
      );
      grunt.file.write(
        path.join(basePath, options.destSubfolder, mod.ModuleCode, 'timetable.json'),
        JSON.stringify(mod.Timetable || [], null, options.jsonSpace)
      );
    });

    grunt.file.write(
      path.join(basePath, 'timetable.json'), 
      JSON.stringify(normalized.map(function (mod) {
        return _.pick(mod, [
        'ModuleCode',
        'ModuleTitle',
        'Timetable'
        ]);
      }), null, options.jsonSpace)
    );

    grunt.file.write(
      path.join(basePath, options.destModuleInformation),
      JSON.stringify(moduleInformation, null, options.jsonSpace)
    );
  });
};
{'fraction_non_alphanumeric': 0.14143540669856458, 'fraction_numerical': 0.0, 'mean_word_length': 2.834189288334556, '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': '454625', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1571, 'n_words': 249}