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
927921cc
Commit
927921cc
authored
Aug 28, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Sort list exports to compare them more easily
parent
f61283c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
20 deletions
+28
-20
group_tools.py
gargantext/util/group_tools.py
+17
-14
ngramlists_tools.py
gargantext/util/ngramlists_tools.py
+11
-6
No files found.
gargantext/util/group_tools.py
View file @
927921cc
...
...
@@ -7,7 +7,7 @@ from gargantext.util.db import session, aliased
from
gargantext.models
import
Ngram
,
NodeNgramNgram
from
igraph
import
Graph
# for group_union
def
query_groups
(
groupings_id
,
details
=
False
):
def
query_groups
(
groupings_id
,
details
=
False
,
sort
=
False
):
"""
Listing of couples (mainform, subform)
aka (ngram1_id, ngram2_id)
...
...
@@ -15,24 +15,27 @@ def query_groups(groupings_id, details=False):
Parameter:
- details: if False, just send the array of couples
if True, send quadruplets with (ngram1_id, term1, ngram2_id, term2)
- sort: order results by terms of ngram1 then ngram2
"""
if
details
or
sort
:
Ngram1
,
Ngram2
=
Ngram
,
aliased
(
Ngram
)
if
not
details
:
# simple contents
query
=
session
.
query
(
NodeNgramNgram
.
ngram1_id
,
NodeNgramNgram
.
ngram2_id
)
columns
=
(
NodeNgramNgram
.
ngram1_id
,
NodeNgramNgram
.
ngram2_id
)
else
:
# detailed contents (id + terms)
Ngram1
=
aliased
(
Ngram
)
Ngram2
=
aliased
(
Ngram
)
query
=
(
session
.
query
(
NodeNgramNgram
.
ngram1_id
,
Ngram1
.
terms
,
NodeNgramNgram
.
ngram2_id
,
Ngram2
.
terms
,
)
.
join
(
Ngram1
,
NodeNgramNgram
.
ngram1_id
==
Ngram1
.
id
)
.
join
(
Ngram2
,
NodeNgramNgram
.
ngram2_id
==
Ngram2
.
id
)
)
columns
=
(
Ngram1
.
id
,
Ngram1
.
terms
,
Ngram2
.
id
,
Ngram2
.
terms
)
query
=
session
.
query
(
*
columns
)
if
details
or
sort
:
query
=
(
query
.
join
(
Ngram1
,
NodeNgramNgram
.
ngram1_id
==
Ngram1
.
id
)
.
join
(
Ngram2
,
NodeNgramNgram
.
ngram2_id
==
Ngram2
.
id
))
if
sort
:
query
=
query
.
order_by
(
Ngram1
.
terms
,
Ngram2
.
terms
)
# main filter
# -----------
...
...
gargantext/util/ngramlists_tools.py
View file @
927921cc
...
...
@@ -35,8 +35,8 @@ from celery import shared_task
def
query_list
(
list_id
,
pagination_limit
=
None
,
pagination_offset
=
None
,
details
=
False
,
scoring_metric_id
=
None
,
groupings_id
=
None
):
details
=
False
,
scoring_metric_id
=
None
,
groupings_id
=
None
,
sort
=
False
):
"""
Paginated listing of ngram_ids in a NodeNgram lists.
...
...
@@ -51,6 +51,7 @@ def query_list(list_id,
(for details and sorting)
- groupings_id: optional id of a list of grouping relations (synonyms)
(each synonym will be added to the list if not already in there)
- sort: order by Ngram.terms (not possible if details is False)
FIXME: subforms appended recently and not generalized enough
=> add a common part for all "if groupings_id"
...
...
@@ -116,6 +117,9 @@ def query_list(list_id,
if
pagination_offset
:
query
=
query
.
offset
(
pagination_offsets
)
if
details
and
sort
:
query
=
query
.
order_by
(
Ngram
.
terms
)
return
query
# helper func for exports
...
...
@@ -220,9 +224,10 @@ def export_ngramlists(node,fname=None,delimiter=DEFAULT_CSV_DELIM,titles=True):
# listes de ngram_ids correspondantes
# ------------------------------------
# contenu: liste des objets ngrammes [(2562,"monterme",1),...]
stop_ngrams
=
query_list
(
stoplist_node
.
id
,
details
=
True
,
groupings_id
=
group_node
.
id
)
.
all
()
main_ngrams
=
query_list
(
mainlist_node
.
id
,
details
=
True
,
groupings_id
=
group_node
.
id
)
.
all
()
map_ngrams
=
query_list
(
maplist_node
.
id
,
details
=
True
,
groupings_id
=
group_node
.
id
)
.
all
()
stop_ngrams
,
main_ngrams
,
map_ngrams
=
(
query_list
(
n
.
id
,
details
=
True
,
groupings_id
=
group_node
.
id
,
sort
=
True
)
.
all
()
for
n
in
(
stoplist_node
,
mainlist_node
,
maplist_node
)
)
# pour debug ---------->8 --------------------
#~ stop_ngrams = stop_ngrams[0:10]
...
...
@@ -239,7 +244,7 @@ def export_ngramlists(node,fname=None,delimiter=DEFAULT_CSV_DELIM,titles=True):
# for the groups we got couples of ids in the DB
# -------------------
# ex: [(3544, 2353), (2787, 4032), ...]
group_ngram_id_couples
=
query_groups
(
group_node
.
id
)
.
all
(
)
group_ngram_id_couples
=
query_groups
(
group_node
.
id
,
sort
=
True
)
# we expend this to double structure for groups lookup
# 1) g['links'] = k couples (x,y_i) as a set [x => {y1,y2}]
...
...
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