openfree commited on
Commit
1bbaec5
ยท
verified ยท
1 Parent(s): b2f8727

Update content_utils.py

Browse files
Files changed (1) hide show
  1. 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 ['๋ถ€์ œ๋ชฉ:', 'Subtitle:', '๋ถ€์ œ:']):
278
- subtitle = line.split(':', 1)[1].strip() if ':' in line else ""
279
- if subtitle:
280
- content["subtitle"] = subtitle
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 in_content_section or (
292
- (line.startswith(('โ€ข', '-', '*', 'ยท')) or re.match(r'^\d+\.', line)) and
293
- len(line) > 10
 
 
 
 
 
 
 
294
  ):
295
- clean_line = re.sub(r'^[โ€ข\-\*ยท\d+\.]', '', line).strip()
296
- if clean_line and not any(skip in clean_line for skip in ["Point", "ํฌ์ธํŠธ", ":", "์ œ๋ชฉ", "Title"]):
297
- content["bullet_points"].append(f"โ€ข {clean_line}")
 
 
 
 
 
 
 
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