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
542ddf49
Commit
542ddf49
authored
Nov 28, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'alex'
Merge new feature
parents
77db4880
0ef141b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
32 deletions
+36
-32
functions.py
analysis/functions.py
+11
-7
urls.py
gargantext_web/urls.py
+4
-3
views.py
gargantext_web/views.py
+16
-9
corpus.html
templates/corpus.html
+1
-1
explorer.html
templates/explorer.html
+1
-1
projects.html
templates/projects.html
+3
-11
No files found.
functions.py
→
analysis/
functions.py
View file @
542ddf49
...
...
@@ -14,9 +14,10 @@ def create_synonymes(user, corpus):
def
create_whitelist
(
user
,
corpus
):
cursor
=
connection
.
cursor
()
try
:
try
:
whitelist_type
=
NodeType
.
objects
.
get
(
name
=
'WhiteList'
)
blacklist_type
=
NodeType
.
objects
.
get
(
name
=
'BlackList'
)
type_document
=
NodeType
.
objects
.
get
(
name
=
'Document'
)
except
:
whitelist_type
=
NodeType
(
name
=
'WhiteList'
)
whitelist_type
.
save
()
...
...
@@ -24,8 +25,8 @@ def create_whitelist(user, corpus):
blacklist_type
=
NodeType
(
name
=
'BlackList'
)
blacklist_type
.
save
()
white_list
=
Node
.
objects
.
create
(
name
=
'WhiteList Corpus'
+
str
(
corpus
.
id
),
user
=
user
,
parent
=
corpus
,
type
=
whitelist_type
)
black_list
=
Node
.
objects
.
create
(
name
=
'BlackList Corpus'
+
str
(
corpus
.
id
),
user
=
user
,
parent
=
corpus
,
type
=
blacklist_type
)
white_list
=
Node
.
objects
.
create
(
name
=
'WhiteList Corpus
'
+
str
(
corpus
.
id
),
user
=
user
,
parent
=
corpus
,
type
=
whitelist_type
)
black_list
=
Node
.
objects
.
create
(
name
=
'BlackList Corpus
'
+
str
(
corpus
.
id
),
user
=
user
,
parent
=
corpus
,
type
=
blacklist_type
)
# delete avant pour éviter les doublons
# try:
...
...
@@ -48,7 +49,7 @@ def create_whitelist(user, corpus):
WHERE
n.parent_id =
%
d
AND
n.type_id =
4
n.type_id =
%
d
AND
ngX.n >= 1
...
...
@@ -61,8 +62,8 @@ def create_whitelist(user, corpus):
LIMIT
100
;
"""
%
(
white_list
.
id
,
corpus
.
id
)
"""
%
(
white_list
.
id
,
corpus
.
id
,
type_document
.
id
)
cursor
.
execute
(
query_whitelist
)
return
white_list
...
...
@@ -70,7 +71,7 @@ def create_whitelist(user, corpus):
#def create_cooc(user, corpus, whitelist, blacklist, synonymes):
def
create_cooc
(
user
=
None
,
corpus
=
None
,
whitelist
=
None
):
cursor
=
connection
.
cursor
()
try
:
cooc_type
=
NodeType
.
objects
.
get
(
name
=
'Cooccurrence'
)
except
:
...
...
@@ -122,6 +123,7 @@ def create_cooc(user=None, corpus=None, whitelist=None):
ngX.terms,
ngY.id,
ngY.terms
ORDER BY
score DESC
LIMIT
...
...
@@ -131,3 +133,5 @@ def create_cooc(user=None, corpus=None, whitelist=None):
cursor
.
execute
(
query_cooc
)
return
cooc
gargantext_web/urls.py
View file @
542ddf49
...
...
@@ -27,14 +27,15 @@ urlpatterns = patterns('',
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
views
.
corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/delete/$'
,
views
.
delete_corpus
),
url
(
r'^
graph
$'
,
views
.
explorer_graph
),
url
(
r'^
corpus/(\d+)/explorer
$'
,
views
.
explorer_graph
),
url
(
r'^chart$'
,
views
.
explorer_chart
),
url
(
r'^matrix$'
,
views
.
explorer_matrix
),
url
(
r'^exploration$'
,
views
.
exploration
),
#
url(r'^exploration$', views.exploration),
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
url
(
r'^graph.json$'
,
views
.
json_node_link
),
url
(
r'^corpus/(\d+)/node_link.json$'
,
views
.
node_link
),
url
(
r'^corpus/(\d+)/adjancy_matrix$'
,
views
.
node_link
),
url
(
r'^api/nodes$'
,
gargantext_web
.
api
.
NodesController
.
get
),
url
(
r'^api/corpus/(\d+)/ngrams$'
,
gargantext_web
.
api
.
CorpusController
.
ngrams
),
...
...
gargantext_web/views.py
View file @
542ddf49
...
...
@@ -172,7 +172,6 @@ def project(request, project_id):
corpus_view
[
'name'
]
=
corpus
.
name
corpus_view
[
'count'
]
=
corpus
.
children
.
count
()
for
node_resource
in
Node_Resource
.
objects
.
filter
(
node
=
corpus
):
donut_part
[
node_resource
.
resource
.
type
]
+=
docs_count
list_corpora
[
node_resource
.
resource
.
type
.
name
]
.
append
(
corpus_view
)
...
...
@@ -187,8 +186,6 @@ def project(request, project_id):
for
key
in
donut_part
.
keys
()
]
if
request
.
method
==
'POST'
:
#form = CorpusForm(request.POST, request.FILES)
#print(str(request.POST))
...
...
@@ -379,14 +376,16 @@ def delete_corpus(request, project_id, corpus_id):
Node
.
objects
.
filter
(
id
=
corpus_id
)
.
all
()
.
delete
()
return
HttpResponseRedirect
(
'/project/'
+
project_id
)
def
explorer_graph
(
request
):
def
explorer_graph
(
request
,
corpus_id
):
t
=
get_template
(
'explorer.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
corpus
=
Node
.
objects
.
get
(
id
=
corpus_id
)
html
=
t
.
render
(
Context
({
\
'user'
:
user
,
\
'date'
:
date
,
\
'corpus'
:
corpus
,
\
}))
return
HttpResponse
(
html
)
...
...
@@ -470,7 +469,7 @@ def send_csv(request, corpus_id):
return
response
def
json_node_link
(
request
):
def
node_link
(
request
,
corpus_id
):
'''
Create the HttpResponse object with the graph dataset.
'''
...
...
@@ -481,11 +480,22 @@ def json_node_link(request):
import
networkx
as
nx
from
networkx.readwrite
import
json_graph
from
gargantext_web.api
import
JsonHttpResponse
from
analysis.louvain
import
best_partition
from
analysis.functions
import
create_whitelist
,
create_cooc
matrix
=
defaultdict
(
lambda
:
defaultdict
(
float
))
labels
=
dict
()
cooc
=
Node
.
objects
.
get
(
id
=
81249
)
corpus
=
Node
.
objects
.
get
(
id
=
corpus_id
)
type_cooc
=
NodeType
.
objects
.
get
(
name
=
"Cooccurrence"
)
if
Node
.
objects
.
filter
(
type
=
type_cooc
,
parent
=
corpus
)
.
first
()
is
None
:
print
(
"Coocurrences do not exist yet, create it."
)
whitelist
=
create_whitelist
(
request
.
user
,
corpus
)
cooc
=
create_cooc
(
user
=
request
.
user
,
corpus
=
corpus
,
whitelist
=
whitelist
)
print
(
cooc
.
id
,
"Cooc created"
)
else
:
cooc
=
Node
.
objects
.
filter
(
type
=
type_cooc
,
parent
=
corpus
)
.
first
()
for
cooccurrence
in
NodeNgramNgram
.
objects
.
filter
(
node
=
cooc
):
labels
[
cooccurrence
.
ngramx
.
id
]
=
cooccurrence
.
ngramx
.
terms
...
...
@@ -494,7 +504,6 @@ def json_node_link(request):
matrix
[
cooccurrence
.
ngramx
.
id
][
cooccurrence
.
ngramy
.
id
]
=
cooccurrence
.
score
matrix
[
cooccurrence
.
ngramy
.
id
][
cooccurrence
.
ngramx
.
id
]
=
cooccurrence
.
score
df
=
pd
.
DataFrame
(
matrix
)
.
T
.
fillna
(
0
)
x
=
copy
(
df
.
values
)
x
=
x
/
x
.
sum
(
axis
=
1
)
...
...
@@ -535,7 +544,6 @@ def json_node_link(request):
return
JsonHttpResponse
(
data
)
def
graph_it
(
request
):
'''The new multimodal graph.'''
t
=
get_template
(
'graph-it.html'
)
...
...
@@ -565,4 +573,3 @@ def ngrams(request):
}))
return
HttpResponse
(
html
)
templates/corpus.html
View file @
542ddf49
...
...
@@ -125,7 +125,7 @@
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/
graph
"
>
Visualizations
</a></h3>
<h3><a
href=
"/
corpus/{{ corpus.id }}/explorer
"
>
Visualizations
</a></h3>
<ol>
<li>
Matrix
</li>
<li>
Static maps
</li>
...
...
templates/explorer.html
View file @
542ddf49
...
...
@@ -60,7 +60,7 @@
<li>
<a>
<div
id=
"graphid"
style=
"visibility: hidden;"
>
/graph
.json
</div>
<div
id=
"graphid"
style=
"visibility: hidden;"
>
/corpus/{{ corpus.id }}/node_link
.json
</div>
</a>
</li>
...
...
templates/projects.html
View file @
542ddf49
...
...
@@ -13,15 +13,10 @@
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"jumbotron"
>
<h1>
My {{number}} projects
</h1>
<p>
Template showing my working space
</p>
</div>
<div
class=
"col-md-1 content"
>
<p>
<br>
<button
type=
"button"
class=
"btn btn-primary btn-lg"
...
...
@@ -31,12 +26,9 @@
>
Add a project
</button>
<div
id=
"popover-content"
class=
"hide"
>
<form
enctype=
'multipart/form-data'
action=
'/projects/'
method=
'post'
>
{% csrf_token %}{{ form.non_field_errors }}{{ form.as_p}}
<input
type=
'submit'
class=
"btn"
value=
'Add this project !'
/></form>
</p>
</div>
</div>
</div>
</div>
</div>
</p>
</div>
</div>
<div
class=
"container"
>
...
...
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