<commit_before>/**
 * Constructs GitHub recommendation database. Based on followers of a project
 * attemtps to find related proejcts. This program saves results into `out` folder
 *
 * Usage:
 *   node  constructRecommendations.js ./db/followers ./db/stars
 *
 * Where:
 *   - followers: leveldb database name with indexed followers (produced by followersIndexer)
 *   - stars: leveldb database name with indexed stars (produced by starsIndexer)
 */
var fs = require('fs');
var saveRecommendation = require('./lib/saveRecommendation');
var findRelated = require('./lib/findRelated');

/*
if (!checkInput()) {
  printHelp();
  return -1;
}

fs.mkdirSync('./out');
fs.mkdirSync('./projects');
*/
// we will iterate over each project:
var projectsDB = openDB(process.argv[2]);
var starsDB = openDB(process.argv[3]);
processProjects();

function processProjects() {
  var projects = [];
//  var projectName = 'angular/angular.js';
  var projectName = 'anvaka/ngraph';
  //projectName = 'lodash/lodash';
  projectsDB.getAllKeyValues([projectName])
    .then(function (p) {
var followers = p[projectName];
    starsDB.getAllKeyValues(followers)
      .then(function (usersDB) {
        console.log('Loaded projects starred by followers of ' + projectName);
        var related = findRelated(followers, usersDB);
        /*
        saveRecommendation(projectName, related);
        projects.push(projectName);
        */
       console.log(related.slice(0, 10));
      });
    });
  /*
  projectsDB.forEach(constructRecommendations)
    .then(writeProjectsFile);
    */

  function constructRecommendations(projectName, followers) {
    console.log('Processing', projectName);
    starsDB.getAllKeyValues(followers)
      .then(function (usersDB) {
        console.log('Loaded projects starred by followers of ' + projectName);
        var related = findRelated(followers, usersDB);
        saveRecommendation(projectName, related);
        projects.push(projectName);
      });
  }

  function writeProjectsFile() {
    var projectsFile ='./projects/projects.json';
    console.log('Saving projects file to', projectsFile);
    fs.writeFileSync(projectsFile, JSON.stringify(projects));
  }<commit_msg>Reverted one project<commit_after>/**
 * Constructs GitHub recommendation database. Based on followers of a project
 * attemtps to find related proejcts. This program saves results into `out` folder
 *
 * Usage:
 *   node  constructRecommendations.js ./db/followers ./db/stars
 *
 * Where:
 *   - followers: leveldb database name with indexed followers (produced by followersIndexer)
 *   - stars: leveldb database name with indexed stars (produced by starsIndexer)
 */
var fs = require('fs');
var saveRecommendation = require('./lib/saveRecommendation');
var findRelated = require('./lib/findRelated');

if (!checkInput()) {
  printHelp();
  return -1;
}

fs.mkdirSync('./out');
fs.mkdirSync('./projects');

// we will iterate over each project:
var projectsDB = openDB(process.argv[2]);
var starsDB = openDB(process.argv[3]);
processProjects();

function processProjects() {
  var projects = [];
  projectsDB.forEach(constructRecommendations)
    .then(writeProjectsFile);

  function constructRecommendations(projectName, followers) {
    console.log('Processing', projectName);
    starsDB.getAllKeyValues(followers)
      .then(function (usersDB) {
        console.log('Loaded projects starred by followers of ' + projectName);
        var related = findRelated(followers, usersDB);
        saveRecommendation(projectName, related);
        projects.push(projectName);
      });
  }

  function writeProjectsFile() {
    var projectsFile ='./projects/projects.json';
    console.log('Saving projects file to', projectsFile);
    fs.writeFileSync(projectsFile, JSON.stringify(projects));
  }
{'fraction_non_alphanumeric': 0.12556053811659193, 'fraction_numerical': 0.002374043787918755, 'mean_word_length': 3.9439374185136895, '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': '785999', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1063, 'n_words': 271}