Kamanda/Streamlit_Machine_Learning
0
1'''Hugging Face'''2 3import streamlit as st4from transformers import pipeline5 6if __name__ == "__main__":7 8 # Define the title of the and its description9 st.title("Answering questions using NLP through Streamlit interface")10 st.write("Pose questions, get answers")11 12 # Load file13 14 raw_text = st.text_area(label="Enter a text here")15 if raw_text != None and raw_text != '':16 17 # Display text18 with st.expander("Show question"):19 st.write(raw_text)20 21 # Conduct question answering using the pipeline22 question_answerer = pipeline('question-answering')23 24 answer = ''25 question = st.text_input('Ask a question')26 27 if question != '' and raw_text != '':28 answer = question_answerer({29 'question': question,30 'context': raw_text31 })32 33 st.write(answer)34 