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
b6263a33
Commit
b6263a33
authored
Apr 27, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/romain-refactoring' into refactoring
parents
0362e268
d6ab7572
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
10 deletions
+105
-10
ngramlists.py
gargantext/views/api/ngramlists.py
+80
-1
urls.py
gargantext/views/api/urls.py
+4
-1
NGrams_dyna_chart_and_table.js
static/js/gargantext/NGrams_dyna_chart_and_table.js
+16
-4
terms.html
templates/pages/corpora/terms.html
+5
-4
No files found.
gargantext/views/api/ngramlists.py
View file @
b6263a33
...
...
@@ -297,6 +297,85 @@ class ListChange(APIView):
return
(
base_list
,
change_list
)
class
MapListGlance
(
APIView
):
"""
Fast infos about the maplist only
HOST/api/ngramlists/glance?corpus=2
HOST/api/ngramlists/glance?maplist=92
REST Parameters:
"maplist=92"
the maplist to retrieve
"corpus=ID"
alternatively, the corpus to which the maplist belongs
"""
def
get
(
self
,
request
):
parameters
=
get_parameters
(
request
)
maplist_id
=
None
scores_id
=
None
if
"corpus"
in
parameters
:
corpus_id
=
parameters
[
'corpus'
]
corpus
=
cache
.
Node
[
corpus_id
]
maplist_id
=
corpus
.
children
(
'MAPLIST'
)
.
first
()
.
id
# with a corpus_id, the explicit scoring pointer is optional
if
"scoring"
in
parameters
:
scores_id
=
parameters
[
'scoring'
]
else
:
scores_id
=
corpus
.
children
(
'OCCURRENCES'
)
.
first
()
.
id
elif
"maplist"
in
parameters
and
"scoring"
in
parameters
:
maplist_id
=
int
(
parameters
[
'mainlist'
])
scores_id
=
int
(
parameters
[
'scoring'
])
else
:
raise
ValidationException
(
"A 'corpus' id or 'maplist' id is required, and a 'scoring' for occurences counts"
)
ngraminfo
=
{}
# ngram details sorted per ngram id
listmembers
=
{
'maplist'
:[]}
# ngram ids sorted per list name
# infos for all ngrams from maplist
map_ngrams
=
_query_list
(
maplist_id
,
details
=
True
,
scoring_metric_id
=
scores_id
)
.
all
()
# ex: [(8805, 'mean age', 4.0),
# (1632, 'activity', 4.0),
# (8423, 'present', 2.0),
# (2928, 'objective', 2.0)]
# shortcut to useful function during loop
add_to_members
=
listmembers
[
'maplist'
]
.
append
for
ng
in
map_ngrams
:
ng_id
=
ng
[
0
]
ngraminfo
[
ng_id
]
=
ng
[
1
:]
# maplist ngrams will already be <=> ngraminfos
# but the client side expects a membership lookup
# as when there are multiple lists or some groupings
add_to_members
(
ng_id
)
return
JsonHttpResponse
({
'ngraminfos'
:
ngraminfo
,
'listmembers'
:
listmembers
,
'links'
:
{},
# no grouping links sent during glance (for speed)
'nodeids'
:
{
'mainlist'
:
None
,
'maplist'
:
maplist_id
,
'stoplist'
:
None
,
'groups'
:
None
,
'scores'
:
None
,
}
})
class
ListFamily
(
APIView
):
"""
Compact combination of *multiple* list info
...
...
@@ -320,7 +399,7 @@ class ListFamily(APIView):
REST Parameters:
"head=20"
use pagination to only load the k top ngrams of the mainlist
(useful for fast loading of terms view)
(useful for fast loading of terms view)
[CURRENTLY NOT USED]
"corpus=ID"
the corpus id to retrieve all 4 lists
"scoring=ID"
...
...
gargantext/views/api/urls.py
View file @
b6263a33
...
...
@@ -21,10 +21,13 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view()
# post data looks like : {"767":[209,640],"779":[436,265,385]}"
,
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
())
# entire combination of lists from a corpus
# entire combination of lists from a corpus
, dedicated to termtable
# (or any combination of lists that go together :
# - a mainlist
# - an optional stoplist
# - an optional maplist
# - an optional grouplist
,
url
(
r'^ngramlists/maplist$'
,
ngramlists
.
MapListGlance
.
as_view
())
# fast access to maplist, similarly formatted for termtable
]
static/js/gargantext/NGrams_dyna_chart_and_table.js
View file @
b6263a33
...
...
@@ -1756,6 +1756,10 @@ function MainTableAndCharts( data , initial , search_filter) {
}
}
// and set this filter's initial status to 'maplist' (aka state == 1)
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
=
1
;
MyTable
.
data
(
'dynatable'
).
process
();
// moves pagination over table
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
...
...
@@ -1897,9 +1901,18 @@ $("#corpusdisplayer").hide()
// NEW AJAX
// NEW AJAX x 2
var
prefetch_url
=
window
.
location
.
origin
+
"/api/ngramlists/maplist?corpus="
+
corpus_id
;
var
new_url
=
window
.
location
.
origin
+
"/api/ngramlists/family?corpus="
+
corpus_id
;
GET_
(
new_url
,
function
(
res
)
{
// faster call: just the maplist, will return first
GET_
(
prefetch_url
,
HandleAjax
);
// longer call (full list of terms) to return when ready and refresh all data
GET_
(
new_url
,
HandleAjax
)
function
HandleAjax
(
res
)
{
if
(
res
&&
res
.
ngraminfos
)
{
main_ngrams_objects
=
{}
...
...
@@ -1955,8 +1968,7 @@ GET_(new_url, function(res) {
$
(
"input#groups_id"
).
val
(
res
.
nodeids
[
'groups'
])
$
(
"input#scores_id"
).
val
(
res
.
nodeids
[
'scores'
])
AfterAjax
()
;
});
}
function
AfterAjax
()
{
// -------------------------------------------------------------------
...
...
templates/pages/corpora/terms.html
View file @
b6263a33
...
...
@@ -67,10 +67,11 @@
<div
class=
"pull-left"
style=
"margin-top:1.85em;"
>
Filter:
<select
id=
"picklistmenu"
name=
"my_state_filter"
>
<option
value=
'reset'
selected=
"selected"
>
All terms
</option>
<option
value=
'0'
>
Mainlist only
</option>
<option
value=
'1'
>
Maplist only
</option>
<option
value=
'2'
>
Stoplist only
</option>
<option
value=
'reset'
>
All terms
</option>
<option
value=
'0'
>
Candidates only
</option>
<!-- <option value='1' selected="selected">Map terms only</option> -->
<option
value=
'1'
>
Map terms only
</option>
<option
value=
'2'
>
New stopwords only
</option>
</select>
</div>
</h4>
...
...
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