Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,7 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
app = Flask(__name__)
|
9 |
-
|
10 |
-
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'docx'}
|
11 |
-
|
12 |
-
def allowed_file(filename):
|
13 |
-
return '.' in filename and \
|
14 |
-
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
15 |
-
|
16 |
-
@app.route('/api/generate-wordcloud', methods=['POST'])
|
17 |
-
def generate_wordcloud():
|
18 |
-
if 'file' not in request.files:
|
19 |
-
return jsonify({'error': 'Missing file upload'}), 400
|
20 |
-
|
21 |
-
file = request.files['file']
|
22 |
-
if file.filename == '':
|
23 |
-
return jsonify({'error': 'No selected file'}), 400
|
24 |
-
|
25 |
-
if file and allowed_file(file.filename):
|
26 |
-
text = ''
|
27 |
-
if file.filename.endswith('.txt'):
|
28 |
-
text = file.read().decode('utf-8')
|
29 |
-
elif file.filename.
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipline
|
3 |
+
pipe =pipline('sentiment-analysis')
|
4 |
+
text=st.text_area('enter some text')
|
5 |
+
if text:
|
6 |
+
out=pip(text)
|
7 |
+
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|