import streamlit as st import transformers # Load the pre-trained NER model model = transformers.pipeline('ner', model='dslim/bert-base-NER') # Define the Streamlit app def app(): # Set the app title st.title('Named Entity Recognition with HuggingFace') # Define the input text area text = st.text_area('Enter some text:', value='', height=200) # Define the button to submit the text if st.button('Submit'): # Run the NER model on the input text entities = model(text) # Display the named entities in the input text for entity in entities: st.write(f'{entity["entity"]}: {entity["word"]}') # Run the Streamlit app if __name__ == '__main__': app()