Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
42871df2
Commit
42871df2
authored
Jul 18, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH explorer] Parameters checked (and mini tutorial to user for each case).
parent
a8b083b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
6 deletions
+40
-6
constants.py
gargantext/constants.py
+3
-2
graph.py
graph/graph.py
+7
-3
rest.py
graph/rest.py
+30
-1
No files found.
gargantext/constants.py
View file @
42871df2
...
@@ -299,8 +299,9 @@ RULE_TINA = "^((VBD,|VBG,|VBN,|CD.?,|JJ.?,|\?,){0,2}?(N.?.?,|\?,)+?(CD.,)??)\
...
@@ -299,8 +299,9 @@ RULE_TINA = "^((VBD,|VBG,|VBN,|CD.?,|JJ.?,|\?,){0,2}?(N.?.?,|\?,)+?(CD.,)??)\
# Graph constraints to compute the graph:
# Graph constraints to compute the graph:
# Modes: live graph generation, graph asynchronously computed or errors detected
# Modes: live graph generation, graph asynchronously computed or errors detected
# here are the maximum size of corpus and maplist required to compute the graph
# here are the maximum size of corpus and maplist required to compute the graph
graph_constraints
=
{
'corpus'
:
400
graph_constraints
=
{
'corpusMax'
:
400
,
'mapList'
:
50
,
'corpusMin'
:
10
,
'mapList'
:
50
}
}
graph/graph.py
View file @
42871df2
...
@@ -58,7 +58,7 @@ def get_graph( request=None , corpus=None
...
@@ -58,7 +58,7 @@ def get_graph( request=None , corpus=None
if
mapList_size
.
count
()
<
graph_constraints
[
'mapList'
]:
if
mapList_size
.
count
()
<
graph_constraints
[
'mapList'
]:
# Do not compute the graph if mapList is not big enough
# 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
# case of corpus not big enough
...
@@ -103,7 +103,7 @@ def get_graph( request=None , corpus=None
...
@@ -103,7 +103,7 @@ def get_graph( request=None , corpus=None
# Finally test if the size of the corpora is big enough
# 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
[
'corpus
Max
'
]:
# Then compute cooc asynchronously with celery
# Then compute cooc asynchronously with celery
scheduled
(
countCooccurrences
)(
corpus_id
=
corpus
.
id
scheduled
(
countCooccurrences
)(
corpus_id
=
corpus
.
id
#, field1="ngrams", field2="ngrams"
#, field1="ngrams", field2="ngrams"
...
@@ -115,7 +115,11 @@ def get_graph( request=None , corpus=None
...
@@ -115,7 +115,11 @@ def get_graph( request=None , corpus=None
)
)
# Dic hack to inform user that graph is computed asynchronously
# Dic hack to inform user that graph is computed asynchronously
# (Impossible graph: no nodes with one link)
# (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
:
else
:
# If graph_constraints are ok then compute the graph in live
# If graph_constraints are ok then compute the graph in live
...
...
graph/rest.py
View file @
42871df2
...
@@ -6,6 +6,7 @@ from graph.graph import get_graph
...
@@ -6,6 +6,7 @@ from graph.graph import get_graph
from
gargantext.util.http
import
APIView
,
APIException
\
from
gargantext.util.http
import
APIView
,
APIException
\
,
JsonHttpResponse
,
requires_auth
,
JsonHttpResponse
,
requires_auth
from
gargantext.constants
import
graph_constraints
from
traceback
import
format_tb
from
traceback
import
format_tb
def
compress_graph
(
graphdata
):
def
compress_graph
(
graphdata
):
...
@@ -150,6 +151,33 @@ class Graph(APIView):
...
@@ -150,6 +151,33 @@ class Graph(APIView):
status
=
200
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
:
elif
len
(
data
[
'nodes'
])
==
0
and
len
(
data
[
'links'
])
==
1
:
# async data case
# async data case
return
JsonHttpResponse
({
return
JsonHttpResponse
({
...
@@ -164,7 +192,8 @@ class Graph(APIView):
...
@@ -164,7 +192,8 @@ class Graph(APIView):
return
JsonHttpResponse
({
return
JsonHttpResponse
({
'msg'
:
'''Empty graph warning
'msg'
:
'''Empty graph warning
No cooccurences found in this corpus for the words of this maplist
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
)
},
status
=
400
)
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment