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
1d4deca7
Commit
1d4deca7
authored
May 10, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
annotations: working local occurrences
parent
6fce8cad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
views.py
annotations/views.py
+11
-3
No files found.
annotations/views.py
View file @
1d4deca7
...
@@ -14,7 +14,7 @@ from rest_framework.authentication import SessionAuthentication, BasicAuthentica
...
@@ -14,7 +14,7 @@ from rest_framework.authentication import SessionAuthentication, BasicAuthentica
# 2016-03-24: refactoring, new paths
# 2016-03-24: refactoring, new paths
from
gargantext.models.ngrams
import
Node
,
NodeNgram
,
Ngram
from
gargantext.models.ngrams
import
Node
,
NodeNgram
,
Ngram
from
gargantext.util.db
import
session
from
gargantext.util.db
import
session
,
aliased
from
gargantext.util.db_cache
import
cache
from
gargantext.util.db_cache
import
cache
from
gargantext.util.http
import
requires_auth
from
gargantext.util.http
import
requires_auth
...
@@ -47,14 +47,22 @@ class NgramList(APIView):
...
@@ -47,14 +47,22 @@ class NgramList(APIView):
doc_ngram_list
=
[]
doc_ngram_list
=
[]
lists
=
{}
lists
=
{}
corpus_nod
=
cache
.
Node
[
corpus_id
]
doc_nod
=
cache
.
Node
[
doc_id
]
scores_nod
=
corpus_nod
.
children
(
typename
=
"OCCURRENCES"
)
.
first
()
for
list_type
in
[
'MAINLIST'
,
'MAPLIST'
,
'STOPLIST'
]:
for
list_type
in
[
'MAINLIST'
,
'MAPLIST'
,
'STOPLIST'
]:
corpus_nod
=
cache
.
Node
[
corpus_id
]
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
ListsTable
=
aliased
(
NodeNgram
)
# 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
)
# add to results
# add to results
doc_ngram_list
+=
[(
obj
.
id
,
obj
.
terms
,
w
,
list_id
)
for
(
w
,
obj
)
in
list_nod
.
ngrams
.
all
()]
doc_ngram_list
+=
[(
obj
.
id
,
obj
.
terms
,
w
,
list_id
)
for
(
w
,
obj
)
in
q
.
all
()]
# debug
# debug
# print("annotations.views.NgramList.doc_ngram_list: ", doc_ngram_list)
# print("annotations.views.NgramList.doc_ngram_list: ", doc_ngram_list)
...
...
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