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
72238540
Commit
72238540
authored
Oct 15, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] adding social score when ngrams added to a list.
parent
7ec54470
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
views.py
annotations/views.py
+13
-8
No files found.
annotations/views.py
View file @
72238540
...
...
@@ -13,7 +13,7 @@ from rest_framework.exceptions import APIException
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
node.models
import
Node
from
gargantext_web.db
import
*
from
gargantext_web.db
import
session
,
cache
,
Node
,
NodeNgram
from
ngram.lists
import
listIds
,
listNgramIds
...
...
@@ -68,12 +68,17 @@ class NgramEdit(APIView):
Edit an existing NGram in a given list
"""
list_id
=
int
(
list_id
)
list_node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
list_id
)
.
first
()
# TODO add 1 for MapList social score ?
if
list_node
.
type_id
==
cache
.
NodeType
[
'MiamList'
]:
weight
=
1.0
elif
list_node
.
type_id
==
cache
.
NodeType
[
'StopList'
]:
weight
=-
1.0
# TODO remove the node_ngram from another conflicting list
# FIXME session.query(Node_Ngram).filter(Node_Ngram.ngram_id==ngram_id).delete()
# add the ngram to the list
for
ngram_id
in
ngram_ids
.
split
(
'+'
):
ngram_id
=
int
(
ngram_id
)
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
=
weight
)
session
.
add
(
node_ngram
)
session
.
commit
()
...
...
@@ -90,9 +95,9 @@ class NgramEdit(APIView):
"""
for
ngram_id
in
ngram_ids
.
split
(
'+'
):
ngram_id
=
int
(
ngram_id
)
(
session
.
query
(
Node
_
Ngram
)
.
filter
(
Node
_
Ngram
.
node_id
==
list_id
)
.
filter
(
Node
_
Ngram
.
ngram_id
==
ngram_id
)
.
delete
()
(
session
.
query
(
NodeNgram
)
.
filter
(
NodeNgram
.
node_id
==
list_id
)
.
filter
(
NodeNgram
.
ngram_id
==
ngram_id
)
.
delete
()
)
session
.
commit
()
return
Response
(
None
,
204
)
...
...
@@ -130,7 +135,7 @@ class NgramCreate(APIView):
ngram_id
=
ngram
.
id
# create the new node_ngram relation
# TODO check existing Node_Ngram ?
node_ngram
=
Node
_
Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
node_ngram
=
NodeNgram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
session
.
add
(
node_ngram
)
session
.
commit
()
...
...
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