Commit be06df46 authored by delanoe's avatar delanoe

[FEAT] Graph, with mapList only.

parent 2b17dfca
......@@ -9,22 +9,20 @@ from sqlalchemy import desc, asc, or_, and_
#import inspect
import datetime
def do_cooc(corpus=None
, field1='ngrams', field2='ngrams'
, mainList_id=None, groupList_id=None
, coocNode_id=None
, start=None, end=None
, n_min=1, n_max=None , limit=1000
, isMonopartite=True
, threshold = 3
, reset=True):
def do_cooc( corpus=None
, field1='ngrams' , field2='ngrams'
, start=None , end=None
, mapList_id=None , groupList_id=None
, n_min=1, n_max=None , limit=1000
, coocNode_id=None , reset=True
, isMonopartite=True , threshold = 3):
'''
Compute the cooccurence matrix and save it, returning NodeNgramNgram.node_id
For the moment list of paramters are not supported because, lists need to
be merged before.
corpus :: Corpus
mainList_id :: Int
mapList_id :: Int
groupList_id :: Int
For the moment, start and end are simple, only year is implemented yet
......@@ -191,9 +189,9 @@ def do_cooc(corpus=None
cooc_query = cooc_query.order_by(desc('cooc_score'))
matrix = WeightedMatrix(cooc_query)
mainList = UnweightedList( mainList_id )
mapList = UnweightedList( mapList_id )
group_list = Translations ( groupList_id )
cooc = matrix & (mainList * group_list)
cooc = matrix & (mapList * group_list)
cooc.save(coocNode_id)
return(coocNode_id)
......@@ -29,7 +29,7 @@ def get_cooc( request=None, corpus=None
, distance='conditional'
, size=1000
, bridgeness=5
, mainList_id = None , groupList_id = None
, mapList_id = None , groupList_id = None
):
'''
get_ccoc : to compute the graph.
......@@ -38,15 +38,15 @@ def get_cooc( request=None, corpus=None
data = {}
if mainList_id == None :
mainList_id = ( session.query ( Node.id )
.filter( Node.typename == "MAINLIST"
if mapList_id == None :
mapList_id = ( session.query ( Node.id )
.filter( Node.typename == "MAPLIST"
, Node.parent_id == corpus.id
)
.first()
)
if mainList_id == None :
raise ValueError("MAINLIST node needed for cooccurrences")
if mapList_id == None :
raise ValueError("MAPLIST node needed for cooccurrences")
if groupList_id == None :
......@@ -79,7 +79,7 @@ def get_cooc( request=None, corpus=None
cooc_id = do_cooc( corpus=corpus
#, field1="ngrams", field2="ngrams"
, mainList_id=int(mainList_id[0]), groupList_id=int(groupList_id[0])
, mapList_id=int(mapList_id[0]), groupList_id=int(groupList_id[0])
#, isMonopartite=True
, start=start , end =end
, threshold = threshold #, limit=size
......
from gargantext.util.http import APIView, APIException, JsonHttpResponse, requires_auth
#from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from gargantext.util.db import session
from gargantext.util.db import session
from gargantext.models.nodes import Node
from graphExplorer.functions import get_cooc
from gargantext.util.http import APIView, APIException\
, JsonHttpResponse, requires_auth
# TODO check authentication
......
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