Commit 29d9e4a5 authored by PkSM3's avatar PkSM3

[UPDATE] tfidf, multiplequery

parent f74f25ee
......@@ -36,7 +36,7 @@ urlpatterns = patterns('',
url(r'^chart/corpus/(\d+)/data.csv$', views.send_csv),
url(r'^corpus/(\d+)/node_link.json$', views.node_link),
url(r'^corpus/(\d+)/adjacency.json$', views.adjacency),
url(r'^api/tfidf/(\d+)/(\d+)$', views.tfidf),
url(r'^api/tfidf/(\d+)/(\w+)$', views.tfidf),
url(r'^api$', gargantext_web.api.Root),
url(r'^api/nodes/(\d+)/children/metadata$', gargantext_web.api.NodesChildrenMetatadata.as_view()),
......
......@@ -532,11 +532,16 @@ def tfidf(request, corpus_id, ngram_id):
Takes IDs of corpus and ngram and returns list of relevent documents in json format
according to TFIDF score (order is decreasing).
"""
#it will receive something like: api/tfidf/corpus_id/NGRAM1aNGRAM2aNGRAM3aNGRAM4...
ngramsids = ngram_id.split("a")
corpus = Node.objects.get(id=corpus_id)
ngram = Ngram.objects.get(id=ngram_id)
ngram = Ngram.objects.get(id=ngramsids[0])#not used
node_node_ngrams = NodeNodeNgram.objects.filter(nodex=corpus, ngram=ngram).order_by('-score')
# print("********-1*******")
node_node_ngrams = NodeNodeNgram.objects.filter(nodex=corpus, ngram__in=ngramsids).order_by('-score')
# print(node_node_ngrams)
# print("********-1*******")
# only for tests
# TODO add test if metadata present
......@@ -548,7 +553,7 @@ def tfidf(request, corpus_id, ngram_id):
abstract=x.nodey.metadata['abstract'])
for x in node_node_ngrams]
data = json.dumps(tfidf_list)
data = json.dumps(tfidf_list[:6]) # max 6 papers
return JsonHttpResponse(data)
......
......@@ -26,9 +26,9 @@ french = Language.objects.get(iso2='fr')
try:
me = User.objects.get(username='alexandre')
me = User.objects.get(username='pksm3')
except:
me = User(username='alexandre')
me = User(username='pksm3')
me.save()
......
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