Commit ab0aa5ba authored by delanoe's avatar delanoe

[FIX] merge conflicts.

parents 53f4d9b9 6d6ac234
......@@ -74,6 +74,7 @@ def compute_coocs( corpus,
"""
# - TODO add grouped element's values in grouping 'chief ngram'
# - TODO cvalue_id: allow a metric as additional input filter
# - TODO n_min, n_max : filter on Ngram.n (aka length of ngram)
# - TODO weighted: if False normal cooc to be saved as result
......@@ -202,9 +203,9 @@ def compute_coocs( corpus,
matrix = WeightedMatrix(coocs_query.all())
# fyi
# shape_0 = len({pair[0] for pair in matrix.items})
# shape_1 = len({pair[1] for pair in matrix.items})
# print("COOCS: NEW matrix shape [%ix%i]" % (shape_0, shape_1))
shape_0 = len({pair[0] for pair in matrix.items})
shape_1 = len({pair[1] for pair in matrix.items})
print("COOCS: NEW matrix shape [%ix%i]" % (shape_0, shape_1))
# 5) SAVE
# --------
......
......@@ -64,6 +64,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
for ngram in ngramsextractor.extract(value):
tokens = tuple(token[0] for token in ngram)
terms = normalize_terms(' '.join(tokens))
if len(terms) > 1:
nodes_ngrams_count[(document.id, terms)] += 1
ngrams_data.add((terms[:255], len(tokens), ))
# integrate ngrams and nodes-ngrams
......
......@@ -24,5 +24,4 @@ urlpatterns = [
# - an optional grouplist)
url(r'^ngramlists/family$', ngramlists.ListFamily.as_view()),
]
......@@ -11,7 +11,7 @@ def ngramtable(request, project_id, corpus_id):
=> maplist and mainlist terms in a table
with groupings as '+' nodes
=> uses API GET batch of lists
=> uses API PUT/DEL for list modifications (TODO)
=> uses API PUT/DEL for list modifications
=> uses frontend AJAX through Ngrams_dyna_charts_and_table.js
# TODO refactor Ngrams_dyna_charts_and_table.js
'''
......@@ -21,7 +21,7 @@ def ngramtable(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
project = cache.Node[project_id]
# rendered page : journals.html
# rendered page : terms.html
return render(
template_name = 'pages/corpora/terms.html',
request = request,
......
......@@ -19,12 +19,15 @@ def explorer(request, project_id, corpus_id):
# we pass our corpus
corpus = cache.Node[corpus_id]
# get the maplist_id for modifications
maplist_id = corpus.children(typename="MAPLIST").first().id
# and the project just for project.id in corpusBannerTop
project = cache.Node[project_id]
graphurl = "projects/" + str(project_id) + "/corpora/" + str(corpus_id) + "/node_link.json"
# rendered page : journals.html
# rendered page : explorer.html
return render(
template_name = 'graphExplorer/explorer.html',
request = request,
......@@ -35,9 +38,8 @@ def explorer(request, project_id, corpus_id):
'date' : datetime.now(),
'project' : project,
'corpus' : corpus,
#'list_id' : maplist.id,\
'graphfile' : graphurl,\
'maplist_id': maplist_id,
'graphfile' : graphurl,
'view' : 'graph'
},
)
......@@ -23,15 +23,11 @@ function modify_ngrams( classname ) {
console.clear()
var corpus_id = getIDFromURL( "corpora" ) // not used
var list_id = $("#list_id").val()
var list_id = $("#maplist_id").val()
var selected_ngrams = $.extend({}, selections)
console.log( selected_ngrams )
if(classname=="delete") {
CRUD( corpus_id , "/keep" , [] , selected_ngrams , "DELETE" , function(result) {
console.log(" Delete from Map-list: "+result)
CRUD( list_id , "" , Object.keys(selected_ngrams).map(Number) , [] , "DELETE", function(result) {
console.log(" Add to Stop-list "+result)
CRUD(list_id, Object.keys(selected_ngrams), "DELETE", function(success) {
cancelSelection(false)
for(var i in selected_ngrams) {
partialGraph.dropNode( i )
......@@ -40,8 +36,7 @@ function modify_ngrams( classname ) {
}
partialGraph.refresh()
$("#lensButton").click()
});
});
}) ;
}
// if(classname=="group") {
......@@ -53,33 +48,43 @@ function modify_ngrams( classname ) {
// }
}
function CRUD( parent_id , action , nodes , args , http_method , callback) {
var the_url = window.location.origin+"/api/node/"+parent_id+"/ngrams"+action+"/"+nodes.join("+");
the_url = the_url.replace(/\/$/, ""); //remove trailing slash
console.log( the_url )
console.log( args )
if(nodes.length>0 || Object.keys(args).length>0) {
function CRUD( list_id , ngram_ids , http_method , callback) {
// ngramlists/change?node_id=42&ngram_ids=1,2
var the_url = window.location.origin+"/api/ngramlists/change?list="+list_id+"&ngrams="+ngram_ids.join(",");
// debug
// console.log("starting CRUD AJAX => URL: " + the_url + " (" + http_method + ")")
if(ngram_ids.length>0) {
$.ajax({
method: http_method,
url: the_url,
data: args,
// data: args, // currently all data explicitly in the url (like a GET)
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data){
console.log("-- CRUD ----------")
console.log(http_method + " ok!!")
console.log(nodes)
console.log(data)
callback("Success");
console.log(JSON.stringify(data))
console.log("------------------")
callback(true);
},
error: function(result) {
console.log("-- CRUD ----------")
console.log("Data not found in #Save_All");
console.log(result)
callback("Fail");
console.log("------------------")
callback(false);
}
});
} else callback(false);
}
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// Execution: ChangeGraphAppearanceByAtt( true )
......
......@@ -136,7 +136,7 @@
<li>
<a>
<div id="graphid" style="visibility: hidden;">{{graphfile}}</div>
<input type="hidden" id="list_id" value="{{ list_id }}"></input>
<input type="hidden" id="maplist_id" value="{{ maplist_id }}"></input>
<div id="jquerytemplatenb" style="visibility: hidden;">{{user.id}}</div>
</a>
</li>
......
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