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
3042e0de
Commit
3042e0de
authored
Oct 13, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Ngram workflow parameters and cooc for specificities (for tests on dev.gargantext.org).
parent
d186837b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
13 deletions
+23
-13
cooccurrences.py
analysis/cooccurrences.py
+3
-2
functions.py
analysis/functions.py
+9
-7
celery.py
gargantext_web/celery.py
+0
-1
workflow.py
ngram/workflow.py
+11
-3
No files found.
analysis/cooccurrences.py
View file @
3042e0de
...
...
@@ -27,7 +27,7 @@ def cooc(corpus=None
stop_id :: Int
group_id :: Int
For the moment, start and en
s
are simple, only year is implemented yet
For the moment, start and en
d
are simple, only year is implemented yet
start :: TimeStamp -- example: '2010-05-30 02:00:00+02'
end :: TimeStamp
limit :: Int
...
...
@@ -109,7 +109,8 @@ def cooc(corpus=None
# Cooc is symetric, take only the main cooccurrences and cut at the limit
cooc_query
=
(
cooc_query
.
filter
(
NodeNgramX
.
ngram_id
<
NodeNgramY
.
ngram_id
)
.
having
(
cooc_score
>
1
)
.
having
(
cooc_score
>
2
)
#.having(cooc_score > 1)
.
group_by
(
NodeNgramX
.
ngram_id
,
NodeNgramY
.
ngram_id
)
.
order_by
(
desc
(
'cooc_score'
))
...
...
analysis/functions.py
View file @
3042e0de
...
...
@@ -21,7 +21,8 @@ import networkx as nx
from
networkx.readwrite
import
json_graph
from
rest_v1_0.api
import
JsonHttpResponse
from
analysis.louvain
import
best_partition
from
analysis.louvain
import
best_partition
,
generate_dendogram
,
partition_at_level
from
ngram.lists
import
listIds
...
...
@@ -229,10 +230,10 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
#print(n)
#print(m)
nodes_included
=
2
00
#int(round(size/20,0))
nodes_included
=
3
00
#int(round(size/20,0))
#nodes_excluded = int(round(size/10,0))
nodes_specific
=
2
00
#int(round(size/10,0))
nodes_specific
=
3
00
#int(round(size/10,0))
#nodes_generic = int(round(size/10,0))
# TODO user the included score for the node size
...
...
@@ -263,11 +264,11 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
#edges_to_remove = [ e for e in G.edges_iter() if
degree
=
G
.
degree
()
nodes_to_remove
=
[
n
for
n
in
degree
if
degree
[
n
]
==
0
]
nodes_to_remove
=
[
n
for
n
in
degree
if
degree
[
n
]
<=
1
]
G
.
remove_nodes_from
(
nodes_to_remove
)
uG
=
G
.
to_undirected
()
partition
=
best_partition
(
uG
)
print
(
partition
)
print
(
"Density of the graph:"
,
nx
.
density
(
G
))
except
:
print
(
"-"
*
30
)
...
...
@@ -315,7 +316,8 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
except
Exception
as
error
:
print
(
"error02: "
,
error
)
data
=
json_graph
.
node_link_data
(
G
)
elif
type
==
'bestpartition'
:
return
(
partition
)
# data = json_graph.node_link_data(G, attrs={\
# 'source':'source',\
...
...
@@ -325,5 +327,5 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
# #'color':'color',\
# 'id':'id',})
#print(data)
return
data
return
(
data
)
gargantext_web/celery.py
View file @
3042e0de
...
...
@@ -50,7 +50,6 @@ def apply_workflow(corpus_id):
#ngrams2miam(user_id=corpus.user_id, corpus_id=corpus_id)
update_processing
(
corpus
,
0
)
#@transaction.commit_manually
@
shared_task
def
empty_trash
(
corpus_id
):
nodes
=
models
.
Node
.
objects
.
filter
(
type_id
=
cache
.
NodeType
[
'Trash'
]
.
id
)
.
all
()
...
...
ngram/workflow.py
View file @
3042e0de
...
...
@@ -6,6 +6,8 @@ from ngram.specificity import compute_specificity
from
ngram.group
import
compute_groups
from
ngram.miam
import
compute_miam
from
gargantext_web.db
import
get_or_create_node
#from gargantext_web.celery import update_processing
def
ngram_workflow
(
corpus
,
n
=
5000
):
'''
...
...
@@ -17,21 +19,27 @@ def ngram_workflow(corpus, n=5000):
compute_cvalue
(
corpus
,
limit
=
part
)
# size
part
=
round
(
part
*
0.6
)
part
=
round
(
part
*
0.4
)
print
(
'spec part:'
,
part
)
compute_specificity
(
corpus
,
limit
=
part
)
part
=
round
(
part
*
0.5
)
# compute_stop(corpus)
compute_groups
(
corpus
,
limit_inf
=
part
,
limit_sup
=
n
)
limit_inf
=
round
(
part
*
1
)
limit_sup
=
round
(
part
*
5
)
print
(
limit_inf
,
limit_sup
)
compute_groups
(
corpus
,
limit_inf
=
limit_inf
,
limit_sup
=
limit_sup
)
# compute_miam(corpus,limit=part) # size
compute_tfidf
(
corpus
)
#corpus=session.query(Node).filter(Node.id==2
44250
).first()
#corpus=session.query(Node).filter(Node.id==2
57579
).first()
#ngram_workflow(corpus)
#update_processing(corpus, 0)
#cvalue = get_or_create_node(corpus=corpus,nodetype='Cvalue')
#print(session.query(NodeNodeNgram).filter(NodeNodeNgram.nodex_id==cvalue.id).count())
...
...
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