Commit 463c27b5 authored by Romain Loth's avatar Romain Loth

annotations: filter map from main at initial transmission to avoid...

annotations: filter map from main at initial transmission to avoid interference of the 2 context menus
parent 0e22345f
...@@ -118,12 +118,8 @@ ...@@ -118,12 +118,8 @@
// * (see also InferCRUDFlags in lib/NGrams_dyna_chart_and_table) // * (see also InferCRUDFlags in lib/NGrams_dyna_chart_and_table)
// --------------------------------------------------------------- // ---------------------------------------------------------------
// TODO disambiguate annotation.list_id for highlighted MapList items // NB: remember that shown mainlist items are actually main 'without map'
// ------------------------------------------------------------- // otherwise the menu for mainlist items can hide the menu for map items
// Because MapList annotations are also MiamList,
// we should ensure that list_id is indeed "MapList"
// (ie that it was added last in CompileNgramsHtml)
// otherwise the "if" here will propose MiamList's options
if ($rootScope.lists[annotation.list_id] == "MAPLIST") { if ($rootScope.lists[annotation.list_id] == "MAPLIST") {
$scope.menuItems.push({ $scope.menuItems.push({
......
...@@ -45,13 +45,18 @@ class NgramList(APIView): ...@@ -45,13 +45,18 @@ class NgramList(APIView):
# our results: ngrams for the corpus_id (ignoring doc_id for the moment) # our results: ngrams for the corpus_id (ignoring doc_id for the moment)
doc_ngram_list = [] doc_ngram_list = []
doc_ngram_list_add = doc_ngram_list.append
lists = {} lists = {}
corpus_nod = cache.Node[corpus_id] corpus_nod = cache.Node[corpus_id]
doc_nod = cache.Node[doc_id] doc_nod = cache.Node[doc_id]
scores_nod = corpus_nod.children(typename="OCCURRENCES").first() scores_nod = corpus_nod.children(typename="OCCURRENCES").first()
for list_type in ['MAINLIST', 'MAPLIST', 'STOPLIST']: # maplist_ids to filter them from mainlist
maplist_ids = {}
# NB must do mainlist after map for filtering map items out of main
for list_type in ['MAPLIST', 'STOPLIST', 'MAINLIST']:
list_nod = corpus_nod.children(typename=list_type).first() list_nod = corpus_nod.children(typename=list_type).first()
list_id = list_nod.id list_id = list_nod.id
lists["%s" % list_id] = list_type lists["%s" % list_id] = list_type
...@@ -61,8 +66,20 @@ class NgramList(APIView): ...@@ -61,8 +66,20 @@ class NgramList(APIView):
# doc_nod.ngrams iff we just need the occurrences in the doc (otherwise do manually) # doc_nod.ngrams iff we just need the occurrences in the doc (otherwise do manually)
q = doc_nod.ngrams.join(ListsTable).filter(ListsTable.node_id == list_id) q = doc_nod.ngrams.join(ListsTable).filter(ListsTable.node_id == list_id)
# add to results # add to results (and optional filtering)
doc_ngram_list += [(obj.id, obj.terms, w, list_id) for (w,obj) in q.all()] for (w,obj) in q.all():
# special filtering case
# when MAINLIST requested we actually want MAIN without MAP
if list_type == "MAPLIST":
maplist_ids[obj.id] = True
if list_type == "MAINLIST":
if obj.id in maplist_ids:
# skip object
continue
# normal case
doc_ngram_list_add((obj.id, obj.terms, w, list_id))
# debug # debug
# print("annotations.views.NgramList.doc_ngram_list: ", doc_ngram_list) # print("annotations.views.NgramList.doc_ngram_list: ", doc_ngram_list)
...@@ -72,7 +89,7 @@ class NgramList(APIView): ...@@ -72,7 +89,7 @@ class NgramList(APIView):
{'uuid': ngram_id, {'uuid': ngram_id,
'text': ngram_text, 'text': ngram_text,
'occs': ngram_occurrences, 'occs': ngram_occurrences,
'lid': list_id,} 'list_id': list_id,}
for (ngram_id,ngram_text,ngram_occurrences,list_id) in doc_ngram_list for (ngram_id,ngram_text,ngram_occurrences,list_id) in doc_ngram_list
], ],
'lists': lists 'lists': lists
......
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