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

module.exports = Model;

function Model(inputMatrix, rowLabels, colLabels) {

  this.rowLabels = rowLabels;
  this.colLabels = colLabels;
  this.input = inputMatrix;
  this.output = {};
}

Model.prototype.neighbors = function(row, n){

  if( this.output == null || this.output['neighbors'] == undefined )
    return;

  if(!n)
    n = 10;

  var neighbors = _.cloneDeep(this.output['neighbors']);

  if( row == undefined ){
    return neighbors;
  }

  var rowIndex = row;


  if(this.rowLabels)
    rowIndex = findInArray(this.rowLabels, row);

  var output = neighbors[rowIndex];

  if( !output ){
    return [];
  }

  if( this.rowLabels ){
    for( var i in output ){
      output[i].user = this.rowLabels[ output[i].user ];
    }
  }

  if( output.length > 0 ){
    output.sort(function(a, b) {return b.similarity - a.similarity;});
  }

  return output.splice(0,n);
}
<commit_msg>fix bugs<commit_after>var _ = require('lodash');

module.exports = Model;

function Model(inputMatrix, rowLabels, colLabels) {

  this.rowLabels = rowLabels;
  this.colLabels = colLabels;
  this.input = inputMatrix;
  this.output = {};
}

Model.prototype.neighbors = function(row, n){

  if( this.output == null || this.output['neighbors'] == undefined )
    return;

  if(!n)
    n = 10;

  var neighbors = _.cloneDeep(this.output['neighbors']);

  if( row == undefined ){
    return neighbors;
  }

  var rowIndex = row;


  if(this.rowLabels)
    rowIndex = findInArray(this.rowLabels, row);

  var output = neighbors[rowIndex];

  if( this.rowLabels ){
    for( var i in output ){
      output[i].user = this.rowLabels[ output[i].user ];
    }
  }

  if( output || output.length > 0 ){
    output.sort(function(a, b) {return b.similarity - a.similarity;});
  }

  return output.splice(0,n);
}

{'fraction_non_alphanumeric': 0.15443592552026286, 'fraction_numerical': 0.004381161007667032, 'mean_word_length': 3.2587412587412588, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1941764', 'n_tokens_mistral': 665, 'n_tokens_neox': 621, 'n_words': 135}