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
3aa44ef1
Commit
3aa44ef1
authored
Jun 15, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'unstable-mat' of
ssh://delanoe.org:1979/gargantext
into unstable
parents
148fd8ef
c70206a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
21 deletions
+49
-21
lists.py
analysis/lists.py
+13
-1
app.js
annotations/static/annotations/app.js
+4
-3
http.js
annotations/static/annotations/http.js
+3
-3
urls.py
annotations/urls.py
+1
-1
views.py
annotations/views.py
+28
-13
No files found.
analysis/lists.py
View file @
3aa44ef1
...
@@ -65,6 +65,18 @@ class WeightedMatrix:
...
@@ -65,6 +65,18 @@ class WeightedMatrix:
"""
"""
pass
pass
def
__mul__
(
self
,
other
):
if
isinstance
(
other
,
Translations
):
result
=
WeightedMatrix
()
for
key1
,
key2_value
in
self
.
items
.
items
():
for
key2
,
value
in
self
.
items
:
result
.
items
[
other
.
items
.
get
(
key
,
key
)
]
=
value
else
:
raise
TypeError
return
result
class
UnweightedList
:
class
UnweightedList
:
...
@@ -181,7 +193,7 @@ class WeightedList:
...
@@ -181,7 +193,7 @@ class WeightedList:
for
key
,
value
in
self
.
items
:
for
key
,
value
in
self
.
items
:
result
.
items
[
result
.
items
[
other
.
items
.
get
(
key
,
key
)
other
.
items
.
get
(
key
,
key
)
]
=
value
]
+
=
value
else
:
else
:
raise
TypeError
raise
TypeError
return
result
return
result
...
...
annotations/static/annotations/app.js
View file @
3aa44ef1
...
@@ -204,11 +204,12 @@
...
@@ -204,11 +204,12 @@
// new annotation from selection
// new annotation from selection
NgramHttpService
.
post
(
NgramHttpService
.
post
(
{
{
'listId'
:
listId
,
'listId'
:
listId
'ngramId'
:
'new'
},
},
{
'annotation'
:
{
'text'
:
$scope
.
selection_text
.
trim
()}}
{
'annotation'
:
{
'text'
:
$scope
.
selection_text
.
trim
()}}
);
).
$promise
.
then
(
function
(
data
)
{
$rootScope
.
annotations
.
push
(
data
);
});
}
}
// hide selection highlighted text and the menu
// hide selection highlighted text and the menu
$
(
".text-panel"
).
removeClass
(
"selection"
);
$
(
".text-panel"
).
removeClass
(
"selection"
);
...
...
annotations/static/annotations/http.js
View file @
3aa44ef1
...
@@ -49,15 +49,15 @@
...
@@ -49,15 +49,15 @@
*/
*/
http
.
factory
(
'NgramHttpService'
,
function
(
$resource
)
{
http
.
factory
(
'NgramHttpService'
,
function
(
$resource
)
{
return
$resource
(
return
$resource
(
window
.
ANNOTATION_API_URL
+
'lists/:listId/ngrams/:ngramId
/
'
,
window
.
ANNOTATION_API_URL
+
'lists/:listId/ngrams/:ngramId'
,
{
{
listId
:
'@listId'
,
listId
:
'@listId'
,
ngramId
:
'@
ngramI
d'
ngramId
:
'@
i
d'
},
},
{
{
post
:
{
post
:
{
method
:
'POST'
,
method
:
'POST'
,
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
'
@ngramId
'
}
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
''
}
},
},
delete
:
{
delete
:
{
method
:
'DELETE'
,
method
:
'DELETE'
,
...
...
annotations/urls.py
View file @
3aa44ef1
...
@@ -5,5 +5,5 @@ from annotations import views
...
@@ -5,5 +5,5 @@ from annotations import views
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
url
(
r'^document/(?P<doc_id>[0-9]+)$'
,
views
.
Document
.
as_view
()),
# document view
url
(
r'^document/(?P<doc_id>[0-9]+)$'
,
views
.
Document
.
as_view
()),
# document view
url
(
r'^corpus/(?P<corpus_id>[0-9]+)/document/(?P<doc_id>[0-9]+)$'
,
views
.
NgramList
.
as_view
()),
# the list associated with an ngram
url
(
r'^corpus/(?P<corpus_id>[0-9]+)/document/(?P<doc_id>[0-9]+)$'
,
views
.
NgramList
.
as_view
()),
# the list associated with an ngram
url
(
r'^lists/(?P<list_id>[0-9]+)/ngrams
/(?P<ngram_id>[new0-9]+)
$'
,
views
.
NgramEdit
.
as_view
()),
#
url
(
r'^lists/(?P<list_id>[0-9]+)/ngrams
(?:/(?P<ngram_id>[0-9]+))?
$'
,
views
.
NgramEdit
.
as_view
()),
#
)
)
annotations/views.py
View file @
3aa44ef1
...
@@ -73,19 +73,34 @@ class NgramEdit(APIView):
...
@@ -73,19 +73,34 @@ class NgramEdit(APIView):
"""
"""
Add a ngram in a list
Add a ngram in a list
"""
"""
# TODO if Ngram is in miam-list, and adding it to stop-list, then remove it from the previous list
# TODO - if Ngram is in miam-list, and adding it to stop-list,
if
ngram_id
==
'new'
:
# then remove it from the previous list
ngram_dict
=
json
.
loads
(
request
.
POST
.
get
(
'annotation'
))
list_id
=
int
(
list_id
)
results
=
ngramList
(
'create'
,
list_id
,
ngram_ids
=
[
ngram_dict
[
'text'
]])
# format the ngram's text
else
:
ngram_text
=
request
.
data
.
get
(
'annotation'
,
{})
.
get
(
'text'
,
None
)
results
=
ngramList
(
'add'
,
list_id
,
ngram_ids
=
[
ngram_id
])
ngram_text
=
ngram_text
.
strip
()
.
lower
()
ngram_text
=
' '
.
join
(
ngram_text
.
split
())
return
Response
([{
# retrieve the ngram's id
'uuid'
:
ngram_id
,
ngram
=
session
.
query
(
Ngram
)
.
filter
(
Ngram
.
terms
==
ngram_text
)
.
first
()
'text'
:
ngram_text
,
if
ngram
is
None
:
'occurrences'
:
ngram_occurrences
,
ngram
=
Ngram
(
n
=
len
(
ngram_text
.
split
()),
terms
=
ngram_text
)
'list_id'
:
list_id
,
session
.
add
(
ngram
)
}
for
ngram_id
,
ngram_text
,
ngram_occurrences
in
results
])
session
.
commit
()
ngram_id
=
ngram
.
id
# 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
()
if
node_ngram
is
None
:
node_ngram
=
Node_Ngram
(
node_id
=
list_id
,
ngram_id
=
ngram_id
,
weight
=
1.0
)
session
.
add
(
node_ngram
)
session
.
commit
()
ngram_occurrences
=
node_ngram
.
weight
# return the response
return
Response
({
'uuid'
:
ngram_id
,
'text'
:
ngram_text
,
'occurrences'
:
ngram_occurrences
,
'list_id'
:
list_id
,
})
def
delete
(
self
,
request
,
list_id
,
ngram_id
):
def
delete
(
self
,
request
,
list_id
,
ngram_id
):
"""
"""
...
...
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