Commit a5da94eb authored by Romain Loth's avatar Romain Loth

parse: debug stats for gexf parser

parent c93c008f
// TODO REFA longterm refactoring: scanXX and dictifyXX is doing double work
// (for instance loop on full gexf in scanGexf then again in dictfyGexf)
// Level-01 // Level-01
ParseCustom = function ( format , data ) { ParseCustom = function ( format , data ) {
...@@ -35,7 +37,6 @@ ParseCustom = function ( format , data ) { ...@@ -35,7 +37,6 @@ ParseCustom = function ( format , data ) {
// Level-02 // Level-02
ParseCustom.prototype.scanFile = function() { ParseCustom.prototype.scanFile = function() {
switch (this.format) { switch (this.format) {
case "api.json": case "api.json":
console.log("scanFile: "+this.format) console.log("scanFile: "+this.format)
...@@ -61,7 +62,6 @@ ParseCustom.prototype.scanFile = function() { ...@@ -61,7 +62,6 @@ ParseCustom.prototype.scanFile = function() {
// Level-02 // Level-02
ParseCustom.prototype.makeDicts = function(categories) { ParseCustom.prototype.makeDicts = function(categories) {
switch (this.format) { switch (this.format) {
case "api.json": case "api.json":
console.log("makeDicts: "+this.format) console.log("makeDicts: "+this.format)
...@@ -88,6 +88,7 @@ ParseCustom.prototype.makeDicts = function(categories) { ...@@ -88,6 +88,7 @@ ParseCustom.prototype.makeDicts = function(categories) {
// Level-00 // Level-00
function scanGexf(gexf) { function scanGexf(gexf) {
console.log("ParseCustom : scanGexf")
var categoriesDict={}, categories=[]; var categoriesDict={}, categories=[];
nodesNodes = gexf.getElementsByTagName('nodes'); nodesNodes = gexf.getElementsByTagName('nodes');
for(i=0; i<nodesNodes.length; i++){ for(i=0; i<nodesNodes.length; i++){
...@@ -137,6 +138,8 @@ function scanGexf(gexf) { ...@@ -137,6 +138,8 @@ function scanGexf(gexf) {
// for {1,2}partite graphs // for {1,2}partite graphs
function dictfyGexf( gexf , categories ){ function dictfyGexf( gexf , categories ){
console.warn("ParseCustom gexf 2nd loop, main data extraction")
var catDict = {} var catDict = {}
var catCount = {} var catCount = {}
...@@ -197,6 +200,12 @@ function dictfyGexf( gexf , categories ){ ...@@ -197,6 +200,12 @@ function dictfyGexf( gexf , categories ){
maxNodeSize=0.001; maxNodeSize=0.001;
numberOfDocs=0; numberOfDocs=0;
numberOfNGrams=0; numberOfNGrams=0;
// debug: for local stats
let allSizes = []
let sumSizes = 0
let sizeStats = {'mean':null, 'median':null, 'max':0, 'min':1000000000}
for(i=0; i<nodesNodes.length; i++) { for(i=0; i<nodesNodes.length; i++) {
var nodesNode = nodesNodes[i]; // Each xml node 'nodes' (plural) var nodesNode = nodesNodes[i]; // Each xml node 'nodes' (plural)
var nodeNodes = nodesNode.getElementsByTagName('node'); // The list of xml nodes 'node' (no 's') var nodeNodes = nodesNode.getElementsByTagName('node'); // The list of xml nodes 'node' (no 's')
...@@ -219,6 +228,14 @@ function dictfyGexf( gexf , categories ){ ...@@ -219,6 +228,14 @@ function dictfyGexf( gexf , categories ){
if(sizeNodes.length>0){ if(sizeNodes.length>0){
sizeNode = sizeNodes[0]; sizeNode = sizeNodes[0];
size = parseFloat(sizeNode.getAttribute('value')); size = parseFloat(sizeNode.getAttribute('value'));
// debug: for stats ---------------------------
allSizes.push(size)
sumSizes += size
if (size < sizeStats.min) sizeStats.min = size
if (size > sizeStats.max) sizeStats.max = size
// --------------------------------------------
}// [ / get Size ] }// [ / get Size ]
// [ get Coordinates ] // [ get Coordinates ]
...@@ -232,7 +249,7 @@ function dictfyGexf( gexf , categories ){ ...@@ -232,7 +249,7 @@ function dictfyGexf( gexf , categories ){
y = parseFloat(positionNode.getAttribute('y')); y = parseFloat(positionNode.getAttribute('y'));
}// [ / get Coordinates ] }// [ / get Coordinates ]
// x = x*-1 // x = x*-1
y = y*-1 y = y*-1 // aka -y
// [ get Colour ] // [ get Colour ]
var colorNodes = nodeNode.getElementsByTagName('color'); var colorNodes = nodeNode.getElementsByTagName('color');
...@@ -293,6 +310,15 @@ function dictfyGexf( gexf , categories ){ ...@@ -293,6 +310,15 @@ function dictfyGexf( gexf , categories ){
} }
} }
// -------------- debug: for local stats ----------------
allSizes.sort();
let N = allSizes.length
sizeStats.median = allSizes[Math.round(N/2)]
sizeStats.mean = Math.round(sumSizes/N * 100)/100
console.log("parseCustom(gexf) sizeStats:", sizeStats)
// ------------- /debug: for local stats ----------------
var attention = false var attention = false
if( TW.Clusters.length == 0 ) { if( TW.Clusters.length == 0 ) {
for( var i in nodes ) { for( var i in nodes ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment