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
8715a750
Commit
8715a750
authored
Nov 17, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
9b970abf
7eac6741
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
21 deletions
+42
-21
ngrams.py
rest_v1_0/ngrams.py
+13
-13
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+29
-8
No files found.
rest_v1_0/ngrams.py
View file @
8715a750
...
...
@@ -99,7 +99,7 @@ class Ngrams(APIView):
'''
REST application to manage ngrams
Example :
http://localhost:8000/api/node/1444485/ngrams?format=json&score=tfidf,occ
urrence
s
http://localhost:8000/api/node/1444485/ngrams?format=json&score=tfidf,occs
'''
def
get
(
self
,
request
,
node_id
):
# query ngrams
...
...
@@ -134,9 +134,9 @@ class Ngrams(APIView):
# )
# for i in ngrams_query:
# print(i)
if
'occ
urrence
s'
in
the_score
:
occ
urrences
=
func
.
sum
(
Node_Ngram
.
weight
)
.
label
(
'occurrence
s'
)
ngrams_query
=
(
ngrams_query
.
add_column
(
occ
urrence
s
))
if
'occs'
in
the_score
:
occ
s
=
func
.
sum
(
Node_Ngram
.
weight
)
.
label
(
'occ
s'
)
ngrams_query
=
(
ngrams_query
.
add_column
(
occs
))
results
.
append
(
'occurences'
)
if
'tfidf'
in
the_score
:
...
...
@@ -170,8 +170,8 @@ class Ngrams(APIView):
results
.
append
(
'specificity'
)
order_query
=
request
.
GET
.
get
(
'order'
,
False
)
if
order_query
==
'occ
urrence
s'
:
ngrams_query
=
ngrams_query
.
order_by
(
desc
(
occ
urrence
s
))
if
order_query
==
'occs'
:
ngrams_query
=
ngrams_query
.
order_by
(
desc
(
occs
))
elif
order_query
==
'cvalue'
:
ngrams_query
=
ngrams_query
.
order_by
(
desc
(
Cvalue
.
score
))
elif
order_query
==
'tfidf'
:
...
...
@@ -241,18 +241,18 @@ class Ngrams(APIView):
output
=
[]
for
ngram
in
ngrams_query
[
offset
:
offset
+
limit
]:
info
=
{}
info
=
{
"scores"
:{}
}
try
:
info
[
"id"
]
=
ngram
.
id
except
:
pass
try
:
info
[
"
terms
"
]
=
ngram
.
terms
try
:
info
[
"
name
"
]
=
ngram
.
terms
except
:
pass
try
:
info
[
"
occurrences"
]
=
ngram
.
occurrence
s
try
:
info
[
"
scores"
][
"occ_uniq"
]
=
ngram
.
occ
s
except
:
pass
try
:
info
[
"tfidf"
]
=
ngram
.
tfidf
try
:
info
[
"
scores"
][
"
tfidf"
]
=
ngram
.
tfidf
except
:
pass
try
:
info
[
"cvalue"
]
=
ngram
.
cvalue
try
:
info
[
"
scores"
][
"
cvalue"
]
=
ngram
.
cvalue
except
:
pass
try
:
info
[
"specificity"
]
=
ngram
.
specificity
try
:
info
[
"s
cores"
][
"s
pecificity"
]
=
ngram
.
specificity
except
:
pass
output
.
append
(
info
)
...
...
@@ -344,7 +344,7 @@ class Group(APIView):
# print(i)
ngrams
=
[
int
(
i
)
for
i
in
list
(
groups
[
"nodes"
]
.
keys
())]
groups
[
"nodes"
]
=
get_occtfidf
(
ngrams
,
request
.
user
.
id
,
corpus_id
,
"Group"
)
#
groups["nodes"] = get_occtfidf( ngrams , request.user.id , corpus_id , "Group")
return
JsonHttpResponse
(
groups
)
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
8715a750
...
...
@@ -880,11 +880,12 @@ function getIDFromURL( item ) {
}
// [ = = = = = = = = = = 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
/list/stop
"
,
var
url0
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams
?format=json&score=tfidf,occs&list=stop&limit=999999
"
,
url1
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams/group"
,
url2
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams
/keep
"
,
url3
=
window
.
location
.
href
+
"/ngrams.json
"
;
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
"
;
var
NGrams
=
{
"group"
:
{},
"stop"
:
{},
...
...
@@ -899,7 +900,11 @@ $.when(
type
:
"GET"
,
url
:
url0
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"stop"
]
=
data
},
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
)
}
...
...
@@ -908,7 +913,9 @@ $.when(
type
:
"GET"
,
url
:
url1
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"group"
]
=
data
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"group"
]
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
...
...
@@ -917,7 +924,11 @@ $.when(
type
:
"GET"
,
url
:
url2
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"map"
]
=
data
},
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
)
}
...
...
@@ -926,7 +937,18 @@ $.when(
type
:
"GET"
,
url
:
url3
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
NGrams
[
"main"
]
=
data
},
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
)
}
...
...
@@ -963,7 +985,6 @@ $.when(
}
}
// Building the Score-Selector //NGrams["scores"]
var
FirstScore
=
NGrams
[
"main"
].
scores
.
initial
var
possible_scores
=
Object
.
keys
(
NGrams
[
"main"
].
ngrams
[
0
].
scores
);
...
...
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