Commit edbcdfb3 authored by Elias's avatar Elias

Annotations : listNgramIds without a doc Id

parent bb02e267
...@@ -44,8 +44,8 @@ class NgramList(APIView): ...@@ -44,8 +44,8 @@ class NgramList(APIView):
list_id = listIds(user_id=request.user.id, corpus_id=int(corpus_id), typeList=list_type) list_id = listIds(user_id=request.user.id, corpus_id=int(corpus_id), typeList=list_type)
lists["%s" % list_id[0][0]] = list_type lists["%s" % list_id[0][0]] = list_type
# ngrams of list_id of corpus_id: # ngrams for the corpus_id (ignoring doc_id for the moment):
doc_ngram_list = listNgramIds(corpus_id=corpus_id, doc_id=doc_id, user_id=request.user.id) doc_ngram_list = listNgramIds(corpus_id=corpus_id, doc_id=None, user_id=request.user.id)
data = { '%s' % corpus_id : { data = { '%s' % corpus_id : {
'%s' % doc_id : [ '%s' % doc_id : [
{ {
...@@ -109,15 +109,14 @@ class NgramCreate(APIView): ...@@ -109,15 +109,14 @@ class NgramCreate(APIView):
create NGram in a given list create NGram in a given list
""" """
list_id = int(list_id) list_id = int(list_id)
# format the ngram's text # format the ngram's text
ngram_text = request.data.get('text', None) ngram_text = request.data.get('text', None)
if ngram_text is not None: if ngram_text is None:
ngram_text = ngram_text.strip().lower()
ngram_text = ' '.join(ngram_text.split())
else:
raise APIException("Could not create a new Ngram without one \ raise APIException("Could not create a new Ngram without one \
text key in the json body") text key in the json body")
ngram_text = ngram_text.strip().lower()
ngram_text = ' '.join(ngram_text.split())
# check if the ngram exists with the same terms # check if the ngram exists with the same terms
ngram = session.query(Ngram).filter(Ngram.terms == ngram_text).first() ngram = session.query(Ngram).filter(Ngram.terms == ngram_text).first()
if ngram is None: if ngram is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment