Zack commited on
Commit
7b2bfe6
·
1 Parent(s): 7b6ef23

makign app simpler

Browse files
Files changed (1) hide show
  1. app.py +5 -36
app.py CHANGED
@@ -1,40 +1,9 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- def load_file():
5
- """Load text from file"""
6
- uploaded_file = st.file_uploader("Upload Files",type=['txt'])
7
 
8
- if uploaded_file is not None:
9
- if uploaded_file.type == "text/plain":
10
- raw_text = str(uploaded_file.read(),"utf-8")
11
- return raw_text
12
-
13
-
14
- if __name__ == "__main__":
15
-
16
- # App title and description
17
- st.title("Answering questions from text")
18
- st.write("Upload text, pose questions, get answers")
19
-
20
- # Load file
21
- raw_text = load_file()
22
- if raw_text != None and raw_text != '':
23
-
24
- # Display text
25
- with st.expander("See text"):
26
- st.write(raw_text)
27
-
28
- # Perform question answering
29
- question_answerer = pipeline('question-answering')
30
-
31
- answer = ''
32
- question = st.text_input('Ask a question')
33
-
34
- if question != '' and raw_text != '':
35
- answer = question_answerer({
36
- 'question': question,
37
- 'context': raw_text
38
- })
39
-
40
- st.write(answer)
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ pipe = pipeline('sentiment-analysis')
5
+ text = st.text_area('enter your feelings here')
 
6
 
7
+ if text:
8
+ out = pipe(text)
9
+ st.json(out)