Spaces:
Running
Running
UI tarafına sayfa minimum değeri ve görünürlük kontrolü eklendi; PDF sayfa aralığı güvenli hale getirildi
Browse files- pdf_reader.py +9 -2
- ui.py +2 -2
pdf_reader.py
CHANGED
@@ -7,8 +7,15 @@ def extract_text_chunks_from_pdf(pdf_input, start=1, end=None, max_chars=4000):
|
|
7 |
else:
|
8 |
doc = fitz.open(pdf_input)
|
9 |
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
chunks = []
|
14 |
current_chunk = ""
|
|
|
7 |
else:
|
8 |
doc = fitz.open(pdf_input)
|
9 |
|
10 |
+
total_pages = len(doc)
|
11 |
+
|
12 |
+
# Sayfa sınırı kontrolleri
|
13 |
+
if start < 1:
|
14 |
+
start = 1
|
15 |
+
if end is None or end > total_pages:
|
16 |
+
end = total_pages
|
17 |
+
if end < start:
|
18 |
+
end = start
|
19 |
|
20 |
chunks = []
|
21 |
current_chunk = ""
|
ui.py
CHANGED
@@ -44,8 +44,8 @@ with gr.Blocks() as demo:
|
|
44 |
manual_input = gr.Textbox(lines=5, label="Metni Manuel Gir")
|
45 |
|
46 |
with gr.Row(visible=False) as page_controls:
|
47 |
-
start_page = gr.Number(label="Başlangıç Sayfası", value=1, precision=0)
|
48 |
-
end_page = gr.Number(label="Bitiş Sayfası", value=5, precision=0)
|
49 |
|
50 |
def show_page_controls(pdf):
|
51 |
return gr.update(visible=True)
|
|
|
44 |
manual_input = gr.Textbox(lines=5, label="Metni Manuel Gir")
|
45 |
|
46 |
with gr.Row(visible=False) as page_controls:
|
47 |
+
start_page = gr.Number(label="Başlangıç Sayfası", value=1, minimum=1, precision=0)
|
48 |
+
end_page = gr.Number(label="Bitiş Sayfası", value=5, minimum=1, precision=0)
|
49 |
|
50 |
def show_page_controls(pdf):
|
51 |
return gr.update(visible=True)
|