Commit fa91f690 authored by Romain Loth's avatar Romain Loth

[FIX] ngram groups: shorter json and better comments in terms table view

parent 5d3b6644
......@@ -399,12 +399,20 @@ class Group(APIView):
max_deg = -1
mainNode = -1
mainNode_sinonims = []
if len(clique) > 1:
for node in clique:
# just a lookup hash with *both*
# the mainNode and the subnodes
groups["nodes"][node] = False
# choosing mainNode
node_outdeg = DG.out_degree(node)
if node_outdeg>max_deg:
max_deg = node_outdeg
mainNode = node
# the links themselves main => [subs]
for node in clique:
if mainNode!=node:
mainNode_sinonims.append( node )
......
......@@ -494,18 +494,18 @@ function add2group ( elem ) {
function clickngram_action ( elem ) {
// local id
var elem_id = $( elem ).data("stuff") ;
console.log("click: state before: "+ AjaxRecords[elem_id].state) ;
// console.log("click: state before: "+ AjaxRecords[elem_id].state) ;
// cycle the statuses (omitting status 3 = group)
AjaxRecords[elem_id].state = (AjaxRecords[elem_id].state==(System[0]["states"].length-2))?0:(AjaxRecords[elem_id].state+1);
// State <=> term color <=> checked colums
console.log("\n\nRECORD visible on click --- " + JSON.stringify(AjaxRecords[elem_id])) ;
// console.log("\n\nRECORD visible on click --- " + JSON.stringify(AjaxRecords[elem_id])) ;
var ngramId = AjaxRecords[elem_id].id ;
console.log("click: state after: "+ AjaxRecords[elem_id].state) ;
// console.log("click: state after: "+ AjaxRecords[elem_id].state) ;
MyTable.data('dynatable').dom.update();
}
......@@ -546,13 +546,13 @@ function transformContent(rec_id) {
}
}
// uncomment if column tableId
// uncomment if column tableId (here and in Main_test)
// result['rec_id'] = rec_id ;
// uncomment if column ngramId
// uncomment if column ngramId (here and in Main_test)
// result["ngramId"] = ngram_info["id"] ;
// uncomment if column state
// uncomment if column state (here and in Main_test)
// result["state"] = AjaxRecords[rec_id].state
// -------------------------------------------
......@@ -700,11 +700,11 @@ function SelectAll(boxType, boxElem) {
// did we already buffer original states ?
var columnBufferExists = null ;
console.log("-------------INCOMING----------------")
console.log(boxElem.id)
console.log("check:" + $(boxElem).prop("checked"))
console.log("indet:" + $(boxElem).prop('indeterminate'))
console.log("data:" + previousColumnSelection)
// console.log("-------------INCOMING----------------")
// console.log(boxElem.id)
// console.log("check:" + $(boxElem).prop("checked"))
// console.log("indet:" + $(boxElem).prop('indeterminate'))
// console.log("data:" + previousColumnSelection)
// toggle column ALL => NONE => SOME => again
......@@ -779,7 +779,7 @@ function SelectAll(boxType, boxElem) {
// and anyway the other box can't stay checked
$('#'+otherBoxId).prop('checked', false);
console.log("data became:" + newColumnSelection)
// console.log("data became:" + newColumnSelection)
$("tbody tr").each(function (i, row) {
var rec_id = $(row).data('stuff'); // ids for old state system
......@@ -843,8 +843,8 @@ function SaveLocalChanges() {
}
// [ = = = = For deleting subforms = = = = ]
// see TODO Prevent empty Ngram["group"]["links"]
for(var i in NGrams["group"].links) {
// i is ngram_id of a group mainNode
if(FlagsBuffer["delete"][i]) {
for(var j in NGrams["group"].links[i] ) {
FlagsBuffer["delete"][NGrams["group"].links[i][j]] = true
......@@ -1019,13 +1019,13 @@ function Main_test( data , initial , search_filter) {
// Any <th> defined here will end up in the 'columns' arg of ulWriter
// ------------------------------------------------------------------
// uncomment for column tableId
// uncomment for column tableId (here and in transformContent)
// div_table += "\t"+"\t"+'<th data-dynatable-column="rec_id" style="background-color:grey">local id</th>'+"\n";
// uncomment for column ngramId
// uncomment for column ngramId (here and in transformContent - l553)
// div_table += "\t"+"\t"+'<th data-dynatable-column="ngramId" style="background-color:grey">ngramId</th>'+"\n";
// uncomment for column stateId
// uncomment for column stateId (here and in transformContent)
// div_table += "\t"+"\t"+'<th data-dynatable-column="state" style="background-color:grey">State</th>'+"\n" ;
div_table += "\t"+"\t"+'<th data-dynatable-column="name">Terms</th>'+"\n";
......@@ -1202,7 +1202,7 @@ function Main_test( data , initial , search_filter) {
.renderlet(function (chart) {
chart.select("g.y").style("display", "none");
LineChart.filter(chart.filter());
console.log("lalaal moveChart.focus(chartfilt);")
// console.log("lalaal moveChart.focus(chartfilt);")
})
.on("filtered", function (chart) {
dc.events.trigger(function () {
......@@ -1429,10 +1429,6 @@ GET_( url[0] , function(result) {
GET_( url[2] , function(result) {
// = = = = GROUP = = = = //
if(result!=false) {
// TODO Prevent empty NGrams["group"]["links"]
// "group":{"links":{"119":[],"449":[],"674":[]...}}
// (then correct for i in links with if 'i' in links)
NGrams["group"] = result
}
// = = = = /GROUP = = = = //
......@@ -1453,43 +1449,59 @@ GET_( url[0] , function(result) {
function AfterAjax() {
// -------------------------------------------------------------------
// dbg: Ngrams structure is too large & redundant
// dbg: Ngrams structure is too large
// 1- Prevent empty groups (see TODO)
// 2- Ngrams list would be shorter in binary format than JSON
// 3- If sorted, top Ngrams could be loaded partly for 1st page show
// 4- We could keep less ngrams altogether at indexation upstream
// 1- Ngrams list would be shorter in binary format than JSON
// 2- If sorted, top Ngrams could be loaded partly for 1st page show
// 3- We could keep less ngrams altogether at indexation upstream
// console.log(JSON.stringify(NGrams))
// -------------------------------------------------------------------
// // Deleting subforms from the ngrams-table, clean start baby!
// Deleting subforms from the ngrams-table, clean start baby!
if( Object.keys(NGrams["group"].links).length>0 ) {
var _forms = { "main":{} , "sub":{} }
// subforms inventory
for(var i in NGrams["group"].links) {
_forms["main"][i] = true
for(var j in NGrams["group"].links[i]) {
// for each subform {subform_ngramid : true}
_forms["sub"][ NGrams["group"].links[i][j] ] = true
}
}
// console.log('_forms["sub"]')
// console.log( _forms["sub"] )
// ngrams_data_ will update NGrams.main (with subforms removed)
var ngrams_data_ = []
for(var i in NGrams["main"].ngrams) {
// FIXME is it necessary to keep NGrams["group"]["nodes"]
// when afterwards only using NGrams["group"]["links"]
// ex: "nodes":{"119":false,"449":false,"674":false,...}
if(_forms["sub"][NGrams["main"].ngrams[i].id]) {
NGrams["group"]["nodes"][NGrams["main"].ngrams[i].id] = NGrams["main"].ngrams[i]
} else {
// if( _forms["main"][ NGrams["main"].ngrams[i].id ] )
// NGrams["main"].ngrams[i].name = "*"+NGrams["main"].ngrams[i].name
var ngram_id = NGrams["main"].ngrams[i].id ;
// if ngram is subform of another
if(_forms["sub"][ngram_id]) {
// subform info storage into NGrams.group.nodes
// ---------------------------------------------
// (subform goes away from new list but info preserved)
// (useful if we want to see/revive subforms in future)
NGrams["group"]["nodes"][ngram_id] = NGrams["main"].ngrams[i]
}
// normal case
else {
// we keep the info untouched in the new list
ngrams_data_.push( NGrams["main"].ngrams[i] )
}
}
// the new list of ngrams replaces the old main
NGrams["main"].ngrams = ngrams_data_;
}
// console.log('NGrams["group"]["nodes"]')
// console.log( NGrams["group"]["nodes"] )
// initialize state of maplist items
if( Object.keys(NGrams["map"]).length>0 ) {
for(var i in NGrams["main"].ngrams) {
......@@ -1502,6 +1514,9 @@ function AfterAjax() {
}
}
// console.log('NGrams["main"]')
// console.log( NGrams["main"] )
// Building the Score-Selector //NGrams["scores"]
var FirstScore = NGrams["main"].scores.initial
var possible_scores = Object.keys( NGrams["main"].ngrams[0].scores );
......@@ -1512,10 +1527,10 @@ function AfterAjax() {
scores_div += "\t"+'<option value="'+possible_scores[i]+'">'+possible_scores[i]+'</option>'+"\n"
}
}
// Initializing the Charts and Table
console.log( NGrams["main"] )
var result = Main_test( NGrams["main"] , FirstScore , "filter_all")
console.log( result )
console.log( result ) // OK
// Listener for onchange Score-Selector
scores_div += "<select>"+"\n";
......
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