Nucha commited on
Commit
827a18f
·
verified ·
1 Parent(s): 4b54518

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
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.title("NER Analysis App")
14
- text = st.text_area("Enter text for NER analysis:")
15
 
16
- if st.button("Analyze"):
17
- ner_results = ner_pipeline(text)
18
- text=""
19
- for entity in ner_results:
20
- text = text + f"Entity: {entity['word']}, Label: {entity['entity']}, Score: {entity['score']:.4f}"
21
- st.text_area(text)
 
 
 
 
 
 
 
 
 
 
 
 
 
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.")