Commit 73289d0b authored by PkSM3's avatar PkSM3

[UPDATE] occs par default

parent b81f45fd
......@@ -6,7 +6,7 @@ from ngram.stop import compute_stop
from ngram.group import compute_groups
from gargantext_web.db import get_or_create_node
from ngram.mapList import compute_mapList
# from ngram.occurrences import compute_occs
from ngram.occurrences import compute_occs
from gargantext_web.db import session , Node , NodeNgram
from admin.utils import WorkflowTracking
......
from ..Taggers import TurboTagger #NltkTagger #,
from ..Taggers import NltkTagger #,
import nltk
......@@ -21,7 +21,7 @@ class NgramsExtractor:
self.stop()
def start(self):
self.tagger = TurboTagger()
self.tagger = NltkTagger()
def stop(self):
pass
......
from .NgramsExtractor import NgramsExtractor
from ..Taggers import TurboTagger #NltkTagger
from ..Taggers import NltkTagger #TurboTagger
class TurboNgramsExtractor(NgramsExtractor):
def start(self):
self.tagger = TurboTagger()
self.tagger = NltkTagger()
......@@ -91,17 +91,30 @@ class List(APIView):
"id": node.id,
"name": node.terms,
"scores": {
"tfidf": 0
"tfidf": 0,
"occs":0
}
}
# occ_list = get_or_create_node(nodetype='Occurrences', corpus_id=parent_id).id
# print( occ_list )
tfidf_list = get_or_create_node(nodetype='Tfidf (global)', corpus_id=parent_id).id
ngram_tfidf = session.query(NodeNodeNgram.ngram_id,NodeNodeNgram.score).filter( NodeNodeNgram.nodex_id==tfidf_list , NodeNodeNgram.ngram_id.in_( list(ngram_ids.keys()) )).all()
for n in ngram_tfidf:
try:
tfidf_list = get_or_create_node(nodetype='Tfidf (global)', corpus_id=parent_id).id
ngram_tfidf = session.query(NodeNodeNgram.ngram_id,NodeNodeNgram.score).filter( NodeNodeNgram.nodex_id==tfidf_list , NodeNodeNgram.ngram_id.in_( list(ngram_ids.keys()) )).all()
for n in ngram_tfidf:
if n.ngram_id in ngram_ids:
ngram_ids[n.ngram_id]["scores"]["tfidf"] += n.score
except:
pass
try:
occ_list = get_or_create_node(nodetype='Occurrences', corpus_id=parent_id).id
ngram_occs = session.query(NodeNodeNgram.ngram_id,NodeNodeNgram.score).filter( NodeNodeNgram.nodex_id==occ_list , NodeNodeNgram.ngram_id.in_( list(ngram_ids.keys()) )).all()
for n in ngram_occs:
if n.ngram_id in ngram_ids:
ngram_ids[n.ngram_id]["scores"]["tfidf"] += n.score
ngram_ids[n.ngram_id]["scores"]["occs"] += round(n.score)
except:
pass
end_ = time.time()
......
......@@ -97,14 +97,16 @@ var LineChart = dc.lineChart("#monthly-move-chart");
var volumeChart = dc.barChart("#monthly-volume-chart");
// Just for Garg
// Get all projects and corpuses of the user
function GetUserPortfolio() {
//http://localhost:8000/api/corpusintersection/1a50317a50145
var project_id = getIDFromURL("project")
var corpus_id = getIDFromURL("corpus")
if( Object.keys( corpusesList ).length > 0 )
return true;
if( Object.keys( corpusesList ).length > 0 ) {
$('#corpuses').modal('show');
return true;
}
var query_url = window.location.origin+'/api/userportfolio/project/'+project_id+'/corpuses'
$.ajax({
......@@ -158,8 +160,6 @@ function GetUserPortfolio() {
});
$('#corpuses').modal('show');
},
error: function(){
pr('Page Not found: TestFunction()');
......@@ -167,6 +167,7 @@ function GetUserPortfolio() {
});
}
//Getting a corpusB-list and intersecting it with current corpusA-miamlist.
function printCorpuses() {
console.log( "!!!!!!!! in printCorpuses() !!!!!!!! " )
pr(corpusesList)
......@@ -585,6 +586,7 @@ function SaveGlobalChanges_Form( nodes2del) {
$("#pre_savechanges").modal("show")
}
// Save changes to all corpusA-lists
function SaveLocalChanges() {
console.clear()
......@@ -713,7 +715,7 @@ $("#Save_All").click(function(){
// }
});
// For lists, all http-requests
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
......@@ -1060,6 +1062,7 @@ function getIDFromURL( item ) {
return pageurl[cid+1];
}
// For lists, only GET requests
function GET_( url , callback ) {
$.ajax({
......@@ -1107,18 +1110,23 @@ var url = [
GET_( url[0] , function(result) {
// = = = = MIAM = = = = //
if(result!=false) {
NGrams["main"] = {
"ngrams": [],
"scores": {
"initial":"tfidf",
"nb_docs":result.length,
"orig_nb_ngrams":1,
"nb_ngrams":result.length,
}
}
NGrams["main"] = {
"ngrams": [],
"scores": {
"initial":"occs",
"nb_docs":result.length,
"orig_nb_ngrams":1,
"nb_ngrams":result.length,
}
}
for(var i in result)
var occs_sum = 0
for(var i in result) {
NGrams["main"].ngrams.push(result[i])
occs_sum += result[i].scores.occs
}
if(occs_sum==0)
NGrams["main"]["scores"]["initial"] = "tfidf";
}
// = = = = /MIAM = = = = //
......
......@@ -49,7 +49,7 @@
<a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add documents</a></p>
{% endif %}
{% if nb_groups != None and nb_groups > 0 %}
<a style="visibility: hidden;" id="share_button" class="btn btn-primary btn-lg" role="button" >Share!!!</a></p>
<a id="share_button" class="btn btn-primary btn-lg" role="button" >Share!!!</a></p>
{% endif %}
</div>
</div>
......
......@@ -252,7 +252,7 @@ def graph_share(request, generic=100, specific=100):
def node_link_share(request):
data = {"hola":"mundo"}
data = { "request" : "error" }
if request.method== 'GET' and "token" in request.GET:
import json
le_token = json.loads(request.GET["token"])[0]
......
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