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
f9c19e0c
Commit
f9c19e0c
authored
Jul 26, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] REST adding option to save graph only.
parent
363097f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
graph.py
graph/graph.py
+13
-0
rest.py
graph/rest.py
+17
-1
No files found.
graph/graph.py
View file @
f9c19e0c
...
...
@@ -23,6 +23,7 @@ def get_graph( request=None , corpus=None
,
distance
=
'conditional'
,
isMonopartite
=
True
# By default, we compute terms/terms graph
,
bridgeness
=
5
,
saveOnly
=
None
#, size=1000
):
'''
...
...
@@ -113,6 +114,18 @@ def get_graph( request=None , corpus=None
# Finally test if the size of the corpora is big enough
# --------------------------------
corpus_size
=
corpus_size_query
.
count
()
if
saveOnly
is
not
None
and
saveOnly
==
"True"
:
scheduled
(
countCooccurrences
)(
corpus_id
=
corpus
.
id
#, field1="ngrams", field2="ngrams"
,
start
=
start
,
end
=
end
,
mapList_id
=
mapList_id
,
groupList_id
=
groupList_id
,
isMonopartite
=
True
,
threshold
=
threshold
,
save_on_db
=
True
#, limit=size
)
return
{
"state"
:
"saveOnly"
}
if
corpus_size
>
graph_constraints
[
'corpusMax'
]:
# Then compute cooc asynchronously with celery
scheduled
(
countCooccurrences
)(
corpus_id
=
corpus
.
id
...
...
graph/rest.py
View file @
f9c19e0c
...
...
@@ -67,6 +67,7 @@ class Graph(APIView):
# Get all the parameters in the URL
cooc_id
=
request
.
GET
.
get
(
'cooc_id'
,
None
)
saveOnly
=
request
.
GET
.
get
(
'saveOnly'
,
None
)
field1
=
str
(
request
.
GET
.
get
(
'field1'
,
'ngrams'
))
field2
=
str
(
request
.
GET
.
get
(
'field2'
,
'ngrams'
))
...
...
@@ -131,6 +132,7 @@ class Graph(APIView):
,
mapList_id
=
mapList_id
,
groupList_id
=
groupList_id
,
start
=
start
,
end
=
end
,
threshold
=
threshold
,
distance
=
distance
,
saveOnly
=
saveOnly
)
else
:
data
=
get_graph
(
corpus
=
corpus
,
cooc_id
=
cooc_id
...
...
@@ -139,6 +141,7 @@ class Graph(APIView):
,
threshold
=
threshold
,
distance
=
distance
,
bridgeness
=
bridgeness
,
saveOnly
=
saveOnly
)
...
...
@@ -158,7 +161,17 @@ class Graph(APIView):
else
:
# All other cases (more probable are higher in the if list)
if
data
[
"state"
]
==
"corpusMin"
:
if
data
[
"state"
]
==
"saveOnly"
:
# async data case
return
JsonHttpResponse
({
'msg'
:
'''Your graph is saved:
http://
%
sgargantext.org/projects/
%
d/corpora/
%
d/myGraphs
'''
%
(
"dev."
,
corpus
.
parent_id
,
corpus
.
id
),
},
status
=
400
)
elif
data
[
"state"
]
==
"corpusMin"
:
# async data case
return
JsonHttpResponse
({
'msg'
:
'''Problem: your corpus is too small (only
%
d documents).
...
...
@@ -208,6 +221,9 @@ class Graph(APIView):
http://
%
sgargantext.org/projects/
%
d/corpora/
%
d/myGraphs
'''
%
(
data
[
"length"
],
"dev."
,
corpus
.
parent_id
,
corpus
.
id
),
},
status
=
400
)
else
:
return
JsonHttpResponse
({
'msg'
:
'''Programming error.'''
,
...
...
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