File size: 725 Bytes
68d82d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()