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
29d9e4a5
Commit
29d9e4a5
authored
Dec 17, 2014
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] tfidf, multiplequery
parent
f74f25ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
urls.py
gargantext_web/urls.py
+1
-1
views.py
gargantext_web/views.py
+9
-4
init.py
init/init.py
+2
-2
No files found.
gargantext_web/urls.py
View file @
29d9e4a5
...
...
@@ -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
()),
...
...
gargantext_web/views.py
View file @
29d9e4a5
...
...
@@ -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
=
ngram
sids
[
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
)
...
...
init/init.py
View file @
29d9e4a5
...
...
@@ -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
()
...
...
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