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
39b31af4
Commit
39b31af4
authored
Nov 18, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
b6d6a1d4
a52363f9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
89 deletions
+87
-89
utils.py
admin/utils.py
+1
-4
celery.py
gargantext_web/celery.py
+1
-1
views.py
gargantext_web/views.py
+2
-2
ngrams.py
rest_v1_0/ngrams.py
+22
-8
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+57
-63
menu.html
templates/corpus/menu.html
+2
-9
views.py
tests/ngramstable/views.py
+2
-2
No files found.
admin/utils.py
View file @
39b31af4
...
...
@@ -53,10 +53,7 @@ class WorkflowTracking:
def
processing_
(
self
,
corpus
,
step
):
try
:
the_query
=
""" UPDATE node_node SET hyperdata=
\'
{
\"
%
s
\"
: 1}
\'
WHERE id=
%
d """
%
(
step
,
corpus
.
id
)
# print(the_query)
# print(step)
# print(" = = = = = = =")
the_query
=
""" UPDATE node_node SET hyperdata=
\'
{
\"
%
s
\"
:
\"
%
s
\"
}
\'
WHERE id=
%
d """
%
(
"Processing"
,
step
,
corpus
.
id
)
cursor
=
connection
.
cursor
()
try
:
cursor
.
execute
(
the_query
)
...
...
gargantext_web/celery.py
View file @
39b31af4
...
...
@@ -43,7 +43,7 @@ def apply_workflow(corpus_id):
ngram_workflow
(
corpus
)
#ngrams2miam(user_id=corpus.user_id, corpus_id=corpus_id)
update_state
.
processing_
(
corpus
,
"
OK
"
)
update_state
.
processing_
(
corpus
,
"
0
"
)
@
shared_task
def
empty_trash
(
corpus_id
):
...
...
gargantext_web/views.py
View file @
39b31af4
...
...
@@ -349,7 +349,7 @@ def corpus(request, project_id, corpus_id):
except
Exception
as
error
:
print
(
error
)
processing
=
0
print
(
'processing'
,
processing
)
print
(
'
corpus'
,
corpus_id
,
' ,
processing'
,
processing
)
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
...
...
@@ -572,7 +572,7 @@ def graph(request, project_id, corpus_id, generic=100, specific=100):
html
=
t
.
render
(
Context
({
\
'debug'
:
settings
.
DEBUG
,
'user'
:
user
,
\
'user'
:
request
.
user
,
\
'date'
:
date
,
\
'corpus'
:
corpus
,
\
'project'
:
project
,
\
...
...
rest_v1_0/ngrams.py
View file @
39b31af4
...
...
@@ -89,9 +89,9 @@ class List(APIView):
ngram_ids
[
node
.
ngram_id
]
=
True
ngrams
=
[
int
(
i
)
for
i
in
list
(
ngram_ids
.
keys
())]
ngram_ids
=
get_occtfidf
(
ngrams
,
request
.
user
.
id
,
corpus_id
,
list_name
)
#
ngram_ids = get_occtfidf( ngrams , request.user.id , corpus_id , list_name)
return
JsonHttpResponse
(
ngram_ids
)
return
JsonHttpResponse
(
{
"data"
:
ngram_ids
}
)
class
Ngrams
(
APIView
):
'''
...
...
@@ -100,18 +100,20 @@ class Ngrams(APIView):
http://localhost:8000/api/node/1444485/ngrams?format=json&score=tfidf,occs
'''
def
get
(
self
,
request
,
node_id
):
# print("\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
# query ngrams
ParentNode
=
aliased
(
Node
)
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
group_by
=
[]
results
=
[
'id'
,
'terms'
]
# print("\t\tSTEP 01","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
ngrams_query
=
(
session
.
query
(
Ngram
.
id
,
Ngram
.
terms
)
.
join
(
Node_Ngram
,
Node_Ngram
.
ngram_id
==
Ngram
.
id
)
.
join
(
Node
,
Node
.
id
==
Node_Ngram
.
node_id
)
)
# print("\t\tSTEP 02","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
the_score
=
"tfidf"
if
request
.
GET
.
get
(
'score'
,
False
)
!=
False
:
the_score
=
request
.
GET
[
'score'
]
...
...
@@ -167,6 +169,7 @@ class Ngrams(APIView):
group_by
.
append
(
Spec
.
score
)
results
.
append
(
'specificity'
)
# print("\t\tSTEP 03","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
order_query
=
request
.
GET
.
get
(
'order'
,
False
)
if
order_query
==
'occs'
:
ngrams_query
=
ngrams_query
.
order_by
(
desc
(
occs
))
...
...
@@ -177,6 +180,7 @@ class Ngrams(APIView):
elif
order_query
==
'specificity'
:
ngrams_query
=
ngrams_query
.
order_by
(
desc
(
Spec
.
score
))
# print("\t\tSTEP 04","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
offset
=
int
(
request
.
GET
.
get
(
'offset'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
20
))
...
...
@@ -184,6 +188,7 @@ class Ngrams(APIView):
.
group_by
(
Ngram
.
id
,
Ngram
.
terms
,
*
group_by
)
)
# print("\t\tSTEP 05","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
if
request
.
GET
.
get
(
'ngram_id'
,
False
)
!=
False
:
ngram_id
=
int
(
request
.
GET
[
'ngram_id'
])
Group
=
aliased
(
NodeNgramNgram
)
...
...
@@ -193,7 +198,8 @@ class Ngrams(APIView):
.
filter
(
Group
.
ngramx_id
==
ngram_id
)
)
# filters by list type (soon list_id to factorize it in javascript)
# print("\t\tSTEP 06","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
# # filters by list type (soon list_id to factorize it in javascript)
list_query
=
request
.
GET
.
get
(
'list'
,
'miam'
)
list_id
=
request
.
GET
.
get
(
'list_id'
,
False
)
if
list_query
==
'miam'
:
...
...
@@ -235,11 +241,18 @@ class Ngrams(APIView):
.
filter
(
CoocY
.
node_id
==
node
.
id
)
)
total
=
ngrams_query
.
count
()
# print("\t\tSTEP 07","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
# print("")
# print(ngrams_query)
# total = ngrams_query.count()
# print("")
# print("\t\tSTEP 07.1, count:", total ,"\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
# print("\t\tSTEP 07.2, i:", offset , ", N:", (offset+limit) ,"\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
output
=
[]
for
ngram
in
ngrams_query
[
offset
:
offset
+
limit
]:
info
=
{
"scores"
:
{}
}
info
=
{
"scores"
:
{}
}
try
:
info
[
"id"
]
=
ngram
.
id
except
:
pass
try
:
info
[
"name"
]
=
ngram
.
terms
...
...
@@ -255,13 +268,14 @@ class Ngrams(APIView):
output
.
append
(
info
)
# print("\t\tSTEP 08","\tCORPUS:",node_id," LIST:",request.GET.get('list', False) , " SCORES:",request.GET.get('score', False))
# return formatted result
return
JsonHttpResponse
({
'pagination'
:
{
'offset'
:
offset
,
'limit'
:
limit
,
'total'
:
total
,
'total'
:
len
(
output
)
,
},
'data'
:
output
,
})
...
...
@@ -344,7 +358,7 @@ class Group(APIView):
# groups["nodes"] = get_occtfidf( ngrams , request.user.id , corpus_id , "Group")
return
JsonHttpResponse
(
groups
)
return
JsonHttpResponse
(
{
"data"
:
groups
}
)
def
post
(
self
,
request
,
node_id
):
return
JsonHttpResponse
(
[
"hola"
,
"mundo"
]
)
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
39b31af4
...
...
@@ -879,13 +879,28 @@ function getIDFromURL( item ) {
return
pageurl
[
cid
+
1
];
}
function
GET_
(
url
,
callback
)
{
$
.
ajax
({
type
:
"GET"
,
url
:
url
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
callback
(
data
.
data
);
},
error
:
function
(
exception
)
{
callback
(
false
);
}
})
}
// [ = = = = = = = = = = INIT = = = = = = = = = = ]
// http://localhost:8000/api/node/84592/ngrams?format=json&score=tfidf,occs&list=miam
var
corpus_id
=
getIDFromURL
(
"corpus"
)
var
url0
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams?format=json&score=tfidf,occs&list=stop&limit=
999999
"
,
var
url0
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams?format=json&score=tfidf,occs&list=stop&limit=
1000
"
,
url1
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams/group"
,
url2
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams
?format=json&score=tfidf,occs&list=map&limit=999999
"
,
url3
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams?format=json&score=tfidf,occs&list=miam&limit=
999999
"
;
url2
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams
/list/map
"
,
url3
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams?format=json&score=tfidf,occs&list=miam&limit=
1000
"
;
var
NGrams
=
{
"group"
:
{},
"stop"
:
{},
...
...
@@ -895,65 +910,42 @@ var NGrams = {
}
$
(
"#corpusdisplayer"
).
hide
()
$
.
when
(
$
.
ajax
({
type
:
"GET"
,
url
:
url0
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
for
(
var
i
in
data
.
data
)
{
NGrams
[
"stop"
][
data
.
data
[
i
].
id
]
=
data
.
data
[
i
]
}
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
}),
$
.
ajax
({
type
:
"GET"
,
url
:
url1
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"group"
]
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
}),
$
.
ajax
({
type
:
"GET"
,
url
:
url2
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
for
(
var
i
in
data
.
data
)
{
NGrams
[
"map"
][
data
.
data
[
i
].
id
]
=
data
.
data
[
i
]
}
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
}),
$
.
ajax
({
type
:
"GET"
,
url
:
url3
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"main"
]
=
{
"ngrams"
:
data
.
data
,
"scores"
:
{
"initial"
:
"occ_uniq"
,
"nb_docs"
:
data
.
data
.
length
,
"orig_nb_ngrams"
:
1
,
"nb_ngrams"
:
data
.
data
.
length
,
}
}
},
error
:
function
(
exception
)
{
console
.
log
(
"second ajax, exception!: "
+
exception
.
status
)
}
})
).
then
(
function
()
{
// The AJAX's in cascade:
GET_
(
url0
,
function
(
result
)
{
if
(
result
!=
false
)
{
for
(
var
i
in
result
)
{
NGrams
[
"stop"
][
result
[
i
].
id
]
=
result
[
i
]
}
}
GET_
(
url1
,
function
(
result
)
{
if
(
result
!=
false
)
{
NGrams
[
"group"
]
=
result
}
GET_
(
url2
,
function
(
result
)
{
if
(
result
!=
false
)
{
NGrams
[
"map"
]
=
result
}
GET_
(
url3
,
function
(
result
)
{
if
(
result
!=
false
)
{
NGrams
[
"main"
]
=
{
"ngrams"
:
result
,
"scores"
:
{
"initial"
:
"occ_uniq"
,
"nb_docs"
:
result
.
length
,
"orig_nb_ngrams"
:
1
,
"nb_ngrams"
:
result
.
length
,
}
}
AfterAjax
()
}
});
});
});
});
function
AfterAjax
()
{
// Deleting subforms from the ngrams-table, clean start baby!
if
(
Object
.
keys
(
NGrams
[
"group"
].
links
).
length
>
0
)
{
...
...
@@ -1013,5 +1005,7 @@ $.when(
$
(
"#corpusdisplayer"
).
show
()
$
(
"#content_loader"
).
remove
()
$
(
"#corpusdisplayer"
).
click
()
}
});
\ No newline at end of file
templates/corpus/menu.html
View file @
39b31af4
...
...
@@ -45,13 +45,7 @@
</ul>
'
>
Manage
</a>
<!--
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: 90%">
<span class="sr-only">45% Complete</span>
</div>
</div>
--!>
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
...
...
@@ -65,8 +59,7 @@
<center>
<a
type=
"button"
class=
"btn btn-default {% if view == "
documents
"
%}
active
{%
endif
%}"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/documents"
>
{{number}} Documents
</a>
<a
type=
"button"
class=
"btn btn-default {% if view == "
journals
"
%}
active
{%
endif
%}"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/journals"
>
Journals
</a>
{% if processing == 0 %}
{% if processing == 0 or processing == "0" %}
<a
type=
"button"
class=
"btn btn-default {% if view == "
terms
"
%}
active
{%
endif
%}"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/terms"
>
Terms (Bêta)
</a>
{% endif %}
</center>
...
...
tests/ngramstable/views.py
View file @
39b31af4
...
...
@@ -122,7 +122,7 @@ def get_ngrams(request , project_id , corpus_id ):
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'user'
:
request
.
user
.
username
,
'user'
:
request
.
user
,
'date'
:
date
,
'project'
:
project
,
'corpus'
:
corpus
,
...
...
@@ -187,7 +187,7 @@ def get_journals(request , project_id , corpus_id ):
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'user'
:
request
.
user
.
username
,
'user'
:
request
.
user
,
'date'
:
date
,
'project'
:
project
,
'corpus'
:
corpus
,
...
...
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