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
92cad524
Commit
92cad524
authored
Apr 17, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] corpora single-comparison
parent
ad48332c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
10 deletions
+151
-10
urls.py
gargantext_web/urls.py
+2
-2
views.py
gargantext_web/views.py
+74
-2
views_optimized.py
gargantext_web/views_optimized.py
+5
-0
explorer.html
templates/explorer.html
+69
-5
project.html
templates/project.html
+1
-1
No files found.
gargantext_web/urls.py
View file @
92cad524
...
@@ -79,8 +79,8 @@ urlpatterns = patterns('',
...
@@ -79,8 +79,8 @@ urlpatterns = patterns('',
url
(
r'^tests/istextquery$'
,
pubmedscrapper
.
getGlobalStatsISTEXT
),
# api/query?type=istext ?
url
(
r'^tests/istextquery$'
,
pubmedscrapper
.
getGlobalStatsISTEXT
),
# api/query?type=istext ?
url
(
r'^tests/pubmedquery$'
,
pubmedscrapper
.
getGlobalStats
),
url
(
r'^tests/pubmedquery$'
,
pubmedscrapper
.
getGlobalStats
),
url
(
r'^tests/project/(\d+)/pubmedquery/go$'
,
pubmedscrapper
.
doTheQuery
),
url
(
r'^tests/project/(\d+)/pubmedquery/go$'
,
pubmedscrapper
.
doTheQuery
),
url
(
r'^tests/project/(\d+)/ISTEXquery/go$'
,
pubmedscrapper
.
testISTEX
)
url
(
r'^tests/project/(\d+)/ISTEXquery/go$'
,
pubmedscrapper
.
testISTEX
)
,
url
(
r'^tests/paginator/project/(\d+)/corpus/(\d+)/$'
,
views
.
newpaginatorJSON
)
)
)
...
...
gargantext_web/views.py
View file @
92cad524
...
@@ -27,6 +27,7 @@ from collections import defaultdict
...
@@ -27,6 +27,7 @@ from collections import defaultdict
from
parsing.FileParsers
import
*
from
parsing.FileParsers
import
*
import
os
import
os
import
json
# SOME FUNCTIONS
# SOME FUNCTIONS
...
@@ -305,6 +306,56 @@ def corpus(request, project_id, corpus_id):
...
@@ -305,6 +306,56 @@ def corpus(request, project_id, corpus_id):
return
HttpResponse
(
html
)
return
HttpResponse
(
html
)
def
newpaginatorJSON
(
request
,
project_id
,
corpus_id
):
results
=
[
"hola"
,
"mundo"
]
# t = get_template('tests/newpag/thetable.html')
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
type_document_id
=
cache
.
NodeType
[
'Document'
]
.
id
documents
=
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_document_id
)
.
all
()
filtered_docs
=
[]
for
doc
in
documents
:
if
"publication_date"
in
doc
.
metadata
:
try
:
realdate
=
doc
.
metadata
[
"publication_date"
]
.
split
(
" "
)[
0
]
# in database is = (year-month-day = 2015-01-06 00:00:00 = 06 jan 2015 00 hrs)
realdate
=
datetime
.
datetime
.
strptime
(
str
(
realdate
),
'
%
Y-
%
m-
%
d'
)
.
date
()
# finalform = (yearmonthday = 20150106 = 06 jan 2015)
# doc.date = realdate
resdict
=
{}
resdict
[
"id"
]
=
doc
.
id
resdict
[
"date"
]
=
realdate
resdict
[
"name"
]
=
doc
.
name
filtered_docs
.
append
(
resdict
)
except
Exception
as
e
:
print
(
"pag2 error01 detail:"
,
e
)
print
(
"pag2 error01 doc:"
,
doc
)
results
=
sorted
(
filtered_docs
,
key
=
lambda
x
:
x
[
"date"
])
for
i
in
results
:
i
[
"date"
]
=
i
[
"date"
]
.
strftime
(
"
%
Y-
%
m-
%
d"
)
finaldict
=
{
"records"
:
results
,
"queryRecordCount"
:
10
,
"totalRecordCount"
:
len
(
results
)
}
return
JsonHttpResponse
(
finaldict
)
# html = t.render(Context({\
# # 'user': user,\
# # 'date': date,\
# 'project': project_id,\
# 'corpus' : corpus_id,\
# # 'documents': results,\
# # 'number' : len(filtered_docs),\
# # 'dates' : chart,\
# }))
# return HttpResponse(html)
# Im using this actually
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
def
subcorpus
(
request
,
project_id
,
corpus_id
,
start
,
end
):
def
subcorpus
(
request
,
project_id
,
corpus_id
,
start
,
end
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
...
@@ -380,7 +431,6 @@ def subcorpus(request, project_id, corpus_id, start , end ):
...
@@ -380,7 +431,6 @@ def subcorpus(request, project_id, corpus_id, start , end ):
return
HttpResponse
(
html
)
return
HttpResponse
(
html
)
import
json
def
subcorpusJSON
(
request
,
project_id
,
corpus_id
,
start
,
end
):
def
subcorpusJSON
(
request
,
project_id
,
corpus_id
,
start
,
end
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
...
@@ -559,11 +609,34 @@ def graph(request, project_id, corpus_id):
...
@@ -559,11 +609,34 @@ def graph(request, project_id, corpus_id):
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
user_id
=
cache
.
User
[
request
.
user
.
username
]
.
id
project_type_id
=
cache
.
NodeType
[
'Project'
]
.
id
corpus_type_id
=
cache
.
NodeType
[
'Corpus'
]
.
id
results
=
{}
projs
=
session
.
query
(
Node
)
.
filter
(
Node
.
type_id
==
project_type_id
)
.
all
()
for
i
in
projs
:
# print(i.id , i.name)
if
i
.
id
not
in
results
:
results
[
i
.
id
]
=
{}
results
[
i
.
id
][
"proj_name"
]
=
i
.
name
results
[
i
.
id
][
"corpuses"
]
=
[]
corpuses
=
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
i
.
id
,
Node
.
type_id
==
corpus_type_id
)
.
all
()
for
j
in
corpuses
:
if
int
(
j
.
id
)
!=
int
(
corpus_id
):
info
=
{
"id"
:
j
.
id
,
"name"
:
j
.
name
}
results
[
i
.
id
][
"corpuses"
]
.
append
(
info
)
# print("\t",j.id , j.name)
import
pprint
pprint
.
pprint
(
results
)
html
=
t
.
render
(
Context
({
\
html
=
t
.
render
(
Context
({
\
'user'
:
user
,
\
'user'
:
user
,
\
'date'
:
date
,
\
'date'
:
date
,
\
'corpus'
:
corpus
,
\
'corpus'
:
corpus
,
\
'project'
:
project
,
\
'project'
:
project
,
\
'corpusinfo'
:
results
,
\
'graphfile'
:
"hola_mundo"
,
\
'graphfile'
:
"hola_mundo"
,
\
}))
}))
...
@@ -667,7 +740,6 @@ def send_csv(request, corpus_id):
...
@@ -667,7 +740,6 @@ def send_csv(request, corpus_id):
# To get the data
# To get the data
from
gargantext_web.api
import
JsonHttpResponse
from
gargantext_web.api
import
JsonHttpResponse
from
analysis.functions
import
get_cooc
from
analysis.functions
import
get_cooc
import
json
def
node_link
(
request
,
corpus_id
):
def
node_link
(
request
,
corpus_id
):
'''
'''
Create the HttpResponse object with the node_link dataset.
Create the HttpResponse object with the node_link dataset.
...
...
gargantext_web/views_optimized.py
View file @
92cad524
...
@@ -199,8 +199,12 @@ def tfidf(request, corpus_id, ngram_ids):
...
@@ -199,8 +199,12 @@ def tfidf(request, corpus_id, ngram_ids):
.
order_by
(
func
.
sum
(
NodeNodeNgram
.
score
)
.
desc
())
.
order_by
(
func
.
sum
(
NodeNodeNgram
.
score
)
.
desc
())
.
limit
(
limit
)
.
limit
(
limit
)
)
)
# print("\n")
# print("in TFIDF:")
# print("\tcorpus_id:",corpus_id)
# convert query result to a list of dicts
# convert query result to a list of dicts
for
node
,
score
in
nodes_query
:
for
node
,
score
in
nodes_query
:
print
(
"
\t
corpus:"
,
corpus_id
,
"
\t
"
,
node
.
name
)
node_dict
=
{
node_dict
=
{
'id'
:
node
.
id
,
'id'
:
node
.
id
,
'score'
:
score
,
'score'
:
score
,
...
@@ -210,5 +214,6 @@ def tfidf(request, corpus_id, ngram_ids):
...
@@ -210,5 +214,6 @@ def tfidf(request, corpus_id, ngram_ids):
node_dict
[
key
]
=
node
.
metadata
[
key
]
node_dict
[
key
]
=
node
.
metadata
[
key
]
nodes_list
.
append
(
node_dict
)
nodes_list
.
append
(
node_dict
)
# print("= = = = = = = = \n")
data
=
json
.
dumps
(
nodes_list
)
data
=
json
.
dumps
(
nodes_list
)
return
JsonHttpResponse
(
data
)
return
JsonHttpResponse
(
data
)
templates/explorer.html
View file @
92cad524
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap-theme
.
min
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap-theme
.
min
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
jquery
/
jquery-ui
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
jquery
/
jquery-ui
.
css
"
%}"
media=
"screen"
>
<
link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
bootstrap
/
css
/
bootstrap
.
css
"
%}"
media=
"screen"
>
<
!-- <link rel="stylesheet" href="{% static "js/libs/bootstrap/css/bootstrap.css" %}" media="screen"> --
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
freshslider
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
freshslider
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
custom
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
custom
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
sidebar
.
css
"
%}"
media=
"screen"
>
<link
rel=
"stylesheet"
href=
"{% static "
js
/
libs
/
css2
/
sidebar
.
css
"
%}"
media=
"screen"
>
...
@@ -260,13 +260,13 @@
...
@@ -260,13 +260,13 @@
</div>
</div>
<
div
id=
"topPapers"
></div
>
<
!-- <div id="topPapers"></div> --
>
<!--
<div
id=
"tab-container-top"
class=
'tab-container'
>
<div
id=
"tab-container-top"
class=
'tab-container'
>
<ul
class=
'etabs'
>
<ul
class=
'etabs'
>
<li
id=
"tabmed"
class=
'tab active'
><a
href=
"#tabs3"
>
Medline Pubs
</a></li>
<li
id=
"tabmed"
class=
'tab active'
><a
href=
"#tabs3"
>
Medline Pubs
</a></li>
<li id="tabgps" class='tab'><a
href="#tabs4
">+</a></li>
<li
id=
"tabgps"
class=
'tab'
><a
onclick=
"$('#corpuses').modal('show');
"
>
+
</a></li>
</ul>
</ul>
<div
class=
'panel-container'
>
<div
class=
'panel-container'
>
...
@@ -278,7 +278,7 @@
...
@@ -278,7 +278,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
-->
...
@@ -350,6 +350,70 @@
...
@@ -350,6 +350,70 @@
</div>
</div>
<div
id=
"corpuses"
class=
"modal fade"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
>
Corpus Comparison
</h4>
</div>
<div
class=
"modal-body form-horizontal"
>
Chose another corpus to compare with:
<div
class=
"form-group"
>
<label
class=
"col-lg-2 control-label"
>
</label>
<div
class=
"col-lg-10"
>
<form
id=
"corpuses_form"
role=
"form"
>
<ul>
{% if corpusinfo %}
{% for k1, v1 in corpusinfo.items %}
{% if v1.corpuses|length > 0 %}
<br><li><a
href=
"/project/{{k1}}/"
>
{{v1.proj_name}}
</a><br>
<ul
style=
"list-style-type: none;"
>
{% for c in v1.corpuses %}
<li>
<div
class=
"radio"
>
<label><input
type=
"radio"
id=
"{{c.id}}"
name=
"optradio"
>
<a
href=
"/project/{{k1}}/corpus/{{c.id}}/"
>
{{c.name}}
</a>
</label>
</div>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
</form>
</div>
</div>
</div>
<div
class=
"modal-footer"
>
<button
id=
"closecorpuses"
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Close
</button>
<button
type=
"button"
class=
"btn btn-primary"
onclick=
'printCorpuses();'
>
Add Tab
</button>
</div>
</div>
</div>
</div>
<div
id=
"modalloader"
class=
"modal fade"
>
<div
id=
"modalloader"
class=
"modal fade"
>
<div
id=
"loader"
class=
"loader"
>
<div
id=
"loader"
class=
"loader"
>
<img
src=
"{% static "
js
/
libs
/
img2
/
loader
.
gif
"
%}"
></img>
<img
src=
"{% static "
js
/
libs
/
img2
/
loader
.
gif
"
%}"
></img>
...
...
templates/project.html
View file @
92cad524
...
@@ -282,7 +282,7 @@
...
@@ -282,7 +282,7 @@
$
(
"#simpleloader"
).
html
(
'<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>'
)
$
(
"#simpleloader"
).
html
(
'<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>'
)
$
(
"#submit_thing"
).
prop
(
'onclick'
,
null
);
$
(
"#submit_thing"
).
prop
(
'onclick'
,
null
);
var
theType
=
$
(
"#id_type option:selected"
).
html
();
var
theType
=
$
(
"#id_type option:selected"
).
html
();
if
(
theType
==
"
pubmed
"
)
doTheQuery
();
if
(
theType
==
"
Pubmed (xml format)
"
)
doTheQuery
();
if
(
theType
==
"istex"
)
{
if
(
theType
==
"istex"
)
{
testISTEX
(
origQuery
.
replace
(
" "
,
"+"
),
1000
)
testISTEX
(
origQuery
.
replace
(
" "
,
"+"
),
1000
)
}
}
...
...
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