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
67eb3782
Commit
67eb3782
authored
Jun 16, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Plain Diff
[UPDATE] merge conflict fixed, but is just a disaster
parents
4e518ff0
d779511a
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
696 additions
and
209 deletions
+696
-209
functions.py
analysis/functions.py
+13
-3
app.css
annotations/static/annotations/app.css
+3
-1
app.js
annotations/static/annotations/app.js
+18
-13
selection_tpl.html
annotations/static/annotations/selection_tpl.html
+2
-3
main.html
annotations/templates/annotations/main.html
+12
-10
gargantext.ini
gargantext.ini
+4
-0
about.py
gargantext_web/about.py
+2
-2
corpus_views.py
gargantext_web/corpus_views.py
+380
-0
urls.py
gargantext_web/urls.py
+24
-4
views.py
gargantext_web/views.py
+85
-19
lists.py
ngram/lists.py
+2
-2
documents.html
templates/corpus/documents.html
+7
-29
journals.html
templates/corpus/journals.html
+3
-74
menu.html
templates/corpus/menu.html
+130
-0
terms.html
templates/corpus/terms.html
+1
-48
menu.html
templates/menu.html
+9
-0
project.html
templates/project.html
+1
-1
No files found.
analysis/functions.py
View file @
67eb3782
...
...
@@ -21,7 +21,10 @@ def create_synonymes(user, corpus):
size
=
1000
def
create_whitelist
(
user
,
corpus_id
,
size
=
size
,
count_min
=
2
):
def
create_whitelist
(
user
,
corpus_id
,
size
=
size
,
count_min
=
2
,
miam_id
=
None
):
if
miam_id
is
None
:
PrintException
()
cursor
=
connection
.
cursor
()
whitelist_type_id
=
cache
.
NodeType
[
'WhiteList'
]
.
id
...
...
@@ -53,10 +56,14 @@ def create_whitelist(user, corpus_id, size=size, count_min=2):
node_node_ngram AS nngX ON nngX.node_id = n.id
INNER JOIN
node_ngram AS ngX ON ngX.id = nngX.ngram_id
INNER JOIN
node_node_ngram AS miam ON ngX.id = miam.ngram_id
WHERE
n.parent_id =
%
d
AND
n.type_id =
%
d
AND
miam.node_id =
%
d
AND
ngX.n >= 2
AND
...
...
@@ -72,7 +79,7 @@ def create_whitelist(user, corpus_id, size=size, count_min=2):
LIMIT
%
d
;
"""
%
(
white_list
.
id
,
int
(
corpus_id
),
int
(
type_document_id
),
count_min
,
size
)
"""
%
(
white_list
.
id
,
int
(
corpus_id
),
int
(
type_document_id
),
int
(
miam_id
),
count_min
,
size
)
# print("PRINTING QYERY OF WHITELIST:")
# print(query_whitelist)
cursor
.
execute
(
query_whitelist
)
...
...
@@ -155,6 +162,7 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size=
from
gargantext_web.api
import
JsonHttpResponse
from
analysis.louvain
import
best_partition
from
ngram.lists
import
listIds
#print(corpus_id, cooc_id)
...
...
@@ -168,7 +176,9 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size=
if
session
.
query
(
Node
)
.
filter
(
Node
.
type_id
==
type_cooc_id
,
Node
.
parent_id
==
corpus_id
)
.
first
()
is
None
:
print
(
"Coocurrences do not exist yet, create it."
)
whitelist
=
create_whitelist
(
request
.
user
,
corpus_id
=
corpus_id
,
size
=
size
)
miam_id
=
listIds
(
typeList
=
'MiamList'
,
user_id
=
request
.
user
.
id
,
corpus_id
=
corpus_id
)[
0
][
0
]
whitelist
=
create_whitelist
(
request
.
user
,
corpus_id
=
corpus_id
,
size
=
size
,
miam_id
=
miam_id
)
cooccurrence_node_id
=
create_cooc
(
user
=
request
.
user
,
corpus_id
=
corpus_id
,
whitelist
=
whitelist
,
size
=
size
)
else
:
cooccurrence_node_id
=
session
.
query
(
Node
.
id
)
.
filter
(
Node
.
type_id
==
type_cooc_id
,
Node
.
parent_id
==
corpus_id
)
.
first
()
...
...
annotations/static/annotations/app.css
View file @
67eb3782
...
...
@@ -60,7 +60,7 @@
}
.keyword-container
{
max-width
:
200px
;
/*display: inline-block;*/
}
.keyword
{
...
...
@@ -71,6 +71,8 @@
display
:
inline-block
;
float
:
left
;
padding
:
5px
;
margin
:
.25em
;
box-shadow
:
.2em
.2em
.1em
rgba
(
0
,
0
,
0
,
.125
);
}
.words-pagination
{
...
...
annotations/static/annotations/app.js
View file @
67eb3782
...
...
@@ -24,18 +24,18 @@
// TODO use the tooltip ?
$scope
.
onDeleteClick
=
function
()
{
NgramHttpService
.
delete
({
'listId'
:
$scope
.
keyword
.
list_id
,
'ngramId'
:
$scope
.
keyword
.
uuid
}).
$promise
.
then
(
function
(
data
)
{
NgramListHttpService
.
get
(
{
'corpusId'
:
$rootScope
.
corpusId
,
'docId'
:
$rootScope
.
docId
}
).
$promise
.
then
(
function
(
data
)
{
$rootScope
.
annotations
=
data
[
$rootScope
.
corpusId
.
toString
()][
$rootScope
.
docId
.
toString
()]
;
$rootScope
.
lists
=
data
[
$rootScope
.
corpusId
.
toString
()][
'lists'
];
});
'listId'
:
$scope
.
keyword
.
list_id
,
'ngramId'
:
$scope
.
keyword
.
uuid
}).
$promise
.
then
(
function
(
data
)
{
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
if
(
element
.
list_id
==
$scope
.
keyword
.
list_id
&&
element
.
uuid
==
$scope
.
keyword
.
uuid
)
{
$rootScope
.
annotations
.
splice
(
index
,
1
);
return
false
;
}
});
});
}
;
}]);
}
}]);
window
.
annotationsApp
.
controller
(
'AnnotationController'
,
[
'$scope'
,
'$rootScope'
,
'$element'
,
...
...
@@ -324,8 +324,13 @@
$rootScope
);
console
.
log
(
$rootScope
.
annotations
.
length
);
console
.
log
(
counter
);
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
if
(
element
.
list_id
==
$rootScope
.
stopListId
)
{
$scope
.
extra_stoplist
.
push
(
element
);
}
else
if
(
element
.
list_id
==
$rootScope
.
miamListId
)
{
$scope
.
extra_miamlist
.
push
(
element
);
}
});
angular
.
element
(
'#full-text'
).
html
(
result
.
fullTextHtml
);
angular
.
element
(
'#abstract-text'
).
html
(
result
.
abstractTextHtml
);
...
...
annotations/static/annotations/selection_tpl.html
View file @
67eb3782
<ul
class=
"noselection"
>
<li>
{[{level}]}
<span
ng-if=
"category !== null"
>
{[{category}]}
</span></li>
<li
class=
"miamword"
ng-if=
"local_miamlist === true"
ng-click=
"onClick($event, 'post', miamListId, 'local')"
>
add to miam-list
</li>
<li
class=
"miamword"
ng-if=
"local_miamlist === false"
ng-click=
"onClick($event, 'delete', miamListId, 'local')"
>
remove from miam-list
</li>
<li
class=
"stopword"
ng-if=
"local_stoplist === true"
ng-click=
"onClick($event, 'post', stopListId, 'local')"
>
add to
local
stop-list
</li>
<li
class=
"stopword"
ng-if=
"local_stoplist === false"
ng-click=
"onClick($event, 'delete', stopListId, 'local')"
>
remove from
local
stop-list
</li>
<li
class=
"stopword"
ng-if=
"local_stoplist === true"
ng-click=
"onClick($event, 'post', stopListId, 'local')"
>
add to stop-list
</li>
<li
class=
"stopword"
ng-if=
"local_stoplist === false"
ng-click=
"onClick($event, 'delete', stopListId, 'local')"
>
remove from stop-list
</li>
<!--<li class="stopword" ng-if="global_stoplist === true" ng-click="onClick($event, 'post', 'stoplist', 'global')">add to global stop-list</li>
<li class="stopword" ng-if="global_stoplist === false" ng-click="onClick($event, 'delete', 'stoplist', 'global')">remove from global stop-list</li>-->
...
...
annotations/templates/annotations/main.html
View file @
67eb3782
...
...
@@ -24,13 +24,13 @@
<div
class=
"row-fluid main-panel"
ng-controller=
"IntraTextController"
>
<div
class=
"col-md-4 col-xs-4 tabbable words-panel"
>
<ul
class=
"nav nav-pills nav-justified"
>
<li
class=
"active"
><a
href=
"#tab1"
data-toggle=
"tab"
>
<span
class=
"glyphicon glyphicon-tags"
></span>
Miamwords
</a></li>
<
!--<li><a href="#tab2" data-toggle="tab">Local stopwords</a></li>--
>
<li
class=
"active"
><a
href=
"#tab1"
data-toggle=
"tab"
>
Miamwords
</a></li>
<
li><a
href=
"#tab2"
data-toggle=
"tab"
>
Stopwords
</a></li
>
</ul>
<div
class=
"tab-content"
>
<div
class=
"tab-pane active"
id=
"tab1"
>
<div
ng-if=
"extra_miamlist.length == 0"
class=
"alert alert-info"
role=
"alert"
>
No extra text miam-word yet
</div>
<ul
class=
"list-group words-list"
>
<div
ng-if=
"extra_miamlist.length == 0"
class=
"alert alert-info"
role=
"alert"
>
No extra text miam-word yet
</div>
<li
ng-repeat=
"keyword in extra_miamlist | startFrom:currentMiamPage*pageSize | limitTo:pageSize"
class=
"list-group-item"
>
<div
ng-controller=
"ExtraAnnotationController"
keyword-template
class=
"keyword-container"
></div>
...
...
@@ -47,22 +47,24 @@
<button
type=
"submit"
class=
"btn btn-default btn-primary"
ng-click=
"onMiamlistSubmit($event)"
>
Add
</button>
</div>
</div>
<!--<div class="tab-pane" id="tab2">
<ul class="list-group words-list clearfix">
<div ng-if="extra_stoplist.length == 0" class="alert alert-info" role="alert">No extra-text stop-word yet</div>
<li ng-repeat="keyword in extra_stoplist | startFrom:currentStopPage*pageSize | limitTo:pageSize" class="list-group-item"><div ng-controller="ExtraAnnotationController" keyword-template></div></li>
<div
class=
"tab-pane"
id=
"tab2"
>
<div
ng-if=
"extra_stoplist.length == 0"
class=
"alert alert-info"
role=
"alert"
>
No extra text stop-word yet
</div>
<ul
class=
"list-group words-list"
>
<li
ng-repeat=
"keyword in extra_stoplist | startFrom:currentStopPage*pageSize | limitTo:pageSize"
class=
"list-group-item"
>
<div
ng-controller=
"ExtraAnnotationController"
keyword-template
class=
"keyword-container"
></div>
</li>
</ul>
<nav
ng-class=
"{invisible: numStopPages() - 1 == 0}"
class=
"clearfix"
>
<ul
class=
"pagination pagination-s pull-right words-pagination"
>
<li ng-class="{disabled: currentStopPage == 0}"><a ng-click="previous
Stop
Page()" class="glyphicon glyphicon-backward"></a></li>
<li
ng-class=
"{disabled: currentStopPage == 0}"
><a
ng-click=
"previous
Miam
Page()"
class=
"glyphicon glyphicon-backward"
></a></li>
<li
ng-class=
"{disabled: currentStopPage >= numStopPages()-1}"
><a
ng-click=
"nextStopPage()"
class=
"glyphicon glyphicon-forward"
></a></li>
</ul>
</nav>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
id=
"stoplist-input"
ng-keypress=
"onStoplistSubmit($event)"
>
<button type="submit" class="btn btn-default
" ng-click="onStoplistSubmit($event)">Exclude
</button>
<button
type=
"submit"
class=
"btn btn-default
btn-primary"
ng-click=
"onStoplistSubmit($event)"
>
Add
</button>
</div>
</div>--
>
</div
>
</div>
</div>
<div
class=
"col-md-8 col-xs-8 text-panel"
ng-controller=
"DocController"
id=
"document"
>
...
...
gargantext.ini
View file @
67eb3782
...
...
@@ -39,6 +39,10 @@ vacuum = true
pidfile
=
/tmp/gargantext.pid
# touch /tmp/gargantext.reload to reload configuration (after git pull for instance)
touch-reload
=
/tmp/gargantext.reload
# respawn processes taking more than 20 seconds
harakiri
=
120
...
...
gargantext_web/about.py
View file @
67eb3782
...
...
@@ -21,13 +21,13 @@ def get_team():
'mail'
:
'alexandre+gargantextATdelanoe.org'
,
'website'
:
'http://alexandre.delanoe.org'
,
'picture'
:
'alexandre.jpg'
,
'role'
:
'pr
oject
investigator, developer'
},
'role'
:
'pr
incipal
investigator, developer'
},
{
'first_name'
:
'David'
,
'last_name'
:
'Chavalarias'
,
'mail'
:
'david.chavalariasATiscpif.fr'
,
'website'
:
'http://chavalarias.com'
,
'picture'
:
'david.jpg'
,
'role'
:
'pr
oject
investigator'
},
'role'
:
'pr
incipal
investigator'
},
{
'first_name'
:
'Mathieu'
,
'last_name'
:
'Rodic'
,
'mail'
:
''
,
...
...
gargantext_web/corpus_views.py
0 → 100644
View file @
67eb3782
This diff is collapsed.
Click to expand it.
gargantext_web/urls.py
View file @
67eb3782
...
...
@@ -12,11 +12,13 @@ import scrappers.scrap_pubmed.views as pubmedscrapper
import
tests.ngramstable.views
as
samtest
import
gargantext_web.corpus_views
as
corpus_views
admin
.
autodiscover
()
urlpatterns
=
patterns
(
''
,
############################################################################
# Admin views
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^login/'
,
include
(
admin
.
site
.
urls
)),
...
...
@@ -25,22 +27,41 @@ urlpatterns = patterns('',
url
(
r'^auth/$'
,
views
.
login_user
),
url
(
r'^auth/logout/$'
,
views
.
logout_user
),
############################################################################
# Dynamic CSS
url
(
r'^img/logo.svg$'
,
views
.
logo
),
url
(
r'^css/bootstrap.css$'
,
views
.
css
),
############################################################################
# User Home view
url
(
r'^$'
,
views
.
home_view
),
url
(
r'^about/'
,
views
.
get_about
),
url
(
r'^maintenance/'
,
views
.
get_maintenance
),
############################################################################
# Project Management
url
(
r'^projects/$'
,
views
.
projects
),
url
(
r'^project/(\d+)/$'
,
views_optimized
.
project
),
url
(
r'^delete/(\d+)$'
,
views
.
delete_node
),
# => api.node('id' = id, children = 'True', copies = False)
############################################################################
# Corpus management
# Document view (main)
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
views
.
corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/documents'
,
views
.
corpus
),
# Journals view
url
(
r'^project/(\d+)/corpus/(\d+)/journals/journals.json$'
,
corpus_views
.
test_journals
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals'
,
corpus_views
.
get_journals
),
# Terms view
url
(
r'^project/(\d+)/corpus/(\d+)/terms/ngrams.json$'
,
corpus_views
.
test_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/terms'
,
corpus_views
.
get_ngrams
),
# Update corpus
url
(
r'^project/(\d+)/corpus/(\d+)/(\w+)/update$'
,
views
.
update
),
############################################################################
# annotations App
url
(
r'^project/(\d+)/corpus/(\d+)/document/(\d+)/$'
,
annotations_main_view
),
url
(
r'^annotations/'
,
include
(
annotations_urls
)),
...
...
@@ -48,11 +69,13 @@ urlpatterns = patterns('',
#
url
(
r'^project/(\d+)/corpus/(\d+)/corpus.csv$'
,
views
.
corpus_csv
),
url
(
r'^project/(\d+)/corpus/(tests_mvc_listdocuments+)/corpus.tests_mvc_listdocuments$'
,
views
.
corpus_csv
),
############################################################################
# Visualizations
url
(
r'^project/(\d+)/corpus/(\d+)/chart$'
,
views
.
chart
),
url
(
r'^project/(\d+)/corpus/(\d+)/explorer$'
,
views
.
graph
),
url
(
r'^project/(\d+)/corpus/(\d+)/matrix$'
,
views
.
matrix
),
############################################################################
# Data management
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
# => api.node.children('type' : 'data', 'format' : 'csv')
...
...
@@ -60,6 +83,7 @@ urlpatterns = patterns('',
url
(
r'^corpus/(\d+)/adjacency.json$'
,
views
.
adjacency
),
# => api.analysis('type': 'adjacency', 'format' : 'json')
url
(
r'^api/tfidf/(\d+)/(\w+)$'
,
views_optimized
.
tfidf
),
############################################################################
# Data management
#url(r'^api$', gargantext_web.api.Root), # = ?
...
...
@@ -84,10 +108,6 @@ urlpatterns = patterns('',
url
(
r'^tests/project/(\d+)/ISTEXquery/go$'
,
pubmedscrapper
.
testISTEX
),
url
(
r'^tests/paginator/corpus/(\d+)/$'
,
views
.
newpaginatorJSON
),
url
(
r'^tests/move2trash/$'
,
views
.
move_to_trash_multiple
),
url
(
r'^project/(\d+)/corpus/(\d+)/ngrams/ngrams.json$'
,
samtest
.
test_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/ngrams$'
,
samtest
.
get_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals/journals.json$'
,
samtest
.
test_journals
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals$'
,
samtest
.
get_journals
),
url
(
r'^corpus/(\d+)/document/(\d+)/testpage$'
,
samtest
.
test_test
)
)
...
...
gargantext_web/views.py
View file @
67eb3782
from
django.shortcuts
import
redirect
from
django.shortcuts
import
render
from
admin.utils
import
PrintException
from
django.shortcuts
import
redirect
,
render
,
render_to_response
from
django.db
import
transaction
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
from
django.template.loader
import
get_template
from
django.template
import
Context
from
django.template
import
Context
,
RequestContext
# remove this
from
node
import
models
from
node.admin
import
CorpusForm
,
ProjectForm
,
ResourceForm
,
CustomForm
from
django.contrib.auth.models
import
User
import
datetime
...
...
@@ -43,7 +44,7 @@ from sqlalchemy import or_, func
from
gargantext_web
import
about
from
gargantext_web.db
import
NodeNgram
,
NodeNgramNgram
def
login_user
(
request
):
logout
(
request
)
...
...
@@ -61,12 +62,12 @@ def login_user(request):
return
HttpResponseRedirect
(
'/projects/'
)
return
render_to_response
(
'authentication.html'
,
context_instance
=
RequestContext
(
request
))
def
logout_user
(
request
):
logout
(
request
)
return
HttpResponseRedirect
(
'/'
)
# Redirect to a success page.
def
logo
(
request
):
template
=
get_template
(
'logo.svg'
)
group
=
"mines"
...
...
@@ -111,7 +112,6 @@ def css(request):
return
HttpResponse
(
css_data
,
mimetype
=
"text/css"
)
def
query_to_dicts
(
query_string
,
*
query_args
):
"""Run a simple query and produce a generator
that returns the results as a bunch of dictionaries
...
...
@@ -251,6 +251,72 @@ def projects(request):
'projects'
:
projects
})
def
update
(
request
,
project_id
,
corpus_id
,
view
=
None
):
'''
update function:
- remove previous computations (temporary lists and coocurrences)
- permanent deletion of Trash
'''
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
try
:
offset
=
int
(
project_id
)
offset
=
int
(
corpus_id
)
offset
=
str
(
view
)
except
ValueError
:
raise
Http404
()
try
:
white
=
(
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
corpus_id
)
.
filter
(
Node
.
type_id
==
cache
.
NodeType
[
'WhiteList'
]
.
id
)
.
first
()
)
session
.
query
(
NodeNgram
)
.
filter
(
NodeNgram
.
node_id
==
white
.
id
)
.
delete
()
session
.
delete
(
white
)
cooc
=
(
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
corpus_id
)
.
filter
(
Node
.
type_id
==
cache
.
NodeType
[
'Cooccurrence'
]
.
id
)
.
first
()
)
session
.
query
(
NodeNgramNgram
)
.
filter
(
NodeNgramNgram
.
node_id
==
cooc
.
id
)
.
delete
()
session
.
delete
(
cooc
)
session
.
commit
()
except
:
PrintException
()
#return redirect('/project/%s/corpus/%s/%s' % (project_id, corpus_id, view))
nodes
=
models
.
Node
.
objects
.
filter
(
type_id
=
cache
.
NodeType
[
'Trash'
]
.
id
,
user_id
=
request
.
user
.
id
)
.
all
()
with
transaction
.
atomic
():
for
node
in
nodes
:
try
:
node
.
children
.
delete
()
except
Exception
as
error
:
print
(
error
)
node
.
delete
()
return
redirect
(
request
.
path
.
replace
(
'update'
,
''
))
#
# return render_to_response(
# request.path,
# { 'title': 'User profile' },
# context_instance=RequestContext(request)
# )
#
def
corpus
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
...
...
@@ -261,9 +327,8 @@ def corpus(request, project_id, corpus_id):
except
ValueError
:
raise
Http404
()
t
=
get_template
(
'corpus.html'
)
t
=
get_template
(
'corpus
/documents
.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
project
=
cache
.
Node
[
int
(
project_id
)]
...
...
@@ -281,13 +346,14 @@ def corpus(request, project_id, corpus_id):
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'user'
:
user
,
'user'
:
request
.
user
,
'date'
:
date
,
'project'
:
project
,
'corpus'
:
corpus
,
'processing'
:
processing
,
# 'documents': documents,\
'number'
:
number
,
'view'
:
"documents"
}))
return
HttpResponse
(
html
)
...
...
@@ -305,7 +371,7 @@ def newpaginatorJSON(request , corpus_id):
user_id
=
request
.
user
.
id
# documents = session.query(Node).filter(Node.parent_id==corpus_id , Node.type_id == type_document_id ).all()
documents
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_document_id
)
.
all
()
documents
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_document_id
)
.
all
()
# for doc in documents:
# print(doc.name)
...
...
@@ -626,14 +692,14 @@ def node_link(request, corpus_id):
data
=
[]
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
filename
=
settings
.
MEDIA_ROOT
+
'/corpora/
%
s/
%
s_
%
s.json'
%
(
request
.
user
,
corpus
.
parent_id
,
corpus_id
)
print
(
"file exists?:"
,
os
.
path
.
isfile
(
filename
))
if
os
.
path
.
isfile
(
filename
):
json_data
=
open
(
filename
,
"r"
)
data
=
json
.
load
(
json_data
)
json_data
.
close
()
else
:
data
=
get_cooc
(
request
=
request
,
corpus_id
=
corpus_id
,
type
=
"node_link"
)
#
filename = settings.MEDIA_ROOT + '/corpora/%s/%s_%s.json' % (request.user , corpus.parent_id, corpus_id)
#
print("file exists?:",os.path.isfile(filename))
#
if os.path.isfile(filename):
#
json_data = open(filename,"r")
#
data = json.load(json_data)
#
json_data.close()
#
else:
data
=
get_cooc
(
request
=
request
,
corpus_id
=
corpus_id
,
type
=
"node_link"
)
return
JsonHttpResponse
(
data
)
def
adjacency
(
request
,
corpus_id
):
...
...
ngram/lists.py
View file @
67eb3782
...
...
@@ -97,10 +97,10 @@ def listNgramIds(list_id=None, typeList=None,
ListNgram
=
aliased
(
NodeNgram
)
or_args
=
[
ListNgram
.
node_id
==
l
[
0
]
for
l
in
allLists
]
query
=
(
session
.
query
(
Ngram
.
id
,
Ngram
.
terms
,
func
.
count
(
),
ListNgram
.
node_id
)
query
=
(
session
.
query
(
Ngram
.
id
,
Ngram
.
terms
,
func
.
sum
(
ListNgram
.
weight
),
ListNgram
.
node_id
)
.
join
(
ListNgram
,
ListNgram
.
ngram_id
==
Ngram
.
id
)
.
filter
(
or_
(
*
or_args
))
.
group_by
(
Ngram
.
id
,
ListNgram
)
.
group_by
(
Ngram
.
id
,
ListNgram
.
node_id
)
)
if
doc_id
is
not
None
:
...
...
templates/corpus.html
→
templates/corpus
/documents
.html
View file @
67eb3782
{% extends "menu.html" %}
{% extends "corpus/menu.html" %}
{% block css %}
{% load staticfiles %}
...
...
@@ -13,7 +12,6 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
dc
.
css
"%}"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
jquery
.
dynatable
.
css
"%}"
/>
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
d3
.
js
"%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
crossfilter
.
js
"%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
dc
.
js
"%}"
></script>
...
...
@@ -47,31 +45,8 @@ th a {
{% endblock %}
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
{% if project %}
<h1>
{{ project.name }}, {{ corpus.name }}
</h1>
{% endif %}
{% if corpus %}
<p>
{{ number}} docs, Created on {{ corpus.date }}
</p>
{% endif %}
<!-- <a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add file</a> -->
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/corpus.csv"
>
Save as
</a>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/delete/{{ corpus.id }}"
>
Delete
</a></p>
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
{% endif %}
</div>
</div>
{% block content %}
<div
class=
"container"
>
<div
class=
"container"
>
...
...
@@ -96,6 +71,8 @@ th a {
<a
class=
"btn btn-xs btn-default"
role=
"button"
href=
"/chart/corpus/{{ corpus.id }}/data.csv"
>
Save
</a></p>
<div
class=
"container"
>
<div
class=
"jumbotron"
>
...
...
@@ -170,8 +147,6 @@ th a {
<div
id=
"filter_search"
style=
"visibility:hidden"
>
<select
id=
"example-single-optgroups"
onchange=
"SearchFilters(this);"
>
<!-- <optgroup label=""> -->
<option
id=
"filter_all"
value=
"filter_all"
>
All
</option>
...
...
@@ -198,3 +173,6 @@ th a {
{% endblock %}
templates/
test
s/journals.html
→
templates/
corpu
s/journals.html
View file @
67eb3782
{% extends "menu.html" %}
{% extends "corpus/menu.html" %}
{% block css %}
{% load staticfiles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
bootstrap
.
css
"
%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
js
/
bootstrap
/
bootstrap-select
.
min
.
css
"
%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
morris
.
css
"
%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
jquery
.
easy-pie-chart
.
css
"%}"
>
...
...
@@ -110,32 +111,6 @@ input[type=radio]:checked + label {
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
{% if project %}
<h1>
{{ project.name }}, {{ corpus.name }}
</h1>
{% endif %}
{% if corpus %}
<p>
Created on {{ corpus.date }}
</p>
<div
id=
"stats"
></div>
{% endif %}
<!-- <a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add file</a> -->
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/corpus.csv"
>
Save as
</a>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/delete/{{ corpus.id }}"
>
Delete
</a></p>
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
{% endif %}
</div>
</div>
<div
class=
"container"
>
<div
class=
"container"
>
...
...
@@ -197,52 +172,6 @@ input[type=radio]:checked + label {
</div>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/chart"
>
Advanced charts
</a></h3>
<ol>
<li>
Count
</li>
<!-- read, compute -->
<li>
Filter
</li>
<!-- count, compute -->
<li>
Compare
</li>
<!-- select, cut -->
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/matrix"
>
Matrix
</a></h3>
<ol>
<li>
Sort
</li>
<li>
Group
</li>
<li>
Cluster
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
{% if processing > 0 %}
<h3>
<img
width=
"20px"
src=
"{% static "
js
/
libs
/
img2
/
loading-bar
.
gif
"
%}"
></img>
Graph (later)
</h3>
{% else %}
<h3><a
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/explorer"
>
Graph
</a></h3>
{% endif %}
<ol>
<li>
Visualize
</li>
<li>
Explore
</li>
<li>
Read
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
charts
/
bootstrap
.
min
.
js
"
%}"
></script>
...
...
templates/corpus/menu.html
0 → 100644
View file @
67eb3782
{% extends "menu.html" %}
{% load staticfiles %}
{% block corpusBannerTop %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
{% if project %}
<h1><a
href=
"/project/{{project.id}}"
>
{{ project.name }}
</a></h1>
<h2>
{{ corpus.name }}
</h2>
{% endif %}
<!--<a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add file</a> -->
</div>
<div
class=
"col-md-4"
>
{% if corpus %}
<br>
<p>
<center>
Creation date:
<br>
{{ corpus.date }}
</center>
</p>
{% endif %}
</div>
<div
class=
"col-md-4"
>
<br>
<a
class=
"btn btn-default btn-lg"
role=
"button"
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/{{view}}/update"
>
Update
</a>
<a
class=
"btn btn-default btn-lg"
role=
"button"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/corpus.csv"
>
Download
</a>
<a
type=
"button"
class=
"btn btn-default btn-lg"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
<ul>
<li> Rename </li>
<li> Add new documents </li>
<li><a href="/delete/{{corpus.id}}">Delete</a></li>
</ul>
'
>
Manage
</a>
<!--
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: 90%">
<span class="sr-only">45% Complete</span>
</div>
</div>
--!>
{% if number == 0 %}
<a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add documents</a></p>
{% endif %}
</div>
</div>
</div>
<div class="btn-group btn-group-justified">
<center>
<a type="button" class="btn btn-default {% if view == "documents" %}active{%endif%}" href="/project/{{project.id}}/corpus/{{ corpus.id }}/documents">{{number}} Documents</a>
<a type="button" class="btn btn-default {% if view == "journals" %}active{%endif%}" href="/project/{{project.id}}/corpus/{{ corpus.id }}/journals">Journals</a>
{% if processing == 0 %}
<a type="button" class="btn btn-default {% if view == "terms" %}active{%endif%}" href="/project/{{project.id}}/corpus/{{ corpus.id }}/terms">Terms</a>
{% endif %}
</center>
</div>
{% endblock %}
{% block corpusBannerBottom %}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="jumbotron">
<h3><a href="/project/{{project.id}}/corpus/{{corpus.id}}/chart">Advanced charts</a></h3>
<ol>
<li>Count</li> <!-- read, compute -->
<li>
Filter
</li>
<!-- count, compute -->
<li>
Compare
</li>
<!-- select, cut -->
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<!-- <h3><a href="/project/{{project.id}}/corpus/{{corpus.id}}/matrix">Matrix</a></h3> -->
<h3>
Matrix (soon)
</h3>
<ol>
<li>
Sort
</li>
<li>
Group
</li>
<li>
Cluster
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
{% if processing > 0 %}
<h3>
<img
width=
"20px"
src=
"{% static "
js
/
libs
/
img2
/
loading-bar
.
gif
"
%}"
></img>
Graph (later)
</h3>
{% else %}
<h3><a
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/explorer"
>
Graph
</a></h3>
{% endif %}
<ol>
<li>
Visualize
</li>
<li>
Explore
</li>
<li>
Read
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
</div>
</div>
{% endblock %}
templates/
tests/ngra
ms.html
→
templates/
corpus/ter
ms.html
View file @
67eb3782
{% extends "menu.html" %}
{% extends "corpus/menu.html" %}
{% block css %}
{% load staticfiles %}
...
...
@@ -115,7 +114,6 @@ input[type=radio]:checked + label {
{% block content %}
<input
type=
"hidden"
id=
"list_id"
value=
"{{ list_id }}"
></input>
...
...
@@ -209,51 +207,6 @@ input[type=radio]:checked + label {
</div>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/chart"
>
Advanced charts
</a></h3>
<ol>
<li>
Count
</li>
<!-- read, compute -->
<li>
Filter
</li>
<!-- count, compute -->
<li>
Compare
</li>
<!-- select, cut -->
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/matrix"
>
Matrix
</a></h3>
<ol>
<li>
Sort
</li>
<li>
Group
</li>
<li>
Cluster
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
{% if processing > 0 %}
<h3>
<img
width=
"20px"
src=
"{% static "
js
/
libs
/
img2
/
loading-bar
.
gif
"
%}"
></img>
Graph (later)
</h3>
{% else %}
<h3><a
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/explorer"
>
Graph
</a></h3>
{% endif %}
<ol>
<li>
Visualize
</li>
<li>
Explore
</li>
<li>
Read
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
</div>
</div>
<div
id=
"savemodal"
class=
"modal fade"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
...
...
templates/menu.html
View file @
67eb3782
...
...
@@ -59,9 +59,18 @@
</div>
<!--/.nav-collapse -->
{% block corpusBannerTop %}
{% endblock %}
{% block content %}
{% endblock %}
{% block corpusBannerBottom %}
{% endblock %}
<hr>
...
...
templates/project.html
View file @
67eb3782
...
...
@@ -87,7 +87,7 @@
{% ifequal corpus.processing 1 %}
{{corpus.name}} :
<img
width=
"20px"
src=
"{% static "
js
/
libs
/
img2
/
loading-bar
.
gif
"
%}"
></img>
Processing, drink a cup of tea, and refresh the page :)
{% else %}
<a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}"
>
{{corpus.name}}
</a>
, {{ corpus.count }} Documents
<a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}"
>
{{corpus.name}}
, {{ corpus.count }} Documents
</a>
{% endifequal %}
<button
type=
"button"
class=
"btn btn-xs btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
...
...
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