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
182788a2
Commit
182788a2
authored
Nov 09, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] excluding subforms, but backing up them with love and tender
parent
215784f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
19 deletions
+66
-19
ngrams.py
rest_v1_0/ngrams.py
+23
-1
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+43
-18
No files found.
rest_v1_0/ngrams.py
View file @
182788a2
...
...
@@ -10,6 +10,7 @@ from sqlalchemy.orm import aliased
import
datetime
import
copy
import
json
from
gargantext_web.validation
import
validate
,
ValidationException
...
...
@@ -280,7 +281,7 @@ class Group(APIView):
mainNode
=
-
1
mainNode_sinonims
=
[]
for
node
in
clique
:
groups
[
"nodes"
][
node
]
=
"nom_"
+
str
(
node
)
groups
[
"nodes"
][
node
]
=
False
node_outdeg
=
DG
.
out_degree
(
node
)
if
node_outdeg
>
max_deg
:
max_deg
=
node_outdeg
...
...
@@ -331,6 +332,27 @@ class Group(APIView):
else
:
raise
APIException
(
'Missing parameter: "{
\'
data
\'
: [
\'
source
\'
: Int,
\'
target
\'
: [Int]}"'
,
400
)
def
put
(
self
,
request
,
corpus_id
):
print
(
request
)
print
(
"= = = = = = = = = = = = = = "
)
print
(
"PUUUUUT:"
)
print
(
"corpus_id:"
,
corpus_id
)
group_id
=
self
.
get_group_id
(
corpus_id
)
ngrams_ngrams
=
(
session
.
query
(
NodeNgramNgram
)
.
filter
(
NodeNgramNgram
.
node_id
==
group_id
)
)
for
ng
in
ngrams_ngrams
:
print
(
ng
)
print
(
"= = = = = = = = = = = = = = "
)
print
(
"FIN"
)
# GroupsJSON = self.get( request , corpus_id )
# # Groups = json.loads(GroupsJSON[0].decode("utf-8"))
# Groups = {}
# for g in GroupsJSON:
# Groups = g.decode("utf-8")
# print(Groups)
return
JsonHttpResponse
(
True
,
201
)
class
Keep
(
APIView
):
"""
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
182788a2
...
...
@@ -508,13 +508,36 @@ $("#Save_All").click(function(){
var
nodes_2del
=
Object
.
keys
(
FlagsBuffer
[
"delete"
]).
map
(
Number
)
var
nodes_2keep
=
Object
.
keys
(
FlagsBuffer
[
"keep"
]).
map
(
Number
)
var
nodes_2group
=
FlagsBuffer
[
"group"
]
var
list_id
=
$
(
"#list_id"
).
val
()
var
nodes_2group
=
$
.
extend
({},
FlagsBuffer
[
"group"
]);
var
list_id
=
$
(
"#list_id"
).
val
()
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
CRUD
(
list_id
,
""
,
nodes_2del
,
"DELETE"
)
CRUD
(
list_id
,
"/keep"
,
nodes_2keep
,
"PUT"
)
// CRUD( list_id , "" , nodes_2del , "DELETE" )
// CRUD( list_id , "/keep" , nodes_2keep , "PUT" )
// CRUD( corpus_id , "/group" , nodes_2group , "PUT" )
console
.
log
(
nodes_2group
)
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams"
+
"/group"
$
.
ajax
({
method
:
"PUT"
,
data
:
nodes_2group
,
url
:
the_url
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
){
console
.
log
(
"PUT"
+
" ok!!"
)
console
.
log
(
nodes_2group
)
console
.
log
(
data
)
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found in #Save_All"
);
console
.
log
(
result
)
}
});
});
...
...
@@ -593,7 +616,7 @@ function Main_test( data , initial) {
var
node_info
=
{
"id"
:
le_ngram
.
id
,
"name"
:
le_ngram
.
name
,
"name"
:
le_ngram
.
id
+
"_"
+
le_ngram
.
name
,
"score"
:
le_ngram
.
scores
[
FirstScore
],
//le_ngram.scores.tfidf_sum / le_ngram.scores.occ_uniq,
"flag"
:
false
,
"group_plus"
:
true
,
...
...
@@ -818,19 +841,21 @@ $.when(
// Deleting subforms from the ngrams-table, clean start baby!
if
(
Object
.
keys
(
ngrams_groups
.
links
).
length
>
0
)
{
var
i
=
ngrams_data
.
ngrams
.
length
while
(
i
--
)
{
var
ng_id
=
ngrams_data
.
ngrams
[
i
].
id
if
(
ngrams_groups
.
links
[
ng_id
]
)
{
ngrams_data
.
ngrams
[
i
].
name
=
"*"
+
ngrams_data
.
ngrams
[
i
].
name
// to comment apres
for
(
var
j
in
ngrams_groups
.
links
[
ng_id
])
{
var
id_2del
=
ngrams_groups
.
links
[
ng_id
][
j
]
if
(
ngrams_data
.
ngrams
[
id_2del
]
)
{
ngrams_data
.
ngrams
.
splice
(
id_2del
,
1
);
}
}
}
}
var
subforms
=
{}
for
(
var
i
in
ngrams_groups
.
links
)
{
for
(
var
j
in
ngrams_groups
.
links
[
i
])
{
subforms
[
ngrams_groups
.
links
[
i
][
j
]
]
=
true
}
}
var
ngrams_data_
=
[]
for
(
var
i
in
ngrams_data
.
ngrams
)
{
if
(
subforms
[
ngrams_data
.
ngrams
[
i
].
id
])
{
ngrams_groups
[
"nodes"
][
ngrams_data
.
ngrams
[
i
].
id
]
=
ngrams_data
.
ngrams
[
i
]
}
else
{
ngrams_data_
.
push
(
ngrams_data
.
ngrams
[
i
]
)
}
}
ngrams_data
.
ngrams
=
ngrams_data_
;
}
...
...
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