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
cbfe3da3
Commit
cbfe3da3
authored
Oct 15, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Editing ngrams (post/create, delete) with lists
parent
8c0e06ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
226 deletions
+20
-226
views.py
annotations/views.py
+20
-15
stopList.txt
ngram/stopList.txt
+0
-211
No files found.
annotations/views.py
View file @
cbfe3da3
...
@@ -12,7 +12,6 @@ from rest_framework.renderers import JSONRenderer
...
@@ -12,7 +12,6 @@ from rest_framework.renderers import JSONRenderer
from
rest_framework.exceptions
import
APIException
from
rest_framework.exceptions
import
APIException
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
node.models
import
Node
from
node.models
import
Node
from
gargantext_web.db
import
*
from
gargantext_web.db
import
*
from
ngram.lists
import
listIds
,
listNgramIds
from
ngram.lists
import
listIds
,
listNgramIds
...
@@ -30,7 +29,6 @@ def main(request, project_id, corpus_id, document_id):
...
@@ -30,7 +29,6 @@ def main(request, project_id, corpus_id, document_id):
'nodes_api_url'
:
urljoin
(
request
.
get_host
(),
'/api/'
),
'nodes_api_url'
:
urljoin
(
request
.
get_host
(),
'/api/'
),
},
context_instance
=
RequestContext
(
request
))
},
context_instance
=
RequestContext
(
request
))
class
NgramList
(
APIView
):
class
NgramList
(
APIView
):
"""Read and Write Annotations"""
"""Read and Write Annotations"""
renderer_classes
=
(
JSONRenderer
,)
renderer_classes
=
(
JSONRenderer
,)
...
@@ -59,7 +57,6 @@ class NgramList(APIView):
...
@@ -59,7 +57,6 @@ class NgramList(APIView):
}}
}}
return
Response
(
data
)
return
Response
(
data
)
class
NgramEdit
(
APIView
):
class
NgramEdit
(
APIView
):
"""
"""
Actions on one existing Ngram in one list
Actions on one existing Ngram in one list
...
@@ -67,34 +64,39 @@ class NgramEdit(APIView):
...
@@ -67,34 +64,39 @@ class NgramEdit(APIView):
renderer_classes
=
(
JSONRenderer
,)
renderer_classes
=
(
JSONRenderer
,)
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
def
post
(
self
,
request
,
list_id
,
ngram_id
):
def
post
(
self
,
request
,
list_id
,
ngram_id
s
):
"""
"""
Edit an existing NGram in a given list
Edit an existing NGram in a given list
"""
"""
list_id
=
int
(
list_id
)
list_id
=
int
(
list_id
)
ngram_id
=
int
(
ngram_id
)
# TODO remove the node_ngram from another conflicting list
# TODO remove the node_ngram from another conflicting list
# FIXME session.query(Node_Ngram).filter(Node_Ngram.ngram_id==ngram_id).delete()
# FIXME session.query(Node_Ngram).filter(Node_Ngram.ngram_id==ngram_id).delete()
# add the ngram to the list
# add the ngram to the list
node_ngram
=
Node_Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
for
ngram_id
in
ngram_ids
:
session
.
add
(
node_ngram
)
ngram_id
=
int
(
ngram_id
)
node_ngram
=
Node_Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
session
.
add
(
node_ngram
)
session
.
commit
()
session
.
commit
()
# return the response
# return the response
return
Response
({
return
Response
({
'uuid'
:
ngram_id
,
'uuid'
:
ngram_id
,
'list_id'
:
list_id
,
'list_id'
:
list_id
,
})
for
ngram_id
in
ngram_ids
})
def
delete
(
self
,
request
,
list_id
,
ngram_id
):
def
delete
(
self
,
request
,
list_id
,
ngram_id
s
):
"""
"""
Delete a ngram from a list
Delete a ngram from a list
"""
"""
session
.
query
(
Node_Ngram
)
.
filter
(
Node_Ngram
.
node_id
==
list_id
)
.
filter
(
Node_Ngram
.
ngram_id
==
ngram_id
)
.
delete
()
for
ngram_id
in
ngram_ids
:
(
session
.
query
(
Node_Ngram
)
.
filter
(
Node_Ngram
.
node_id
==
list_id
)
.
filter
(
Node_Ngram
.
ngram_id
==
ngram_id
)
.
delete
()
)
session
.
commit
()
session
.
commit
()
return
Response
(
None
,
204
)
return
Response
(
None
,
204
)
class
NgramCreate
(
APIView
):
class
NgramCreate
(
APIView
):
"""
"""
Create a new Ngram in one list
Create a new Ngram in one list
...
@@ -139,7 +141,6 @@ class NgramCreate(APIView):
...
@@ -139,7 +141,6 @@ class NgramCreate(APIView):
'list_id'
:
list_id
,
'list_id'
:
list_id
,
})
})
def
deleteMultiple
(
request
,
list_id
):
def
deleteMultiple
(
request
,
list_id
):
results
=
[
"hola"
,
"mundo"
]
results
=
[
"hola"
,
"mundo"
]
...
@@ -150,8 +151,14 @@ def deleteMultiple(request, list_id):
...
@@ -150,8 +151,14 @@ def deleteMultiple(request, list_id):
if
request
.
POST
:
if
request
.
POST
:
todel_ids
=
json
.
loads
(
request
.
POST
[
'to_delete'
])
todel_ids
=
json
.
loads
(
request
.
POST
[
'to_delete'
])
for
ngram_id
in
todel_ids
:
for
ngram_id
in
todel_ids
:
# add the ngram to the list if not already done
# add the ngram to the list if not already done
node_ngram
=
session
.
query
(
Node_Ngram
)
.
filter
(
Node_Ngram
.
node_id
==
list_id
)
.
filter
(
Node_Ngram
.
ngram_id
==
ngram_id
)
.
first
()
node_ngram
=
(
session
.
query
(
Node_Ngram
)
.
filter
(
Node_Ngram
.
node_id
==
list_id
)
.
filter
(
Node_Ngram
.
ngram_id
==
ngram_id
)
.
first
()
)
if
node_ngram
is
None
:
if
node_ngram
is
None
:
node_ngram
=
Node_Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
node_ngram
=
Node_Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
session
.
add
(
node_ngram
)
session
.
add
(
node_ngram
)
...
@@ -159,8 +166,6 @@ def deleteMultiple(request, list_id):
...
@@ -159,8 +166,6 @@ def deleteMultiple(request, list_id):
return
JsonHttpResponse
(
results
)
return
JsonHttpResponse
(
results
)
class
Document
(
APIView
):
class
Document
(
APIView
):
"""
"""
Read-only Document view, similar to /api/nodes/
Read-only Document view, similar to /api/nodes/
...
...
ngram/stopList.txt
deleted
100644 → 0
View file @
8c0e06ad
A
ABOUT
ABOVE
ACCORDING
ACROSS
ACTUAL
ADDED
AFTER
AGAINST
AHEAD
ALL
ALMOST
ALONE
ALONG
ALSO
AMONG
AMONGST
AN
AND
AND-OR
AND/OR
ANON
ANOTHER
ANY
ARE
ARISING
AROUND
AS
AT
AWARD
AWAY
BE
BECAUSE
BECOME
BECOMES
BEEN
BEFORE
BEHIND
BEING
BELOW
BEST
BETTER
BETWEEN
BEYOND
BIRTHDAY
BOTH
BUT
BY
CAN
CERTAIN
COME
COMES
COMING
COMPLETELY
CONCERNING
CONSIDER
CONSIDERED
CONSIDERING
CONSISTING
DE
DEPARTMENT
DER
DESPITE
DISCUSSION
DO
DOES
DOESNT
DOING
DOWN
DR
DU
DUE
DURING
EACH
EITHER
ESPECIALLY
ET
FEW
FOR
FORWARD
FROM
FURTHER
GET
GIVE
GIVEN
GIVING
HAS
HAVE
HAVING
HIS
HONOR
HOW
IN
INSIDE
INSTEAD
INTO
IS
IT
ITEMS
ITS
JUST
LET
LETS
LITTLE
LOOK
LOOKS
MADE
MAKE
MAKES
MAKING
MANY
MEET
MEETS
MORE
MOST
MUCH
MUST
MY
NEAR
NEARLY
NEXT
NOT
NOW
OF
OFF
ON
ONLY
ONTO
OR
OTHER
OUR
OUT
OUTSIDE
OVER
OVERALL
PER
POSSIBLY
PT
PUT
REALLY
REGARDING
REPRINTED
SAME
SEEN
SEVERAL
SHOULD
SHOWN
SINCE
SO-CALLED
SOME
SPP
STUDIES
STUDY
SUCH
TAKE
TAKEN
TAKES
TAKING
THAN
THAT
THE
THEIR
THEM
THEN
THERE
THEREFROM
THESE
THEY
THIS
THOSE
THROUGH
THROUGHOUT
TO
TOGETHER
TOWARD
TOWARDS
UNDER
UNDERGOING
UP
UPON
UPWARD
VARIOUS
VERSUS
VERY
VIA
VOL
VOLS
VS
WAS
WAY
WAYS
WE
WERE
WHAT
WHATS
WHEN
WHERE
WHICH
WHILE
WHITHER
WHO
WHOM
WHOS
WHOSE
WHY
WITH
WITHIN
WITHOUT
YET
YOU
YOUR
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