Commit 42871df2 authored by delanoe's avatar delanoe

[GRAPH explorer] Parameters checked (and mini tutorial to user for each case).

parent a8b083b9
......@@ -299,8 +299,9 @@ RULE_TINA = "^((VBD,|VBG,|VBN,|CD.?,|JJ.?,|\?,){0,2}?(N.?.?,|\?,)+?(CD.,)??)\
# Graph constraints to compute the graph:
# Modes: live graph generation, graph asynchronously computed or errors detected
# here are the maximum size of corpus and maplist required to compute the graph
graph_constraints = {'corpus' : 400
,'mapList': 50
graph_constraints = {'corpusMax' : 400
,'corpusMin' : 10
,'mapList' : 50
}
......@@ -58,7 +58,7 @@ def get_graph( request=None , corpus=None
if mapList_size.count() < graph_constraints['mapList']:
# Do not compute the graph if mapList is not big enough
return {'nodes':[], 'links':[]}
return {'nodes':[], 'links':[0,0,0]}
# case of corpus not big enough
......@@ -103,7 +103,7 @@ def get_graph( request=None , corpus=None
# Finally test if the size of the corpora is big enough
# --------------------------------
if corpus_size_query.count() > graph_constraints['corpus']:
if corpus_size_query.count() > graph_constraints['corpusMax']:
# Then compute cooc asynchronously with celery
scheduled(countCooccurrences)( corpus_id=corpus.id
#, field1="ngrams", field2="ngrams"
......@@ -115,7 +115,11 @@ def get_graph( request=None , corpus=None
)
# Dic hack to inform user that graph is computed asynchronously
# (Impossible graph: no nodes with one link)
return {'nodes':[], 'links':[1]}
return {'nodes':[], 'links':[0]}
elif corpus_size_query.count() <= graph_constraints['corpusMin']:
# Do not compute the graph if corpus is not big enough
return {'nodes':[], 'links':[0,0]}
else:
# If graph_constraints are ok then compute the graph in live
......
......@@ -6,6 +6,7 @@ from graph.graph import get_graph
from gargantext.util.http import APIView, APIException\
, JsonHttpResponse, requires_auth
from gargantext.constants import graph_constraints
from traceback import format_tb
def compress_graph(graphdata):
......@@ -150,6 +151,33 @@ class Graph(APIView):
status=200
)
# --------------------------------------------
elif len(data['nodes']) == 0 and len(data['links']) == 2 :
# async data case
return JsonHttpResponse({
'msg': '''Your corpus is too small.
Add more documents (more than %d documents)
in order to get a graph.
You can manage your corpus here:
http://%sgargantext.org/projects/%d/
''' % (graph_constraints['corpusMin'], "dev.", corpus.parent_id),
}, status=400)
elif len(data['nodes']) == 0 and len(data['links']) == 3 :
# async data case
return JsonHttpResponse({
'msg': '''Your map list is too small.
Add some terms (more than %d terms)
in order to get a graph.
You can manage your map terms here:
http://%sgargantext.org/projects/%d/corpora/%d/terms
''' % (graph_constraints['mapList'], "dev.", corpus.parent_id, corpus.id),
}, status=400)
elif len(data['nodes']) == 0 and len(data['links']) == 1 :
# async data case
return JsonHttpResponse({
......@@ -164,7 +192,8 @@ class Graph(APIView):
return JsonHttpResponse({
'msg': '''Empty graph warning
No cooccurences found in this corpus for the words of this maplist
(maybe add more terms to the maplist?)''',
(maybe add more terms to the maplist or increase the size of your
corpus ?)''',
}, status=400)
else:
......
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