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
31c015f7
Commit
31c015f7
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add query analysis form options etc.
parent
5f291123
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/main/forms.py
+24
-5
24 additions, 5 deletions
app/main/forms.py
app/main/views.py
+10
-1
10 additions, 1 deletion
app/main/views.py
app/templates/main/corpora/corpus_analysis.html.j2
+20
-11
20 additions, 11 deletions
app/templates/main/corpora/corpus_analysis.html.j2
with
54 additions
and
17 deletions
app/main/forms.py
+
24
−
5
View file @
31c015f7
from
flask_wtf
import
FlaskForm
from
flask_wtf
import
FlaskForm
from
wtforms
import
(
MultipleFileField
,
StringField
,
SubmitField
,
from
wtforms
import
(
MultipleFileField
,
StringField
,
SubmitField
,
ValidationError
,
IntegerField
)
ValidationError
,
IntegerField
,
SelectField
)
from
wtforms.validators
import
DataRequired
,
Length
,
NumberRange
from
wtforms.validators
import
DataRequired
,
Length
,
NumberRange
...
@@ -26,8 +26,27 @@ class AddCorpusFileForm(FlaskForm):
...
@@ -26,8 +26,27 @@ class AddCorpusFileForm(FlaskForm):
class
QueryForm
(
FlaskForm
):
class
QueryForm
(
FlaskForm
):
query
=
StringField
(
'
CQP Query
'
,
validators
=
[
DataRequired
()])
query
=
StringField
(
'
CQP Query
'
,
validators
=
[
DataRequired
(),
(
Length
(
1
,
1024
))])
# hits_per_page = IntegerField('Hits per page',
hits_per_page
=
SelectField
(
'
Hits per page
'
,
# validators=[DataRequired(),
choices
=
[(
''
,
'
Nr. of hits per page
'
),
# NumberRange(min=10, max=50)])
(
'
10
'
,
'
10
'
),
(
'
20
'
,
'
20
'
),
(
'
30
'
,
'
30
'
),
(
'
40
'
,
'
40
'
),
(
'
50
'
,
'
50
'
)],
validators
=
[
DataRequired
()],
default
=
'
30
'
)
context
=
SelectField
(
'
Context
'
,
choices
=
[(
''
,
'
Words of context around hit
'
),
(
'
5
'
,
'
5
'
),
(
'
10
'
,
'
10
'
),
(
'
15
'
,
'
15
'
),
(
'
20
'
,
'
20
'
),
(
'
25
'
,
'
25
'
)],
validators
=
[
DataRequired
()],
default
=
'
10
'
)
submit
=
SubmitField
(
'
Start Query
'
)
submit
=
SubmitField
(
'
Start Query
'
)
class
QueryDownloadForm
(
FlaskForm
):
pass
This diff is collapsed.
Click to expand it.
app/main/views.py
+
10
−
1
View file @
31c015f7
...
@@ -55,15 +55,24 @@ def corpus_download(corpus_id):
...
@@ -55,15 +55,24 @@ def corpus_download(corpus_id):
@login_required
@login_required
def
corpus_analysis
(
corpus_id
):
def
corpus_analysis
(
corpus_id
):
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
query
=
request
.
args
.
get
(
'
query
'
)
form
=
QueryForm
()
form
=
QueryForm
()
if
form
.
validate_on_submit
():
if
form
.
validate_on_submit
():
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
'
Data has been sent!
'
)
logger
.
warning
(
'
Data has been sent!
'
)
logger
.
warning
(
'
Data labels: {data}
'
.
format
(
data
=
[
data
for
data
in
form
.
data
]))
logger
.
warning
(
'
Query: {q}
'
.
format
(
q
=
form
.
query
.
data
))
logger
.
warning
(
'
Hits: {hits}
'
.
format
(
hits
=
form
.
hits_per_page
.
data
))
logger
.
warning
(
'
Context: {context}
'
.
format
(
context
=
form
.
context
.
data
))
flash
(
'
Query has been sent!
'
)
flash
(
'
Query has been sent!
'
)
return
redirect
(
url_for
(
'
main.corpus_analysis
'
,
corpus_id
=
corpus_id
))
query
=
form
.
query
.
data
logger
.
warning
(
'
Session query: {sq}
'
.
format
(
sq
=
query
))
return
redirect
(
url_for
(
'
main.corpus_analysis
'
,
corpus_id
=
corpus_id
,
query
=
query
))
return
render_template
(
'
main/corpora/corpus_analysis.html.j2
'
,
return
render_template
(
'
main/corpora/corpus_analysis.html.j2
'
,
corpus
=
corpus
,
corpus
=
corpus
,
form
=
form
,
form
=
form
,
query
=
query
,
title
=
'
Corpus:
'
+
corpus
.
title
)
title
=
'
Corpus:
'
+
corpus
.
title
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/main/corpora/corpus_analysis.html.j2
+
20
−
11
View file @
31c015f7
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<span class="card-title">Query and analysis</span>
<span class="card-title">Query and analysis</span>
<div class="input-field">
<div class="input-field">
<i class="material-icons prefix">search</i>
<i class="material-icons prefix">search</i>
<
textarea
id="{{ form.query.id }}" name="{{ form.query.id }}" required="" type="text" value="
" class="materialize-textarea"></textarea
>
<
input autofocus size="1024" data-length="1024"
id="{{ form.query.id }}" name="{{ form.query.id }}" required="" type="text" value="
{{ query if query != None else '' }}"></input
>
{{ form.query.label }}
{{ form.query.label }}
{% for error in form.query.errors %}
{% for error in form.query.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
<div class="right-align">
<div class="right-align">
{{ form.submit(class='btn') }}
{{ form.submit(class='btn') }}
</div>
</div>
<!--
<br>
<br>
<span class="card-title">Help</span>
<span class="card-title">Help</span>
<ul>
<ul>
<li>
<li>
...
@@ -54,17 +54,26 @@
...
@@ -54,17 +54,26 @@
</ul>
</ul>
<br>
<br>
<span class="card-title">Options</span>
<span class="card-title">Options</span>
<select>
<option value="" disabled selected>Choose your option</option>
<option value="1">10</option>
<option value="2">20</option>
<option value="3">25</option>
<option value="3">50</option>
</select>
<label>Materialize Select</label>
<br>
<br>
<div class="input-field">
<i class="material-icons prefix">format_list_numbered</i>
{{ form.hits_per_page() }}
{{ form.hits_per_page.label }}
{% for error in form.hits_per_page.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<br>
<div class="input-field">
<i class="material-icons prefix">short_text</i>
{{ form.context() }}
{{ form.context.label }}
{% for error in form.context.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<span class="card-title">Download Results</span>
<span class="card-title">Download Results</span>
</div>
-->
</div>
</form>
</form>
</div>
</div>
</div>
</div>
...
...
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