-
Notifications
You must be signed in to change notification settings - Fork 20
/
dump.js
28 lines (25 loc) · 918 Bytes
/
dump.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* A data dumper for https://anvaka.github.io/npmrank/online/
* Dumps keywords and page rank into separate files.
*/
var fs = require('fs');
var outFileName = 'online/npmrank.json';
console.log('Collecting tags...');
var collectTags = require('./lib/collectTags.js');
collectTags('./data/graph.in', function(result) {
var tags = result.tags;
console.log('Collected ' + result.totalTags + '; Unique tags: ' + result.uniqueTags);
console.log('Computing page rank...');
var computePageRank = require('./lib/computePageRank.js');
var rank = computePageRank('./data/dependenciesGraph.out.graph');
var keys = Object.keys(rank);
for (var i = 0; i < keys.length; ++i) {
rank[keys[i]] = (rank[keys[i]] * 100).toFixed(7);
}
console.log('Done');
console.log('Saving pagerank and tags to ' + outFileName);
fs.writeFileSync(outFileName, JSON.stringify({
tags: tags,
rank: rank
}));
});