-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (31 loc) · 971 Bytes
/
Copy pathapp.py
File metadata and controls
38 lines (31 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask,render_template,url_for,request
import joblib
import re
import string
import pandas as pd
app = Flask(__name__)
Model = joblib.load('Model.pkl')
@app.route('/')
def index():
return render_template("index.html")
def wordpre(text):
text = text.lower()
text = re.sub(r'\[.*?\]', '', text)
text = re.sub("\\W"," ",text) # remove special chars
text = re.sub(r'https?://\S+|www\.\S+', '', text)
text = re.sub('<.*?>+', '', text)
text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
text = re.sub('\n', '', text)
text = re.sub(r'\w*\d\w*', '', text)
return text
@app.route('/',methods=['POST'])
def pre():
if request.method == 'POST':
txt = request.form['txt']
txt = wordpre(txt)
txt = pd.Series(txt)
result = Model.predict(txt)
return render_template("index.html", result = result)
return ''
if __name__ == "__main__":
app.run(debug=True)