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
be06df46
Commit
be06df46
authored
Mar 30, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Graph, with mapList only.
parent
2b17dfca
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
21 deletions
+20
-21
cooccurrences.py
graphExplorer/cooccurrences.py
+10
-12
functions.py
graphExplorer/functions.py
+7
-7
rest.py
graphExplorer/rest.py
+3
-2
No files found.
graphExplorer/cooccurrences.py
View file @
be06df46
...
...
@@ -9,22 +9,20 @@ from sqlalchemy import desc, asc, or_, and_
#import inspect
import
datetime
def
do_cooc
(
corpus
=
None
,
field1
=
'ngrams'
,
field2
=
'ngrams'
,
mainList_id
=
None
,
groupList_id
=
None
,
coocNode_id
=
None
,
start
=
None
,
end
=
None
def
do_cooc
(
corpus
=
None
,
field1
=
'ngrams'
,
field2
=
'ngrams'
,
start
=
None
,
end
=
None
,
mapList_id
=
None
,
groupList_id
=
None
,
n_min
=
1
,
n_max
=
None
,
limit
=
1000
,
isMonopartite
=
True
,
threshold
=
3
,
reset
=
True
):
,
coocNode_id
=
None
,
reset
=
True
,
isMonopartite
=
True
,
threshold
=
3
):
'''
Compute the cooccurence matrix and save it, returning NodeNgramNgram.node_id
For the moment list of paramters are not supported because, lists need to
be merged before.
corpus :: Corpus
ma
inList_id
:: Int
ma
pList_id
:: Int
groupList_id :: Int
For the moment, start and end are simple, only year is implemented yet
...
...
@@ -191,9 +189,9 @@ def do_cooc(corpus=None
cooc_query
=
cooc_query
.
order_by
(
desc
(
'cooc_score'
))
matrix
=
WeightedMatrix
(
cooc_query
)
ma
inList
=
UnweightedList
(
main
List_id
)
ma
pList
=
UnweightedList
(
map
List_id
)
group_list
=
Translations
(
groupList_id
)
cooc
=
matrix
&
(
ma
in
List
*
group_list
)
cooc
=
matrix
&
(
ma
p
List
*
group_list
)
cooc
.
save
(
coocNode_id
)
return
(
coocNode_id
)
graphExplorer/functions.py
View file @
be06df46
...
...
@@ -29,7 +29,7 @@ def get_cooc( request=None, corpus=None
,
distance
=
'conditional'
,
size
=
1000
,
bridgeness
=
5
,
ma
in
List_id
=
None
,
groupList_id
=
None
,
ma
p
List_id
=
None
,
groupList_id
=
None
):
'''
get_ccoc : to compute the graph.
...
...
@@ -38,15 +38,15 @@ def get_cooc( request=None, corpus=None
data
=
{}
if
ma
in
List_id
==
None
:
ma
in
List_id
=
(
session
.
query
(
Node
.
id
)
.
filter
(
Node
.
typename
==
"MA
IN
LIST"
if
ma
p
List_id
==
None
:
ma
p
List_id
=
(
session
.
query
(
Node
.
id
)
.
filter
(
Node
.
typename
==
"MA
P
LIST"
,
Node
.
parent_id
==
corpus
.
id
)
.
first
()
)
if
ma
in
List_id
==
None
:
raise
ValueError
(
"MA
IN
LIST node needed for cooccurrences"
)
if
ma
p
List_id
==
None
:
raise
ValueError
(
"MA
P
LIST node needed for cooccurrences"
)
if
groupList_id
==
None
:
...
...
@@ -79,7 +79,7 @@ def get_cooc( request=None, corpus=None
cooc_id
=
do_cooc
(
corpus
=
corpus
#, field1="ngrams", field2="ngrams"
,
ma
inList_id
=
int
(
main
List_id
[
0
]),
groupList_id
=
int
(
groupList_id
[
0
])
,
ma
pList_id
=
int
(
map
List_id
[
0
]),
groupList_id
=
int
(
groupList_id
[
0
])
#, isMonopartite=True
,
start
=
start
,
end
=
end
,
threshold
=
threshold
#, limit=size
...
...
graphExplorer/rest.py
View file @
be06df46
from
gargantext.util.http
import
APIView
,
APIException
,
JsonHttpResponse
,
requires_auth
#from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from
gargantext.util.db
import
session
from
gargantext.models.nodes
import
Node
from
graphExplorer.functions
import
get_cooc
from
gargantext.util.http
import
APIView
,
APIException
\
,
JsonHttpResponse
,
requires_auth
# TODO check authentication
...
...
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