Spaces:
Running
Running
Update content_utils.py
Browse files- content_utils.py +28 -22
content_utils.py
CHANGED
@@ -258,7 +258,7 @@ def extract_slide_section_from_executor(executor_response: str, slide_num: int)
|
|
258 |
return ""
|
259 |
|
260 |
def parse_slide_section(section: str, default_title: str) -> Dict:
|
261 |
-
"""์ฌ๋ผ์ด๋ ์น์
์์ ์ฝํ
์ธ ํ์ฑ"""
|
262 |
try:
|
263 |
content = {
|
264 |
"subtitle": default_title,
|
@@ -266,35 +266,41 @@ def parse_slide_section(section: str, default_title: str) -> Dict:
|
|
266 |
}
|
267 |
|
268 |
lines = section.split('\n')
|
269 |
-
in_content_section = False
|
270 |
|
271 |
for line in lines:
|
272 |
line = line.strip()
|
273 |
if not line:
|
274 |
continue
|
275 |
|
276 |
-
# ๋ถ์ ๋ชฉ ์ฐพ๊ธฐ
|
277 |
-
if any(marker in line for marker in ['๋ถ์ ๋ชฉ:', '
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
# ํต์ฌ ๋ด์ฉ ์น์
์์
|
283 |
-
elif any(marker in line for marker in ['ํต์ฌ ๋ด์ฉ:', 'Key Points:', '๋ด์ฉ:', 'Content:']):
|
284 |
-
in_content_section = True
|
285 |
-
|
286 |
-
# ๋ค๋ฅธ ์น์
์์ ์ ์ค๋จ
|
287 |
-
elif any(marker in line for marker in ['๋ฐํ์ ๋
ธํธ:', 'Speaker Notes:', '์๊ฐ ์๋ฃ:', 'Visual:']):
|
288 |
-
in_content_section = False
|
289 |
|
290 |
-
# ๋ถ๋ฆฟ ํฌ์ธํธ ์์ง
|
291 |
-
elif
|
292 |
-
|
293 |
-
len(line) >
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
):
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
return content if len(content["bullet_points"]) > 0 else None
|
300 |
|
|
|
258 |
return ""
|
259 |
|
260 |
def parse_slide_section(section: str, default_title: str) -> Dict:
|
261 |
+
"""์ฌ๋ผ์ด๋ ์น์
์์ ์ฝํ
์ธ ํ์ฑ - ๋ ์ ์ฐํ๊ฒ"""
|
262 |
try:
|
263 |
content = {
|
264 |
"subtitle": default_title,
|
|
|
266 |
}
|
267 |
|
268 |
lines = section.split('\n')
|
|
|
269 |
|
270 |
for line in lines:
|
271 |
line = line.strip()
|
272 |
if not line:
|
273 |
continue
|
274 |
|
275 |
+
# ๋ถ์ ๋ชฉ ์ฐพ๊ธฐ (๋ ์ ์ฐํ ํจํด)
|
276 |
+
if any(marker in line.lower() for marker in ['๋ถ์ ๋ชฉ:', 'subtitle:', '๋ถ์ :', '์ ๋ชฉ:']):
|
277 |
+
if ':' in line:
|
278 |
+
subtitle = line.split(':', 1)[1].strip()
|
279 |
+
if subtitle:
|
280 |
+
content["subtitle"] = subtitle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
|
282 |
+
# ๋ถ๋ฆฟ ํฌ์ธํธ ์์ง (๋ ํฌ๊ด์ ์ผ๋ก)
|
283 |
+
elif (
|
284 |
+
# ์ด๋ชจ์ง๋ก ์์
|
285 |
+
(len(line) > 0 and ord(line[0]) >= 0x1F300) or
|
286 |
+
# ๋ถ๋ฆฟ ๊ธฐํธ๋ก ์์
|
287 |
+
line.startswith(('โข', '-', '*', 'ยท', 'โช', 'โธ')) or
|
288 |
+
# ์ซ์๋ก ์์
|
289 |
+
re.match(r'^\d+[.)]\s', line) or
|
290 |
+
# "ํต์ฌ ๋ด์ฉ:" ์ดํ์ ๋ชจ๋ ์ค
|
291 |
+
('ํต์ฌ' in section and line and len(line) > 10 and
|
292 |
+
not any(skip in line for skip in [':', '์ ๋ชฉ', 'Title', '๋
ธํธ', 'Notes']))
|
293 |
):
|
294 |
+
# ๋ถํ์ํ ๊ธฐํธ ์ ๊ฑฐ
|
295 |
+
clean_line = re.sub(r'^[โข\-\*ยทโชโธ\d+.)]\s*', '', line).strip()
|
296 |
+
|
297 |
+
# ์๋ฏธ ์๋ ๋ด์ฉ์ธ์ง ํ์ธ
|
298 |
+
if clean_line and len(clean_line) > 5:
|
299 |
+
# ์ด๋ชจ์ง๊ฐ ์์ผ๋ฉด ๊ทธ๋๋ก, ์์ผ๋ฉด โข ์ถ๊ฐ
|
300 |
+
if len(line) > 0 and ord(line[0]) >= 0x1F300:
|
301 |
+
content["bullet_points"].append(line)
|
302 |
+
else:
|
303 |
+
content["bullet_points"].append(f"โข {clean_line}")
|
304 |
|
305 |
return content if len(content["bullet_points"]) > 0 else None
|
306 |
|