Skip to content

Commit

Permalink
set up basic web format
Browse files Browse the repository at this point in the history
  • Loading branch information
petersapountzis committed Apr 9, 2024
1 parent 72e85f4 commit a724333
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
5 changes: 4 additions & 1 deletion nlp/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class MyForm(FlaskForm):
class Meta: # Ignoring CSRF security feature.
csrf = False

input_field = StringField(label='input headline:', id='input_field',
premise_field = StringField(label='Premise:', id='premise_field',
validators=[DataRequired()],
render_kw={'style': 'width:50%'})
hypothesis_field = StringField(label='Hypothesis:', id='hypo_field',
validators=[DataRequired()],
render_kw={'style': 'width:50%'})
submit = SubmitField('Submit')
4 changes: 2 additions & 2 deletions nlp/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def index():
pred = clf.predict(X)[0]
proba = clf.predict_proba(X)[0].max()
# flash(input_field)
return render_template('myform.html', title='', form=form,
return render_template('myform.html', title='Interactive NLI Classifier', form=form,
prediction=labels[pred], confidence='%.2f' % proba)
#return redirect('/index')
return render_template('myform.html', title='', form=form, prediction=None, confidence=None)
return render_template('myform.html', title='Interactive NLI Classifier', form=form, prediction=None, confidence=None)
24 changes: 13 additions & 11 deletions nlp/app/templates/myform.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% extends "base.html" %}

{% block content %}
<b>Partisan headline classifier</b>
<form action="" method="post" novalidate>
<p>
{{ form.input_field.label }} {{ form.input_field(size=32) }}
</p>
{{ form.submit() }}
</form>
{% endblock %}
{% extends "base.html" %} {% block content %}
<b>Interactive NLI classifier</b>
<form action="" method="post" novalidate>
<p>{{ form.premise_field.label }} {{ form.premise_field(size=32) }}</p>
{{ form.submit() }}
</form>
<form action="" method="post" novalidate>
<p>
{{ form.hypothesis_field.label }} {{ form.hypothesis_field(size=32) }}
</p>
{{ form.submit() }}
</form>
{% endblock %}

0 comments on commit a724333

Please sign in to comment.