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
3245de9a
Commit
3245de9a
authored
Nov 12, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
650c8fea
c4ed35c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
4 deletions
+51
-4
ngrams.py
rest_v1_0/ngrams.py
+27
-0
urls.py
rest_v1_0/urls.py
+2
-1
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+22
-3
No files found.
rest_v1_0/ngrams.py
View file @
3245de9a
...
...
@@ -469,6 +469,33 @@ class Keep(APIView):
"""
renderer_classes
=
(
JSONRenderer
,)
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
def
get
(
self
,
request
,
corpus_id
):
print
(
""
)
print
(
""
)
print
(
""
)
print
(
"in HTTP/GET Keep():"
)
print
(
""
)
# list_id = session.query(Node).filter(Node.id==list_id).first()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
print
(
"corpus:"
,
corpus
)
node_mapList
=
get_or_create_node
(
nodetype
=
'MapList'
,
corpus
=
corpus
)
print
(
"node_mapList:"
,
node_mapList
)
nodes_in_map
=
session
.
query
(
NodeNgram
)
.
filter
(
NodeNgram
.
node_id
==
node_mapList
.
id
)
.
all
()
results
=
{}
for
node
in
nodes_in_map
:
print
(
node
)
results
[
node
.
ngram_id
]
=
True
# ngram_2del = [int(i) for i in ngram_ids.split('+')]
# ngram_2del = session.query(NodeNgram).filter(NodeNgram.node_id==node_mapList.id , NodeNgram.ngram_id.in_(ngram_2del) ).all()
# for map_node in ngram_2del:
# session.delete(map_node)
# session.commit()
print
(
""
)
print
(
""
)
print
(
""
)
return
JsonHttpResponse
(
results
)
def
put
(
self
,
request
,
list_id
,
ngram_ids
):
"""
...
...
rest_v1_0/urls.py
View file @
3245de9a
...
...
@@ -19,7 +19,8 @@ urlpatterns = patterns('',
# NGRAMS table & annotations
url
(
r'node/(\d+)/ngrams$'
,
ngrams
.
Ngrams
.
as_view
()),
url
(
r'node/(\d+)/ngrams/group$'
,
ngrams
.
Group
.
as_view
()),
url
(
r'node/(?P<list_id>[0-9]+)/ngrams/keep/(?P<ngram_ids>[0-9,\+]+)+$'
,
ngrams
.
Keep
.
as_view
()),
url
(
r'node/(\d+)/ngrams/keep$'
,
ngrams
.
Keep
.
as_view
()),
# url(r'node/(?P<list_id>[0-9]+)/ngrams/keep/(?P<ngram_ids>[0-9,\+]+)+$' , ngrams.Keep.as_view()),
url
(
r'node/(?P<list_id>[0-9]+)/ngrams/(?P<ngram_ids>[0-9,\+]+)+$'
,
views
.
NgramEdit
.
as_view
()),
url
(
r'node/(\d+)/ngrams/list$'
,
ngrams
.
List
.
as_view
()),
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
3245de9a
...
...
@@ -536,6 +536,7 @@ function CRUD( parent_id , action , nodes , args , http_method ) {
console
.
log
(
http_method
+
" : "
+
action
)
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
console
.
log
(
the_url
)
if
(
nodes
.
length
>
0
||
Object
.
keys
(
args
).
length
>
0
)
{
$
.
ajax
({
method
:
http_method
,
...
...
@@ -617,7 +618,7 @@ function Main_test( data , initial) {
"flag"
:
false
,
"group_plus"
:
true
,
"group_blocked"
:
false
,
"state"
:
0
"state"
:
(
le_ngram
.
map
)?
1
:
0
}
AjaxRecords
.
push
(
node_info
)
...
...
@@ -812,8 +813,9 @@ function getIDFromURL( item ) {
// [ = = = = = = = = = = INIT = = = = = = = = = = ]
var
corpus_id
=
getIDFromURL
(
"corpus"
)
var
url1
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams/group"
,
url2
=
window
.
location
.
href
+
"/ngrams.json"
;
var
ngrams_groups
,
ngrams_data
;
url2
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams/keep"
,
url3
=
window
.
location
.
href
+
"/ngrams.json"
;
var
ngrams_groups
,
ngrams_map
,
ngrams_data
;
$
.
when
(
$
.
ajax
({
type
:
"GET"
,
...
...
@@ -828,6 +830,15 @@ $.when(
type
:
"GET"
,
url
:
url2
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
ngrams_map
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
}),
$
.
ajax
({
type
:
"GET"
,
url
:
url3
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
ngrams_data
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"second ajax, exception!: "
+
exception
.
status
)
...
...
@@ -858,6 +869,14 @@ $.when(
ngrams_data
.
ngrams
=
ngrams_data_
;
}
if
(
Object
.
keys
(
ngrams_map
).
length
>
0
)
{
for
(
var
i
in
ngrams_data
.
ngrams
)
{
if
(
ngrams_map
[
ngrams_data
.
ngrams
[
i
].
id
])
{
ngrams_data
.
ngrams
[
i
][
"map"
]
=
true
}
}
}
// Building the Score-Selector
var
FirstScore
=
ngrams_data
.
scores
.
initial
...
...
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