Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline,
|
3 |
import pandas as pd
|
4 |
|
5 |
# Uygulama sayfa ayarları
|
@@ -52,10 +52,10 @@ def load_pipeline(model_name, task_type):
|
|
52 |
# Görev ve modele göre pipeline yükleme
|
53 |
model_dict = {
|
54 |
"Metin Sınıflandırma": "nlptown/bert-base-multilingual-uncased-sentiment",
|
55 |
-
"Metin Analizi": "dbmdz/bert-base-turkish-cased",
|
56 |
"Duygu Analizi": "cardiffnlp/twitter-roberta-base-sentiment",
|
57 |
"Metin Oluşturma": "gpt2",
|
58 |
-
"Varlık Tanıma": "dbmdz/bert-base-turkish-cased"
|
59 |
}
|
60 |
|
61 |
pipeline_model = load_pipeline(model_dict[task], task)
|
@@ -102,8 +102,23 @@ if st.button("Çalıştır") and input_text:
|
|
102 |
output = pipeline_model(input_text)
|
103 |
|
104 |
# Process entities
|
105 |
-
processed_entities =
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
st.subheader("Tanımlanan Varlıklar")
|
108 |
st.dataframe(df)
|
109 |
|
@@ -129,7 +144,7 @@ if st.button("Çalıştır") and input_text:
|
|
129 |
formatted_text += original_text[last_end:]
|
130 |
return formatted_text
|
131 |
|
132 |
-
formatted_text = format_text(processed_entities, input_text)
|
133 |
st.subheader("Analiz Edilen Metin")
|
134 |
st.markdown(f"<p>{formatted_text}</p>", unsafe_allow_html=True)
|
135 |
elif task == "Metin Oluşturma":
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification, AutoModelForSequenceClassification, AutoModelForCausalLM
|
3 |
import pandas as pd
|
4 |
|
5 |
# Uygulama sayfa ayarları
|
|
|
52 |
# Görev ve modele göre pipeline yükleme
|
53 |
model_dict = {
|
54 |
"Metin Sınıflandırma": "nlptown/bert-base-multilingual-uncased-sentiment",
|
55 |
+
"Metin Analizi": "dbmdz/bert-base-turkish-cased",
|
56 |
"Duygu Analizi": "cardiffnlp/twitter-roberta-base-sentiment",
|
57 |
"Metin Oluşturma": "gpt2",
|
58 |
+
"Varlık Tanıma": "dbmdz/bert-base-turkish-cased"
|
59 |
}
|
60 |
|
61 |
pipeline_model = load_pipeline(model_dict[task], task)
|
|
|
102 |
output = pipeline_model(input_text)
|
103 |
|
104 |
# Process entities
|
105 |
+
processed_entities = []
|
106 |
+
for entity in output:
|
107 |
+
word = entity['word']
|
108 |
+
label = entity['entity']
|
109 |
+
score = entity['score']
|
110 |
+
start = entity['start']
|
111 |
+
end = entity['end']
|
112 |
+
processed_entities.append({
|
113 |
+
'word': word,
|
114 |
+
'label': label,
|
115 |
+
'score': score,
|
116 |
+
'start': start,
|
117 |
+
'end': end
|
118 |
+
})
|
119 |
+
|
120 |
+
# Aggregate entities
|
121 |
+
df = pd.DataFrame(process_entities(processed_entities, input_text))
|
122 |
st.subheader("Tanımlanan Varlıklar")
|
123 |
st.dataframe(df)
|
124 |
|
|
|
144 |
formatted_text += original_text[last_end:]
|
145 |
return formatted_text
|
146 |
|
147 |
+
formatted_text = format_text(process_entities(processed_entities, input_text), input_text)
|
148 |
st.subheader("Analiz Edilen Metin")
|
149 |
st.markdown(f"<p>{formatted_text}</p>", unsafe_allow_html=True)
|
150 |
elif task == "Metin Oluşturma":
|