Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import transformers
|
3 |
+
|
4 |
+
# Load the pre-trained NER model
|
5 |
+
model = transformers.pipeline('ner', model='dslim/bert-base-NER')
|
6 |
+
|
7 |
+
# Define the Streamlit app
|
8 |
+
def app():
|
9 |
+
# Set the app title
|
10 |
+
st.title('Named Entity Recognition with HuggingFace')
|
11 |
+
|
12 |
+
# Define the input text area
|
13 |
+
text = st.text_area('Enter some text:', value='', height=200)
|
14 |
+
|
15 |
+
# Define the button to submit the text
|
16 |
+
if st.button('Submit'):
|
17 |
+
# Run the NER model on the input text
|
18 |
+
entities = model(text)
|
19 |
+
|
20 |
+
# Display the named entities in the input text
|
21 |
+
for entity in entities:
|
22 |
+
st.write(f'{entity["entity"]}: {entity["word"]}')
|
23 |
+
|
24 |
+
# Run the Streamlit app
|
25 |
+
if __name__ == '__main__':
|
26 |
+
app()
|