Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,23 @@ model = AutoModelForTokenClassification.from_pretrained(model_name)
|
|
10 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
|
11 |
|
12 |
# UI ด้วย Streamlit
|
13 |
-
st.
|
14 |
-
text = st.text_area("Enter text for NER analysis:")
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
text=""
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
|
11 |
|
12 |
# UI ด้วย Streamlit
|
13 |
+
col1, col2 = st.columns(2)
|
|
|
14 |
|
15 |
+
with col1:
|
16 |
+
st.header("Input")
|
17 |
+
text = st.text_area("Enter text for NER analysis:")
|
18 |
+
analyze_button = st.button("Analyze")
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
with col2:
|
23 |
+
st.header("Output")
|
24 |
+
if analyze_button:
|
25 |
+
ner_results = ner_pipeline(text)
|
26 |
+
|
27 |
+
# Display results in a structured output block
|
28 |
+
if ner_results:
|
29 |
+
output_data = [{"Entity": entity['word'], "Label": entity['entity'], "Score": f"{entity['score']:.4f}"} for entity in ner_results]
|
30 |
+
st.table(output_data) # Display as a table
|
31 |
+
else:
|
32 |
+
st.write("No entities found.")
|