Code: Select all
from flask import Flask,request,render_template
from nltk.sentiment.vader import SentimentIntensityAnalyzer
model =SentimentIntensityAnalyzer()
app =Flask(__name__)
@app.route('/')
def hello_comment():
return render_template('Select_comment.html')
@app.route('/',methods=['POST','GET'])
def read_comment():
comment =request.form['mycomment']
polarity_scores =model.polarity_scores(comment)
if polarity_scores['pos']>0.5:
text ='positive'
else:
text ='not positive'
return render_template('Select_comment.html',name=text)
if __name__=='__main__':
app.run(debug=True)
< /code>
und entsprechende HTML -Datei: < /p>
Select comment
Write your comment here
your comment is {{ name }}
Ich brauche so etwas, wie kann ich es machen? Vielen Dank im Voraus