<commit_before>'use strict';

angular.module('iMLApp.interactive-learning.interactive-learning-controller', [])

  .controller('ILCtrl', function ($scope, $q, ILService, algoConfig) {

    $scope.showDiagram = false;
    $scope.showTooltipFirst = false;
    $scope.showTooltipSecond = false;
    $scope.learningContainerVisible = true;
    $scope.showDoneMessage = false;

    $scope.formatNumber = function(i) {
      return Math.round(i * 10000)/10000;
    };

    $scope.columnNames = ["age", "education-num","hours-per-week", "workclass", "native-country", "sex", "race",
      "relationship","occupation","income", "marital-status"];

    $scope.allCases = [];
    $scope.userDecisions = [];
    $scope.dataTop = [];
    $scope.dataBottom = [];
    $scope.weightVecTop = [];
    $scope.weightVecBottom = [];
    $scope.center = {};
    $scope.movedUp = false;
    $scope.movedDown = false;
    $scope.currentRound = 0;
    $scope.currentKFactor = algoConfig.startKFactor;

    let currentRecordIdx = 0;

    $scope.setRecords = function() {
      $scope.dataTop = [];
      $scope.dataBottom = [];
      $scope.center = {};
      if ($scope.allCases.length > currentRecordIdx) {
        $scope.center = $scope.allCases[currentRecordIdx].dataPoint._features;
        $scope.dataTop.push($scope.allCases[currentRecordIdx].cluster1);
        $scope.dataTop.push($scope.allCases[currentRecordIdx].cluster1);
        $scope.dataBottom.push($scope.allCases[currentRecordIdx].cluster2);
        $scope.dataBottom.push($scope.allCases[currentRecordIdx].cluster2);
        $scope.weightVecTop = ILService.getWeightsArray($scope.allCases[currentRecordIdx].weights);
        $scope.weightVecBottom = ILService.getWeightsArray($scope.allCases[currentRecordIdx].weights);
      } else if ($scope.currentRound < (algoConfig.maxKFactor - algoConfig.startKFactor)) {
        $scope.currentRound += 1;
        $scope.currentKFactor += 1;
        currentRecordIdx = 0;
        ILService.saveUserDecisionsAndCalculateNewWeights($scope.userDecisions);
        $scope.retrieveNewCases();
      } else {
        $scope.learningContainerVisible = false;
        $scope.showDoneMessage = true;
      }
    };

    $scope.retrieveNewCases = function () {
      var promise_case = ILService.getCases($scope.currentKFactor);

      promise_case.then(function (data) {
        $scope.allCases = data;
        $scope.setRecords();
      }, function(reason) {              //error
        console.log("ILCTrl " + "[error] retrieving of anonymized clusters and centers failed: ", reason);
      });
    };

    $scope.retrieveNewCases();
    var centerRecordTag = $("#panel-center");

    $scope.up = function () {
      console.log("[ILCtrl] data record sent up");

      let userDecision = {};
      userDecision.cat_level = $scope.allCases[currentRecordIdx].cluster1_cat_level;
      userDecision.cont_range = $scope.allCases[currentRecordIdx].cluster1_cont_range;
      userDecision.dataPoint = $scope.allCases[currentRecordIdx].dataPoint;
      userDecision.datapoint_cat_level = $scope.allCases[currentRecordIdx].datapoint_cat_level;
      $scope.userDecisions.push(userDecision);

      $scope.movedUp = true;
      centerRecordTag.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd',
        function(e) {
          // code to execute after transition ends
          currentRecordIdx += 1;
          $scope.setRecords();
          $scope.movedUp = false;
          $scope.$digest();
      });
    };

    $scope.down = function () {
      console.log("[ILCtrl] data record sent down");

      let userDecision = {};
      userDecision.cat_level = $scope.allCases[currentRecordIdx].cluster2_cat_level;
      userDecision.cont_range = $scope.allCases[currentRecordIdx].cluster2_cont_range;
      userDecision.dataPoint = $scope.allCases[currentRecordIdx].dataPoint;
      userDecision.datapoint_cat_level = $scope.allCases[currentRecordIdx].datapoint_cat_level;
      $scope.userDecisions.push(userDecision);

      $scope.movedDown = true;
      centerRecordTag.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd',
      function(e) {
        // code to execute after transition ends<commit_msg>Fixed transition bug in firefox<commit_after>'use strict';

angular.module('iMLApp.interactive-learning.interactive-learning-controller', [])

  .controller('ILCtrl', function ($scope, $q, ILService, algoConfig) {

    $scope.showDiagram = false;
    $scope.showTooltipFirst = false;
    $scope.showTooltipSecond = false;
    $scope.learningContainerVisible = true;
    $scope.showDoneMessage = false;

    $scope.formatNumber = function(i) {
      return Math.round(i * 10000)/10000;
    };

    $scope.columnNames = ["age", "education-num","hours-per-week", "workclass", "native-country", "sex", "race",
      "relationship","occupation","income", "marital-status"];

    $scope.allCases = [];
    $scope.userDecisions = [];
    $scope.dataTop = [];
    $scope.dataBottom = [];
    $scope.weightVecTop = [];
    $scope.weightVecBottom = [];
    $scope.center = {};
    $scope.movedUp = false;
    $scope.movedDown = false;
    $scope.currentRound = 0;
    $scope.currentKFactor = algoConfig.startKFactor;

    let currentRecordIdx = 0;

    $scope.setRecords = function() {
      $scope.dataTop = [];
      $scope.dataBottom = [];
      $scope.center = {};
      if ($scope.allCases.length > currentRecordIdx) {
        $scope.center = $scope.allCases[currentRecordIdx].dataPoint._features;
        $scope.dataTop.push($scope.allCases[currentRecordIdx].cluster1);
        $scope.dataTop.push($scope.allCases[currentRecordIdx].cluster1);
        $scope.dataBottom.push($scope.allCases[currentRecordIdx].cluster2);
        $scope.dataBottom.push($scope.allCases[currentRecordIdx].cluster2);
        $scope.weightVecTop = ILService.getWeightsArray($scope.allCases[currentRecordIdx].weights);
        $scope.weightVecBottom = ILService.getWeightsArray($scope.allCases[currentRecordIdx].weights);
      } else if ($scope.currentRound < (algoConfig.maxKFactor - algoConfig.startKFactor)) {
        $scope.currentRound += 1;
        $scope.currentKFactor += 1;
        currentRecordIdx = 0;
        ILService.saveUserDecisionsAndCalculateNewWeights($scope.userDecisions);
        $scope.retrieveNewCases();
      } else {
        $scope.learningContainerVisible = false;
        $scope.showDoneMessage = true;
      }
    };

    $scope.retrieveNewCases = function () {
      var promise_case = ILService.getCases($scope.currentKFactor);

      promise_case.then(function (data) {
        $scope.allCases = data;
        $scope.setRecords();
      }, function(reason) {              //error
        console.log("ILCTrl " + "[error] retrieving of anonymized clusters and centers failed: ", reason);
      });
    };

    $scope.retrieveNewCases();
    var centerRecordTag = $("#panel-center");

    $scope.up = function () {
      console.log("[ILCtrl] data record sent up");

      let userDecision = {};
      userDecision.cat_level = $scope.allCases[currentRecordIdx].cluster1_cat_level;
      userDecision.cont_range = $scope.allCases[currentRecordIdx].cluster1_cont_range;
      userDecision.dataPoint = $scope.allCases[currentRecordIdx].dataPoint;
      userDecision.datapoint_cat_level = $scope.allCases[currentRecordIdx].datapoint_cat_level;
      $scope.userDecisions.push(userDecision);

      $scope.movedUp = true;
      centerRecordTag.one('webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd',
        function(e) {
          // code to execute after transition ends
          currentRecordIdx += 1;
          $scope.setRecords();
          $scope.movedUp = false;
          $scope.$digest();
      });
    };

    $scope.down = function () {
      console.log("[ILCtrl] data record sent down");

      let userDecision = {};
      userDecision.cat_level = $scope.allCases[currentRecordIdx].cluster2_cat_level;
      userDecision.cont_range = $scope.allCases[currentRecordIdx].cluster2_cont_range;
      userDecision.dataPoint = $scope.allCases[currentRecordIdx].dataPoint;
      userDecision.datapoint_cat_level = $scope.allCases[currentRecordIdx].datapoint_cat_level;
      $scope.userDecisions.push(userDecision);

      $scope.movedDown = true;
      centerRecordTag.one('webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd',
      function(e) {
        // code to execute after transition ends
{'fraction_non_alphanumeric': 0.13162878787878787, 'fraction_numerical': 0.005681818181818182, 'mean_word_length': 3.3936557462298493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '376496', 'n_tokens_mistral': 2590, 'n_tokens_neox': 2516, 'n_words': 365}