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
ab0aa5ba
Commit
ab0aa5ba
authored
Apr 04, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
[FIX] merge conflicts.
parents
53f4d9b9
6d6ac234
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
143 deletions
+151
-143
ngram_coocs.py
gargantext/util/toolchain/ngram_coocs.py
+4
-3
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+3
-2
urls.py
gargantext/views/api/urls.py
+0
-1
terms.py
gargantext/views/pages/terms.py
+2
-2
views.py
graphExplorer/views.py
+7
-5
extras_explorerjs.js
static/js/extras_explorerjs.js
+111
-106
explorer.html
templates/graphExplorer/explorer.html
+24
-24
No files found.
gargantext/util/toolchain/ngram_coocs.py
View file @
ab0aa5ba
...
@@ -74,6 +74,7 @@ def compute_coocs( corpus,
...
@@ -74,6 +74,7 @@ def compute_coocs( corpus,
"""
"""
# - TODO add grouped element's values in grouping 'chief ngram'
# - TODO cvalue_id: allow a metric as additional input filter
# - TODO cvalue_id: allow a metric as additional input filter
# - TODO n_min, n_max : filter on Ngram.n (aka length of ngram)
# - TODO n_min, n_max : filter on Ngram.n (aka length of ngram)
# - TODO weighted: if False normal cooc to be saved as result
# - TODO weighted: if False normal cooc to be saved as result
...
@@ -202,9 +203,9 @@ def compute_coocs( corpus,
...
@@ -202,9 +203,9 @@ def compute_coocs( corpus,
matrix
=
WeightedMatrix
(
coocs_query
.
all
())
matrix
=
WeightedMatrix
(
coocs_query
.
all
())
# fyi
# fyi
#
shape_0 = len({pair[0] for pair in matrix.items})
shape_0
=
len
({
pair
[
0
]
for
pair
in
matrix
.
items
})
#
shape_1 = len({pair[1] for pair in matrix.items})
shape_1
=
len
({
pair
[
1
]
for
pair
in
matrix
.
items
})
#
print("COOCS: NEW matrix shape [%ix%i]" % (shape_0, shape_1))
print
(
"COOCS: NEW matrix shape [
%
ix
%
i]"
%
(
shape_0
,
shape_1
))
# 5) SAVE
# 5) SAVE
# --------
# --------
...
...
gargantext/util/toolchain/ngrams_extraction.py
View file @
ab0aa5ba
...
@@ -64,6 +64,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
...
@@ -64,6 +64,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
for
ngram
in
ngramsextractor
.
extract
(
value
):
for
ngram
in
ngramsextractor
.
extract
(
value
):
tokens
=
tuple
(
token
[
0
]
for
token
in
ngram
)
tokens
=
tuple
(
token
[
0
]
for
token
in
ngram
)
terms
=
normalize_terms
(
' '
.
join
(
tokens
))
terms
=
normalize_terms
(
' '
.
join
(
tokens
))
if
len
(
terms
)
>
1
:
nodes_ngrams_count
[(
document
.
id
,
terms
)]
+=
1
nodes_ngrams_count
[(
document
.
id
,
terms
)]
+=
1
ngrams_data
.
add
((
terms
[:
255
],
len
(
tokens
),
))
ngrams_data
.
add
((
terms
[:
255
],
len
(
tokens
),
))
# integrate ngrams and nodes-ngrams
# integrate ngrams and nodes-ngrams
...
...
gargantext/views/api/urls.py
View file @
ab0aa5ba
...
@@ -24,5 +24,4 @@ urlpatterns = [
...
@@ -24,5 +24,4 @@ urlpatterns = [
# - an optional grouplist)
# - an optional grouplist)
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()),
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()),
]
]
gargantext/views/pages/terms.py
View file @
ab0aa5ba
...
@@ -11,7 +11,7 @@ def ngramtable(request, project_id, corpus_id):
...
@@ -11,7 +11,7 @@ def ngramtable(request, project_id, corpus_id):
=> maplist and mainlist terms in a table
=> maplist and mainlist terms in a table
with groupings as '+' nodes
with groupings as '+' nodes
=> uses API GET batch of lists
=> uses API GET batch of lists
=> uses API PUT/DEL for list modifications
(TODO)
=> uses API PUT/DEL for list modifications
=> uses frontend AJAX through Ngrams_dyna_charts_and_table.js
=> uses frontend AJAX through Ngrams_dyna_charts_and_table.js
# TODO refactor Ngrams_dyna_charts_and_table.js
# TODO refactor Ngrams_dyna_charts_and_table.js
'''
'''
...
@@ -21,7 +21,7 @@ def ngramtable(request, project_id, corpus_id):
...
@@ -21,7 +21,7 @@ def ngramtable(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
# and the project just for project.id in corpusBannerTop
project
=
cache
.
Node
[
project_id
]
project
=
cache
.
Node
[
project_id
]
# rendered page :
journal
s.html
# rendered page :
term
s.html
return
render
(
return
render
(
template_name
=
'pages/corpora/terms.html'
,
template_name
=
'pages/corpora/terms.html'
,
request
=
request
,
request
=
request
,
...
...
graphExplorer/views.py
View file @
ab0aa5ba
...
@@ -19,12 +19,15 @@ def explorer(request, project_id, corpus_id):
...
@@ -19,12 +19,15 @@ def explorer(request, project_id, corpus_id):
# we pass our corpus
# we pass our corpus
corpus
=
cache
.
Node
[
corpus_id
]
corpus
=
cache
.
Node
[
corpus_id
]
# get the maplist_id for modifications
maplist_id
=
corpus
.
children
(
typename
=
"MAPLIST"
)
.
first
()
.
id
# and the project just for project.id in corpusBannerTop
# and the project just for project.id in corpusBannerTop
project
=
cache
.
Node
[
project_id
]
project
=
cache
.
Node
[
project_id
]
graphurl
=
"projects/"
+
str
(
project_id
)
+
"/corpora/"
+
str
(
corpus_id
)
+
"/node_link.json"
graphurl
=
"projects/"
+
str
(
project_id
)
+
"/corpora/"
+
str
(
corpus_id
)
+
"/node_link.json"
# rendered page :
journals
.html
# rendered page :
explorer
.html
return
render
(
return
render
(
template_name
=
'graphExplorer/explorer.html'
,
template_name
=
'graphExplorer/explorer.html'
,
request
=
request
,
request
=
request
,
...
@@ -35,9 +38,8 @@ def explorer(request, project_id, corpus_id):
...
@@ -35,9 +38,8 @@ def explorer(request, project_id, corpus_id):
'date'
:
datetime
.
now
(),
'date'
:
datetime
.
now
(),
'project'
:
project
,
'project'
:
project
,
'corpus'
:
corpus
,
'corpus'
:
corpus
,
#'list_id' : maplist.id,\
'maplist_id'
:
maplist_id
,
'graphfile'
:
graphurl
,
\
'graphfile'
:
graphurl
,
'view'
:
'graph'
'view'
:
'graph'
},
},
)
)
static/js/extras_explorerjs.js
View file @
ab0aa5ba
...
@@ -23,15 +23,11 @@ function modify_ngrams( classname ) {
...
@@ -23,15 +23,11 @@ function modify_ngrams( classname ) {
console
.
clear
()
console
.
clear
()
var
corpus_id
=
getIDFromURL
(
"corpora"
)
// not used
var
corpus_id
=
getIDFromURL
(
"corpora"
)
// not used
var
list_id
=
$
(
"#list_id"
).
val
()
var
list_id
=
$
(
"#
map
list_id"
).
val
()
var
selected_ngrams
=
$
.
extend
({},
selections
)
var
selected_ngrams
=
$
.
extend
({},
selections
)
console
.
log
(
selected_ngrams
)
if
(
classname
==
"delete"
)
{
if
(
classname
==
"delete"
)
{
CRUD
(
corpus_id
,
"/keep"
,
[]
,
selected_ngrams
,
"DELETE"
,
function
(
result
)
{
CRUD
(
list_id
,
Object
.
keys
(
selected_ngrams
),
"DELETE"
,
function
(
success
)
{
console
.
log
(
" Delete from Map-list: "
+
result
)
CRUD
(
list_id
,
""
,
Object
.
keys
(
selected_ngrams
).
map
(
Number
)
,
[]
,
"DELETE"
,
function
(
result
)
{
console
.
log
(
" Add to Stop-list "
+
result
)
cancelSelection
(
false
)
cancelSelection
(
false
)
for
(
var
i
in
selected_ngrams
)
{
for
(
var
i
in
selected_ngrams
)
{
partialGraph
.
dropNode
(
i
)
partialGraph
.
dropNode
(
i
)
...
@@ -40,8 +36,7 @@ function modify_ngrams( classname ) {
...
@@ -40,8 +36,7 @@ function modify_ngrams( classname ) {
}
}
partialGraph
.
refresh
()
partialGraph
.
refresh
()
$
(
"#lensButton"
).
click
()
$
(
"#lensButton"
).
click
()
});
})
;
});
}
}
// if(classname=="group") {
// if(classname=="group") {
...
@@ -53,33 +48,43 @@ function modify_ngrams( classname ) {
...
@@ -53,33 +48,43 @@ function modify_ngrams( classname ) {
// }
// }
}
}
function
CRUD
(
parent_id
,
action
,
nodes
,
args
,
http_method
,
callback
)
{
function
CRUD
(
list_id
,
ngram_ids
,
http_method
,
callback
)
{
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
// ngramlists/change?node_id=42&ngram_ids=1,2
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
var
the_url
=
window
.
location
.
origin
+
"/api/ngramlists/change?list="
+
list_id
+
"&ngrams="
+
ngram_ids
.
join
(
","
);
console
.
log
(
the_url
)
console
.
log
(
args
)
// debug
if
(
nodes
.
length
>
0
||
Object
.
keys
(
args
).
length
>
0
)
{
// console.log("starting CRUD AJAX => URL: " + the_url + " (" + http_method + ")")
if
(
ngram_ids
.
length
>
0
)
{
$
.
ajax
({
$
.
ajax
({
method
:
http_method
,
method
:
http_method
,
url
:
the_url
,
url
:
the_url
,
data
:
args
,
// data: args, // currently all data explicitly in the url (like a GET)
beforeSend
:
function
(
xhr
)
{
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
},
success
:
function
(
data
){
success
:
function
(
data
){
console
.
log
(
"-- CRUD ----------"
)
console
.
log
(
http_method
+
" ok!!"
)
console
.
log
(
http_method
+
" ok!!"
)
console
.
log
(
nodes
)
console
.
log
(
JSON
.
stringify
(
data
)
)
console
.
log
(
data
)
console
.
log
(
"------------------"
)
callback
(
"Success"
);
callback
(
true
);
},
},
error
:
function
(
result
)
{
error
:
function
(
result
)
{
console
.
log
(
"-- CRUD ----------"
)
console
.
log
(
"Data not found in #Save_All"
);
console
.
log
(
result
)
console
.
log
(
result
)
callback
(
"Fail"
);
console
.
log
(
"------------------"
)
callback
(
false
);
}
}
});
});
}
else
callback
(
false
);
}
else
callback
(
false
);
}
}
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// Execution: ChangeGraphAppearanceByAtt( true )
// Execution: ChangeGraphAppearanceByAtt( true )
...
...
templates/graphExplorer/explorer.html
View file @
ab0aa5ba
...
@@ -136,7 +136,7 @@
...
@@ -136,7 +136,7 @@
<li>
<li>
<a>
<a>
<div
id=
"graphid"
style=
"visibility: hidden;"
>
{{graphfile}}
</div>
<div
id=
"graphid"
style=
"visibility: hidden;"
>
{{graphfile}}
</div>
<input
type=
"hidden"
id=
"
list_id"
value=
"{{
list_id }}"
></input>
<input
type=
"hidden"
id=
"
maplist_id"
value=
"{{ map
list_id }}"
></input>
<div
id=
"jquerytemplatenb"
style=
"visibility: hidden;"
>
{{user.id}}
</div>
<div
id=
"jquerytemplatenb"
style=
"visibility: hidden;"
>
{{user.id}}
</div>
</a>
</a>
</li>
</li>
...
...
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