Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,6 @@ MODEL_OPTIONS = {
|
|
21 |
# Hedeflenen bölümler
|
22 |
target_items = ["item_1", "item_1A", "item_7", "item_8", "item_9A"]
|
23 |
|
24 |
-
# Yanlış şirket adlarını düzeltme fonksiyonu
|
25 |
def fix_company_names(text, correct_name="Quotient Technology Inc."):
|
26 |
wrong_names = [
|
27 |
"Bridgeline", "Guidewire", "AppFolio", "GTY",
|
@@ -31,13 +30,11 @@ def fix_company_names(text, correct_name="Quotient Technology Inc."):
|
|
31 |
text = text.replace(wrong, correct_name)
|
32 |
return text
|
33 |
|
34 |
-
# Token sayısına göre metni kırpma
|
35 |
def safe_trim(text, tokenizer, max_tokens):
|
36 |
input_ids = tokenizer.encode(text, truncation=False)
|
37 |
input_ids = input_ids[:max_tokens]
|
38 |
return tokenizer.decode(input_ids, skip_special_tokens=True)
|
39 |
|
40 |
-
# Özetleme işlemi
|
41 |
def summarize_json(json_file, selected_model, is_turkish):
|
42 |
model_cfg = MODEL_OPTIONS[selected_model]
|
43 |
model_id = model_cfg["model_id"]
|
@@ -69,8 +66,6 @@ def summarize_json(json_file, selected_model, is_turkish):
|
|
69 |
eng_summary = summarizer(trimmed, max_length=max_len, min_length=min_len, do_sample=False)[0]["summary_text"]
|
70 |
|
71 |
final = en2tr(eng_summary)[0]["translation_text"] if is_turkish else eng_summary
|
72 |
-
|
73 |
-
# Şirket adı düzeltmesi burada uygulanır
|
74 |
summary_output[item] = fix_company_names(final)
|
75 |
|
76 |
output_path = "summary_output.json"
|
@@ -83,7 +78,28 @@ def summarize_json(json_file, selected_model, is_turkish):
|
|
83 |
|
84 |
# Gradio Arayüz
|
85 |
with gr.Blocks(title="10-K Summary Generator") as demo:
|
86 |
-
gr.HTML("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
with gr.Row():
|
89 |
model_selector = gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), value="BART (10k-BART)", label="Select Model")
|
@@ -105,4 +121,4 @@ with gr.Blocks(title="10-K Summary Generator") as demo:
|
|
105 |
outputs=[output_file, summary_text]
|
106 |
)
|
107 |
|
108 |
-
demo.launch()
|
|
|
21 |
# Hedeflenen bölümler
|
22 |
target_items = ["item_1", "item_1A", "item_7", "item_8", "item_9A"]
|
23 |
|
|
|
24 |
def fix_company_names(text, correct_name="Quotient Technology Inc."):
|
25 |
wrong_names = [
|
26 |
"Bridgeline", "Guidewire", "AppFolio", "GTY",
|
|
|
30 |
text = text.replace(wrong, correct_name)
|
31 |
return text
|
32 |
|
|
|
33 |
def safe_trim(text, tokenizer, max_tokens):
|
34 |
input_ids = tokenizer.encode(text, truncation=False)
|
35 |
input_ids = input_ids[:max_tokens]
|
36 |
return tokenizer.decode(input_ids, skip_special_tokens=True)
|
37 |
|
|
|
38 |
def summarize_json(json_file, selected_model, is_turkish):
|
39 |
model_cfg = MODEL_OPTIONS[selected_model]
|
40 |
model_id = model_cfg["model_id"]
|
|
|
66 |
eng_summary = summarizer(trimmed, max_length=max_len, min_length=min_len, do_sample=False)[0]["summary_text"]
|
67 |
|
68 |
final = en2tr(eng_summary)[0]["translation_text"] if is_turkish else eng_summary
|
|
|
|
|
69 |
summary_output[item] = fix_company_names(final)
|
70 |
|
71 |
output_path = "summary_output.json"
|
|
|
78 |
|
79 |
# Gradio Arayüz
|
80 |
with gr.Blocks(title="10-K Summary Generator") as demo:
|
81 |
+
gr.HTML("""
|
82 |
+
<style>
|
83 |
+
body {
|
84 |
+
background-color: #f9f9f9;
|
85 |
+
color: #2c3e50;
|
86 |
+
}
|
87 |
+
h2 {
|
88 |
+
text-align: center;
|
89 |
+
color: #2c3e50;
|
90 |
+
font-family: Arial, sans-serif;
|
91 |
+
}
|
92 |
+
.gr-button {
|
93 |
+
background-color: #f39c12 !important;
|
94 |
+
color: white !important;
|
95 |
+
font-weight: bold;
|
96 |
+
}
|
97 |
+
.gr-button:hover {
|
98 |
+
background-color: #e67e22 !important;
|
99 |
+
}
|
100 |
+
</style>
|
101 |
+
<h2> 10-K Financial Report Summarizer</h2>
|
102 |
+
""")
|
103 |
|
104 |
with gr.Row():
|
105 |
model_selector = gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), value="BART (10k-BART)", label="Select Model")
|
|
|
121 |
outputs=[output_file, summary_text]
|
122 |
)
|
123 |
|
124 |
+
demo.launch()
|