WhiteAngels commited on
Commit
d84cca7
1 Parent(s): 37a9028

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import streamlit as st
3
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer, AutoModelForTokenClassification, AutoModelForCausalLM
4
  import pandas as pd
@@ -70,10 +69,14 @@ if Run_Button and input_text != "":
70
  st.dataframe(df)
71
  elif task == "Metin Analizi":
72
  output = pipeline_model(input_text)
73
- entities = [{"Word": e['word'], "Entity": e['entity_group'], "Score": e['score']} for e in output]
74
- df = pd.DataFrame(entities)
75
- st.subheader("Tanımlanan Varlıklar")
76
- st.dataframe(df)
 
 
 
 
77
  elif task == "Metin Oluşturma":
78
  output = pipeline_model(input_text, max_length=100, num_return_sequences=1)
79
  st.subheader("Oluşturulan Metin")
 
 
1
  import streamlit as st
2
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer, AutoModelForTokenClassification, AutoModelForCausalLM
3
  import pandas as pd
 
69
  st.dataframe(df)
70
  elif task == "Metin Analizi":
71
  output = pipeline_model(input_text)
72
+ # Çıktı formatına göre anahtar isimlerini düzenleyin
73
+ try:
74
+ entities = [{"Word": e.get('word', 'N/A'), "Entity": e.get('entity', 'N/A'), "Score": e.get('score', 'N/A')} for e in output]
75
+ df = pd.DataFrame(entities)
76
+ st.subheader("Tanımlanan Varlıklar")
77
+ st.dataframe(df)
78
+ except Exception as e:
79
+ st.error(f"Bir hata oluştu: {e}")
80
  elif task == "Metin Oluşturma":
81
  output = pipeline_model(input_text, max_length=100, num_return_sequences=1)
82
  st.subheader("Oluşturulan Metin")