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
29aa56bb
Commit
29aa56bb
authored
Jan 14, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] get and remove sessions for graph explorer.
parent
0613100d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
distance.py
analysis/distance.py
+4
-2
functions.py
analysis/functions.py
+7
-4
No files found.
analysis/distance.py
View file @
29aa56bb
from
admin.utils
import
PrintException
from
admin.utils
import
PrintException
from
gargantext_web.db
import
*
from
gargantext_web.db
import
*
from
gargantext_web.db
import
get_or_create_node
from
gargantext_web.db
import
get_or_create_node
,
get_session
from
collections
import
defaultdict
from
collections
import
defaultdict
from
operator
import
itemgetter
from
operator
import
itemgetter
...
@@ -31,6 +31,8 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
...
@@ -31,6 +31,8 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
do_distance :: Int -> (Graph, Partition, {ids}, {weight})
do_distance :: Int -> (Graph, Partition, {ids}, {weight})
'''
'''
session
=
get_session
()
authorized
=
[
'conditional'
,
'distributional'
,
'cosine'
]
authorized
=
[
'conditional'
,
'distributional'
,
'cosine'
]
if
distance
not
in
authorized
:
if
distance
not
in
authorized
:
distance
=
'conditional'
distance
=
'conditional'
...
@@ -203,7 +205,6 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
...
@@ -203,7 +205,6 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
def
getWeight
(
item
):
def
getWeight
(
item
):
return
item
[
1
]
return
item
[
1
]
#
#
...
@@ -226,4 +227,5 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
...
@@ -226,4 +227,5 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
partition
=
best_partition
(
G
.
to_undirected
())
partition
=
best_partition
(
G
.
to_undirected
())
return
(
G
,
partition
,
ids
,
weight
)
return
(
G
,
partition
,
ids
,
weight
)
session
.
remove
()
analysis/functions.py
View file @
29aa56bb
...
@@ -9,7 +9,7 @@ from math import log
...
@@ -9,7 +9,7 @@ from math import log
import
scipy
import
scipy
from
gargantext_web.db
import
get_or_create_node
from
gargantext_web.db
import
get_
session
,
get_
or_create_node
from
analysis.cooccurrences
import
do_cooc
from
analysis.cooccurrences
import
do_cooc
from
analysis.distance
import
do_distance
from
analysis.distance
import
do_distance
...
@@ -39,12 +39,14 @@ def get_cooc(request=None, corpus=None
...
@@ -39,12 +39,14 @@ def get_cooc(request=None, corpus=None
'''
'''
get_ccoc : to compute the graph.
get_ccoc : to compute the graph.
'''
'''
session
=
get_session
()
data
=
{}
data
=
{}
#if session.query(Node).filter(Node.type_id==type_cooc_id, Node.parent_id==corpus_id).first() is None:
#if session.query(Node).filter(Node.type_id==type_cooc_id, Node.parent_id==corpus_id).first() is None:
print
(
"Cooccurrences do not exist yet, creating it."
)
print
(
"Cooccurrences do not exist yet, creating it."
)
miam_id
=
get_or_create_node
(
nodetype
=
'MapList'
,
corpus
=
corpus
)
.
id
miam_id
=
get_or_create_node
(
nodetype
=
'MapList'
,
corpus
=
corpus
,
session
=
session
)
.
id
stop_id
=
get_or_create_node
(
nodetype
=
'StopList'
,
corpus
=
corpus
)
.
id
stop_id
=
get_or_create_node
(
nodetype
=
'StopList'
,
corpus
=
corpus
,
session
=
session
)
.
id
group_id
=
get_or_create_node
(
nodetype
=
'Group'
,
corpus
=
corpus
)
.
id
group_id
=
get_or_create_node
(
nodetype
=
'Group'
,
corpus
=
corpus
,
session
=
session
)
.
id
SamuelFlag
=
False
SamuelFlag
=
False
# if field1 == field2 == 'ngrams' :
# if field1 == field2 == 'ngrams' :
...
@@ -168,6 +170,7 @@ def get_cooc(request=None, corpus=None
...
@@ -168,6 +170,7 @@ def get_cooc(request=None, corpus=None
return
(
partition
)
return
(
partition
)
return
(
data
)
return
(
data
)
session
.
remove
()
def
get_graphA
(
nodeA_type
,
NodesB
,
links
,
corpus
):
def
get_graphA
(
nodeA_type
,
NodesB
,
links
,
corpus
):
from
analysis.InterUnion
import
Utils
from
analysis.InterUnion
import
Utils
...
...
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