Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
3fb58026
Commit
3fb58026
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup corpus analysis code
parent
df98f3a9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/views.py
+11
-21
11 additions, 21 deletions
app/corpora/views.py
app/templates/corpora/analyse_corpus.html.j2
+14
-14
14 additions, 14 deletions
app/templates/corpora/analyse_corpus.html.j2
app/templates/corpora/corpus.html.j2
+1
-1
1 addition, 1 deletion
app/templates/corpora/corpus.html.j2
with
26 additions
and
36 deletions
app/corpora/views.py
+
11
−
21
View file @
3fb58026
from
app
import
db
,
logger
from
app
import
db
from
app.models
import
Corpus
,
CorpusFile
from
app.models
import
Corpus
,
CorpusFile
from
flask
import
(
abort
,
current_app
,
flash
,
redirect
,
request
,
from
flask
import
(
abort
,
current_app
,
flash
,
redirect
,
request
,
render_template
,
url_for
,
send_from_directory
)
render_template
,
url_for
,
send_from_directory
)
...
@@ -6,7 +6,7 @@ from flask_login import current_user, login_required
...
@@ -6,7 +6,7 @@ from flask_login import current_user, login_required
from
werkzeug.utils
import
secure_filename
from
werkzeug.utils
import
secure_filename
from
.
import
corpora
from
.
import
corpora
from
.background_functions
import
(
delete_corpus_
,
delete_corpus_file_
,
from
.background_functions
import
(
delete_corpus_
,
delete_corpus_file_
,
edit_corpus_file_
)
edit_corpus_file_
)
from
.forms
import
(
AddCorpusFileForm
,
AddCorpusForm
,
EditCorpusFileForm
,
from
.forms
import
(
AddCorpusFileForm
,
AddCorpusForm
,
EditCorpusFileForm
,
QueryDownloadForm
,
QueryForm
)
QueryDownloadForm
,
QueryForm
)
import
os
import
os
...
@@ -48,31 +48,21 @@ def corpus(corpus_id):
...
@@ -48,31 +48,21 @@ def corpus(corpus_id):
title
=
'
Corpus
'
)
title
=
'
Corpus
'
)
@corpora.route
(
'
/<int:corpus_id>/analys
is
'
,
methods
=
[
'
GET
'
,
'
POST
'
]
)
@corpora.route
(
'
/<int:corpus_id>/analys
e
'
)
@login_required
@login_required
def
corpus_analysi
s
(
corpus_id
):
def
analyse_corpu
s
(
corpus_id
):
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
if
corpus
.
status
==
'
prepared
'
:
if
corpus
.
status
==
'
prepared
'
:
corpus
.
status
=
'
start analysis
'
corpus
.
status
=
'
start analysis
'
db
.
session
.
commit
()
db
.
session
.
commit
()
query
=
request
.
args
.
get
(
'
query
'
)
query_download_form
=
QueryDownloadForm
()
logger
.
warning
(
'
Query first: {}
'
.
format
(
query
))
query_form
=
QueryForm
(
context
=
request
.
args
.
get
(
'
context
'
,
10
),
hits_per_page
=
request
.
args
.
get
(
'
hits_per_page
'
,
30
)
hits_per_page
=
request
.
args
.
get
(
'
hits_per_page
'
,
30
),
context
=
request
.
args
.
get
(
'
context
'
,
10
)
query
=
request
.
args
.
get
(
'
query
'
))
dl_form
=
QueryDownloadForm
()
return
render_template
(
'
corpora/analyse_corpus.html.j2
'
,
form
=
QueryForm
(
hits_per_page
=
hits_per_page
,
context
=
context
,
query
=
query
)
if
form
.
validate_on_submit
():
flash
(
'
Query has been sent!
'
)
query
=
form
.
query
.
data
hits_per_page
=
form
.
hits_per_page
.
data
context
=
form
.
context
.
data
return
redirect
(
url_for
(
'
corpora.corpus_analysis
'
,
corpus_id
=
corpus_id
,
query
=
query
,
hits_per_page
=
hits_per_page
,
context
=
context
))
return
render_template
(
'
corpora/corpus_analysis.html.j2
'
,
corpus_id
=
corpus_id
,
corpus_id
=
corpus_id
,
form
=
form
,
dl_form
=
dl
_form
,
query_download_form
=
query_download
_form
,
title
=
'
Corpus: {}
'
.
format
(
corpus
.
title
)
)
query_form
=
query_form
,
title
=
'
Analyse Corpus
'
)
@corpora.route
(
'
/<int:corpus_id>/delete
'
)
@corpora.route
(
'
/<int:corpus_id>/delete
'
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/
corpus_analysi
s.html.j2
→
app/templates/corpora/
analyse_corpu
s.html.j2
+
14
−
14
View file @
3fb58026
...
@@ -6,12 +6,12 @@
...
@@ -6,12 +6,12 @@
<div class="card">
<div class="card">
<div class="card-content">
<div class="card-content">
<form id="query-form" method="POST">
<form id="query-form" method="POST">
{{ form.hidden_tag() }}
{{
query_
form.hidden_tag() }}
<span class="card-title">Query and analysis</span>
<span class="card-title">Query and analysis</span>
<div class="input-field">
<div class="input-field">
{{ form.query(class='materialize-textarea') }}
{{
query_
form.query(class='materialize-textarea') }}
{{ form.query.label }}
{{
query_
form.query.label }}
{% for error in form.query.errors %}
{% for error in
query_
form.query.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
...
@@ -23,17 +23,17 @@
...
@@ -23,17 +23,17 @@
<span class="card-title">Options</span>
<span class="card-title">Options</span>
<div class="input-field">
<div class="input-field">
<i class="material-icons prefix">format_list_numbered</i>
<i class="material-icons prefix">format_list_numbered</i>
{{ form.hits_per_page() }}
{{
query_
form.hits_per_page() }}
{{ form.hits_per_page.label }}
{{
query_
form.hits_per_page.label }}
{% for error in form.hits_per_page.errors %}
{% for error in
query_
form.hits_per_page.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
<div class="input-field">
<div class="input-field">
<i class="material-icons prefix">short_text</i>
<i class="material-icons prefix">short_text</i>
{{ form.context() }}
{{
query_
form.context() }}
{{ form.context.label }}
{{
query_
form.context.label }}
{% for error in form.context.errors %}
{% for error in
query_
form.context.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
...
@@ -44,14 +44,14 @@
...
@@ -44,14 +44,14 @@
<div class="card">
<div class="card">
<div class="card-content">
<div class="card-content">
<form id="download-form" method="POST">
<form id="download-form" method="POST">
{{ d
l
_form.hidden_tag() }}
{{
query_downloa
d_form.hidden_tag() }}
<span class="card-title">Download Results</span>
<span class="card-title">Download Results</span>
<p>Downlaod all results of the current query as csv, excel or json file.</p>
<p>Downlaod all results of the current query as csv, excel or json file.</p>
<div class="input-field">
<div class="input-field">
<i class="material-icons prefix">insert_drive_file</i>
<i class="material-icons prefix">insert_drive_file</i>
{{ d
l
_form.file_type() }}
{{
query_downloa
d_form.file_type() }}
{{ d
l
_form.file_type.label }}
{{
query_downloa
d_form.file_type.label }}
{% for error in d
l
_form.file_type.errors %}
{% for error in
query_downloa
d_form.file_type.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/corpus.html.j2
+
1
−
1
View file @
3fb58026
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
</div>
</div>
</div>
</div>
<div class="card-action right-align">
<div class="card-action right-align">
<a href="{{ url_for('corpora.
corpus_analysi
s', corpus_id=corpus.id) }}" class="waves-effect waves-light btn hide" id="analyse"><i class="material-icons left">help</i>Analyse</a>
<a href="{{ url_for('corpora.
analyse_corpu
s', corpus_id=corpus.id) }}" class="waves-effect waves-light btn hide" id="analyse"><i class="material-icons left">help</i>Analyse</a>
{% if corpus.files[0] is defined %}
{% if corpus.files[0] is defined %}
<a href="{{ url_for('corpora.prepare_corpus', corpus_id=corpus.id) }}" class="waves-effect waves-light btn" id="prepare"><i class="material-icons left">whatshot</i>Prepare</a>
<a href="{{ url_for('corpora.prepare_corpus', corpus_id=corpus.id) }}" class="waves-effect waves-light btn" id="prepare"><i class="material-icons left">whatshot</i>Prepare</a>
{% endif %}
{% endif %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment