jin2li commited on
Commit
36dc8c7
ยท
verified ยท
1 Parent(s): b73345b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -67
app.py CHANGED
@@ -67,7 +67,6 @@ def display_country(country):
67
  def is_numeric_like(value):
68
  if pd.isna(value):
69
  return False
70
-
71
  text = str(value).strip().replace(",", ".").replace("%", "")
72
  return bool(re.fullmatch(r"\d+\.?\d*", text))
73
 
@@ -96,12 +95,7 @@ def get_country_folders():
96
  "venv",
97
  "node_modules",
98
  ]
99
-
100
- folders = [
101
- f for f in os.listdir(".")
102
- if os.path.isdir(f) and f not in exclude
103
- ]
104
-
105
  return folders if folders else ["ํด๋” ์—†์Œ"]
106
 
107
 
@@ -140,7 +134,7 @@ def find_col_by_keywords(df, keywords, default_index=None, exclude_cols=None):
140
  "aqua", "water", "glycerin", "retinol", "niacinamide",
141
  "extract", "acid", "lecithin", "palmitate", "hexanediol",
142
  "triglyceride", "arginine", "crosspolymer", "squalane",
143
- "butylene glycol", "caprylic", "ceramide"
144
  ]):
145
  if any(k in keywords for k in ["inci", "ingredient", "์„ฑ๋ถ„", "์ „์„ฑ๋ถ„", "๊ตฌ์„ฑ"]):
146
  score += 5
@@ -159,11 +153,7 @@ def find_col_by_keywords(df, keywords, default_index=None, exclude_cols=None):
159
 
160
 
161
  def find_main_columns(df):
162
- no_col = find_col_by_keywords(
163
- df,
164
- ["no", "๋ฒˆํ˜ธ", "์ˆœ๋ฒˆ"],
165
- default_index=0
166
- )
167
 
168
  trade_col = find_col_by_keywords(
169
  df,
@@ -186,10 +176,6 @@ def find_main_columns(df):
186
  continue
187
 
188
  header = str(col).lower()
189
-
190
- if header in ["no", "๋ฒˆํ˜ธ", "์ˆœ๋ฒˆ", "index", "#"]:
191
- continue
192
-
193
  values = df[col].dropna()
194
 
195
  if values.empty:
@@ -218,18 +204,13 @@ def find_main_columns(df):
218
  final_amount_col = None
219
 
220
  if numeric_candidates:
221
- # ๊ฐ’์ด ๋งŽ์ด ์ฑ„์›Œ์ง„ ์ˆซ์ž ์ปฌ๋Ÿผ = ๊ตฌ์„ฑ ์„ฑ๋ถ„๋ณ„ ์ตœ์ข… ํ•จ๋Ÿ‰์ผ ๊ฐ€๋Šฅ์„ฑ
222
  final_amount_col = sorted(
223
  numeric_candidates,
224
  key=lambda x: (x["non_null"], x["idx"]),
225
  reverse=True
226
  )[0]["col"]
227
 
228
- # ๊ฐ’์ด ์ ๊ฒŒ ์ฑ„์›Œ์ง„ ์ˆซ์ž ์ปฌ๋Ÿผ = ์›๋ฃŒ ํˆฌ์ž…๋Ÿ‰์ผ ๊ฐ€๋Šฅ์„ฑ
229
- candidates_except_final = [
230
- c for c in numeric_candidates
231
- if c["col"] != final_amount_col
232
- ]
233
 
234
  if candidates_except_final:
235
  amount_col = sorted(
@@ -264,35 +245,24 @@ def build_database(country_folder):
264
  if not os.path.isdir(country_folder):
265
  return None
266
 
267
- files = [
268
- f for f in os.listdir(country_folder)
269
- if f.lower().endswith(".pdf")
270
- ]
271
-
272
  if not files:
273
  return None
274
 
275
  texts = []
276
-
277
- splitter = RecursiveCharacterTextSplitter(
278
- chunk_size=800,
279
- chunk_overlap=100
280
- )
281
 
282
  for filename in files:
283
  try:
284
  file_path = os.path.join(country_folder, filename)
285
-
286
  with pdfplumber.open(file_path) as pdf:
287
  for page in pdf.pages:
288
  text = page.extract_text()
289
-
290
  if text:
291
  chunks = splitter.split_text(
292
  f"[๊ตญ๊ฐ€: {country_folder}] [์ถœ์ฒ˜: {filename}] {text}"
293
  )
294
  texts.extend(chunks)
295
-
296
  except Exception as e:
297
  print(f"PDF ์ฝ๊ธฐ ์˜ค๋ฅ˜: {country_folder}/{filename} / {e}")
298
 
@@ -303,7 +273,6 @@ def build_database(country_folder):
303
  texts,
304
  OpenAIEmbeddings(model="text-embedding-3-small")
305
  )
306
-
307
  VECTOR_DB_CACHE[country_folder] = db
308
  return db
309
 
@@ -313,20 +282,16 @@ def build_database(country_folder):
313
  # =========================
314
  def make_grouped_materials(df):
315
  no_col, trade_col, inci_col, amount_col, final_amount_col = find_main_columns(df)
316
-
317
  df = df.copy()
318
 
319
  if no_col in df.columns:
320
  df[no_col] = df[no_col].ffill()
321
-
322
  if trade_col in df.columns:
323
  df[trade_col] = df[trade_col].ffill()
324
-
325
  if amount_col in df.columns:
326
  df[amount_col] = df[amount_col].ffill()
327
 
328
  group_keys = [no_col, trade_col] if no_col != trade_col else [trade_col]
329
-
330
  grouped_materials = []
331
 
332
  for key, group in df.groupby(group_keys, dropna=True, sort=False):
@@ -341,7 +306,6 @@ def make_grouped_materials(df):
341
  continue
342
 
343
  amount_value = "-"
344
-
345
  if amount_col in group.columns:
346
  amount_values = group[amount_col].dropna().tolist()
347
  if amount_values:
@@ -352,7 +316,6 @@ def make_grouped_materials(df):
352
 
353
  for _, row in group.iterrows():
354
  inci_name = safe_str(row.get(inci_col, ""))
355
-
356
  if inci_name and inci_name.lower() != "nan":
357
  inci_list.append(inci_name)
358
 
@@ -457,36 +420,59 @@ def evaluate_one_country(country, material, llm):
457
  ๊ฒฐ๊ณผ:
458
  ๋น„๊ณ :
459
 
 
 
 
 
 
 
460
  ์ž‘์„ฑ ์›์น™:
461
- 1. ๊ฒฐ๊ณผ๋Š” ์—‘์…€ ์…€ ํ•˜๋‚˜์— ๋ฐ”๋กœ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๊ฒŒ ์งง๊ฒŒ ์ž‘์„ฑํ•œ๋‹ค.
462
  2. ๋ณตํ•ฉ ์›๋ฃŒ๋ผ๋ฉด ๊ตฌ์„ฑ ์„ฑ๋ถ„ ์ „์ฒด๋ฅผ ๋ณด๊ณ  ๊ฐ€์žฅ ํ•ต์‹ฌ ๊ทœ์ œ ์„ฑ๋ถ„ ๊ธฐ์ค€์œผ๋กœ ํŒ๋‹จํ•œ๋‹ค.
463
  3. ๊ทœ์ œ ๋Œ€์ƒ์€ ์›๋ฃŒ๋ช…์ด ์•„๋‹ˆ๋ผ ์‹ค์ œ ๊ตฌ์„ฑ ์„ฑ๋ถ„ ๋˜๋Š” ๊ทœ์ œ ์›๋ฌธ์— ๋“ฑ์žฌ๋œ ์„ฑ๋ถ„๋ช… ๊ธฐ์ค€์ด๋‹ค.
464
  4. ๊ด€๋ จ ๊ทœ์ œ๊ฐ€ ์—†์œผ๋ฉด ๊ฒฐ๊ณผ๋Š” ๋ฐ˜๋“œ์‹œ "์ œํ•œ ์—†์Œ (ํ†ต๊ณผ)" ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
465
- 5. ๊ทœ์ œ๋Š” ์žˆ์œผ๋‚˜ ํ•œ๋„ ์ด๋‚ด์ด๋ฉด "๊ทœ์ œ๋ช… / ์ด๋Ÿ‰ ๊ณ„์‚ฐ, ํ•œ๋„ ์ด๋‚ด(ํ†ต๊ณผ)" ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
466
- 6. ๊ธˆ์ง€ ์„ฑ๋ถ„์ด๊ฑฐ๋‚˜ ๊ธฐ์ค€ ์ดˆ๊ณผ์ด๋ฉด "๊ธˆ์ง€ ์„ฑ๋ถ„(๋ถ€์ ํ•ฉ)" ๋˜๋Š” "ํ•œ๋„ ์ดˆ๊ณผ(๋ถ€์ ํ•ฉ)" ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
467
- 7. ์ •๋ณด๊ฐ€ ๋ถ€์กฑํ•˜๋ฉด "ํ™•์ธ ํ•„์š” / ์‚ฌ์œ " ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
468
- 8. ๋‹ค๋ฅธ ์„ฑ๋ถ„ ๊ทœ์ œ๋ฅผ ๋ถ„์„ ๋Œ€์ƒ ์„ฑ๋ถ„์— ์ž˜๋ชป ์ ์šฉํ•˜์ง€ ๋งˆ.
469
- 9. ๋น„๊ณ ๋Š” ํŠน๋ณ„ํ•œ ์ถ”๊ฐ€ ์„ค๋ช…์ด ์—†์œผ๋ฉด "-" ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
 
 
 
 
 
 
 
 
 
 
 
470
 
471
- ์˜ˆ์‹œ:
472
  ๋Œ€ํ‘œ INCI: Aqua
473
  ๊ฒฐ๊ณผ: ์ œํ•œ ์—†์Œ (ํ†ต๊ณผ)
474
  ๋น„๊ณ : -
475
 
476
- ์˜ˆ์‹œ:
477
- ๋Œ€ํ‘œ INCI: Retinol
478
- ๊ฒฐ๊ณผ: ๋น„ํƒ€๋ฏผA ๊ทœ์ œ / ์ด Retinol 0.1002%(=0.0002+0.100), ํ•œ๋„ 0.3% RE ์ด๋‚ด(ํ†ต๊ณผ)
479
- ๋น„๊ณ : -
480
-
481
- ์˜ˆ์‹œ:
482
  ๋Œ€ํ‘œ INCI: Methylisothiazolinone
483
  ๊ฒฐ๊ณผ: ๋ณด์กด์ œ ๊ทœ์ œ / ์‚ฌ์šฉ ์กฐ๊ฑด ํ™•์ธ ํ•„์š”
484
  ๋น„๊ณ : leave-on / rinse-off ๊ตฌ๋ถ„ ํ•„์š”
 
 
 
 
 
485
  """
486
 
487
  try:
488
  response = llm.invoke(prompt).content
489
- return parse_country_response(response)
 
 
 
 
 
 
 
 
490
 
491
  except Exception as e:
492
  return {
@@ -542,10 +528,7 @@ def style_excel(path, selected_countries):
542
 
543
  elif (
544
  "ํ™•์ธ ํ•„์š”" in value
545
- or (
546
- "๊ทœ์ œ" in value
547
- and "์ œํ•œ ์—†์Œ" not in value
548
- )
549
  ):
550
  cell.fill = yellow_fill
551
  cell.font = red_font
@@ -589,10 +572,7 @@ def process(countries, file):
589
  if not grouped_materials:
590
  return None, None, "โŒ ์—‘์…€์—์„œ ์›๋ฃŒ ์ •๋ณด๋ฅผ ์ฝ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. ์ปฌ๋Ÿผ๋ช…์„ ํ™•์ธํ•ด์ฃผ์„ธ์š”."
591
 
592
- llm = ChatOpenAI(
593
- model="gpt-4o-mini",
594
- temperature=0
595
- )
596
 
597
  output_rows = []
598
 
@@ -621,7 +601,6 @@ def process(countries, file):
621
  note_list.append(f"{col_name}: {note}")
622
 
623
  row_data["๋น„๊ณ "] = " / ".join(note_list) if note_list else "-"
624
-
625
  output_rows.append(row_data)
626
 
627
  result_df = pd.DataFrame(output_rows)
@@ -636,7 +615,6 @@ def process(countries, file):
636
  ])
637
 
638
  out_path = f"screening_result_{safe_country_name}.xlsx"
639
-
640
  result_df.to_excel(out_path, index=False)
641
  style_excel(out_path, countries)
642
 
 
67
  def is_numeric_like(value):
68
  if pd.isna(value):
69
  return False
 
70
  text = str(value).strip().replace(",", ".").replace("%", "")
71
  return bool(re.fullmatch(r"\d+\.?\d*", text))
72
 
 
95
  "venv",
96
  "node_modules",
97
  ]
98
+ folders = [f for f in os.listdir(".") if os.path.isdir(f) and f not in exclude]
 
 
 
 
 
99
  return folders if folders else ["ํด๋” ์—†์Œ"]
100
 
101
 
 
134
  "aqua", "water", "glycerin", "retinol", "niacinamide",
135
  "extract", "acid", "lecithin", "palmitate", "hexanediol",
136
  "triglyceride", "arginine", "crosspolymer", "squalane",
137
+ "butylene glycol", "caprylic", "ceramide", "oil"
138
  ]):
139
  if any(k in keywords for k in ["inci", "ingredient", "์„ฑ๋ถ„", "์ „์„ฑ๋ถ„", "๊ตฌ์„ฑ"]):
140
  score += 5
 
153
 
154
 
155
  def find_main_columns(df):
156
+ no_col = find_col_by_keywords(df, ["no", "๋ฒˆํ˜ธ", "์ˆœ๋ฒˆ"], default_index=0)
 
 
 
 
157
 
158
  trade_col = find_col_by_keywords(
159
  df,
 
176
  continue
177
 
178
  header = str(col).lower()
 
 
 
 
179
  values = df[col].dropna()
180
 
181
  if values.empty:
 
204
  final_amount_col = None
205
 
206
  if numeric_candidates:
 
207
  final_amount_col = sorted(
208
  numeric_candidates,
209
  key=lambda x: (x["non_null"], x["idx"]),
210
  reverse=True
211
  )[0]["col"]
212
 
213
+ candidates_except_final = [c for c in numeric_candidates if c["col"] != final_amount_col]
 
 
 
 
214
 
215
  if candidates_except_final:
216
  amount_col = sorted(
 
245
  if not os.path.isdir(country_folder):
246
  return None
247
 
248
+ files = [f for f in os.listdir(country_folder) if f.lower().endswith(".pdf")]
 
 
 
 
249
  if not files:
250
  return None
251
 
252
  texts = []
253
+ splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=100)
 
 
 
 
254
 
255
  for filename in files:
256
  try:
257
  file_path = os.path.join(country_folder, filename)
 
258
  with pdfplumber.open(file_path) as pdf:
259
  for page in pdf.pages:
260
  text = page.extract_text()
 
261
  if text:
262
  chunks = splitter.split_text(
263
  f"[๊ตญ๊ฐ€: {country_folder}] [์ถœ์ฒ˜: {filename}] {text}"
264
  )
265
  texts.extend(chunks)
 
266
  except Exception as e:
267
  print(f"PDF ์ฝ๊ธฐ ์˜ค๋ฅ˜: {country_folder}/{filename} / {e}")
268
 
 
273
  texts,
274
  OpenAIEmbeddings(model="text-embedding-3-small")
275
  )
 
276
  VECTOR_DB_CACHE[country_folder] = db
277
  return db
278
 
 
282
  # =========================
283
  def make_grouped_materials(df):
284
  no_col, trade_col, inci_col, amount_col, final_amount_col = find_main_columns(df)
 
285
  df = df.copy()
286
 
287
  if no_col in df.columns:
288
  df[no_col] = df[no_col].ffill()
 
289
  if trade_col in df.columns:
290
  df[trade_col] = df[trade_col].ffill()
 
291
  if amount_col in df.columns:
292
  df[amount_col] = df[amount_col].ffill()
293
 
294
  group_keys = [no_col, trade_col] if no_col != trade_col else [trade_col]
 
295
  grouped_materials = []
296
 
297
  for key, group in df.groupby(group_keys, dropna=True, sort=False):
 
306
  continue
307
 
308
  amount_value = "-"
 
309
  if amount_col in group.columns:
310
  amount_values = group[amount_col].dropna().tolist()
311
  if amount_values:
 
316
 
317
  for _, row in group.iterrows():
318
  inci_name = safe_str(row.get(inci_col, ""))
 
319
  if inci_name and inci_name.lower() != "nan":
320
  inci_list.append(inci_name)
321
 
 
420
  ๊ฒฐ๊ณผ:
421
  ๋น„๊ณ :
422
 
423
+ ๋งค์šฐ ์ค‘์š”:
424
+ - "๊ทœ์ œ๋ช…", "์ด๋Ÿ‰ ๊ณ„์‚ฐ", "ํ•œ๋„ ์ด๋‚ด" ๊ฐ™์€ placeholder ๋ฌธ๊ตฌ๋ฅผ ์ ˆ๋Œ€ ์“ฐ์ง€ ๋งˆ.
425
+ - ์‹ค์ œ ๊ทœ์ œ๊ตฐ๋ช…, ์‹ค์ œ ํ•ต์‹ฌ ์„ฑ๋ถ„๋ช…, ์‹ค์ œ ์ด๋Ÿ‰, ์‹ค์ œ ํ•œ๋„๋ฅผ ์“ธ ์ˆ˜ ์žˆ์„ ๋•Œ๋งŒ ๊ตฌ์ฒด์ ์œผ๋กœ ์ž‘์„ฑํ•ด.
426
+ - ๊ตฌ์ฒด๊ฐ’์„ ๊ณ„์‚ฐ/ํ™•์ธํ•  ์ˆ˜ ์—†์œผ๋ฉด "์ œํ•œ ์—†์Œ (ํ†ต๊ณผ)" ๋˜๋Š” "ํ™•์ธ ํ•„์š” / ์‚ฌ์œ "๋กœ ์ž‘์„ฑํ•ด.
427
+ - ๋‹ค๋ฅธ ์„ฑ๋ถ„์˜ ๊ทœ์ œ๋ฅผ ์ž˜๋ชป ์ ์šฉํ•˜์ง€ ๋งˆ.
428
+
429
  ์ž‘์„ฑ ์›์น™:
430
+ 1. ๊ฒฐ๊ณผ๋Š” ์—‘์…€ ์…€ ํ•˜๋‚˜์— ๋ฐ”๋กœ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๊ฒŒ ์งง๊ณ  ์™„๊ฒฐ๋œ ๋ฌธ์žฅ์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
431
  2. ๋ณตํ•ฉ ์›๋ฃŒ๋ผ๋ฉด ๊ตฌ์„ฑ ์„ฑ๋ถ„ ์ „์ฒด๋ฅผ ๋ณด๊ณ  ๊ฐ€์žฅ ํ•ต์‹ฌ ๊ทœ์ œ ์„ฑ๋ถ„ ๊ธฐ์ค€์œผ๋กœ ํŒ๋‹จํ•œ๋‹ค.
432
  3. ๊ทœ์ œ ๋Œ€์ƒ์€ ์›๋ฃŒ๋ช…์ด ์•„๋‹ˆ๋ผ ์‹ค์ œ ๊ตฌ์„ฑ ์„ฑ๋ถ„ ๋˜๋Š” ๊ทœ์ œ ์›๋ฌธ์— ๋“ฑ์žฌ๋œ ์„ฑ๋ถ„๋ช… ๊ธฐ์ค€์ด๋‹ค.
433
  4. ๊ด€๋ จ ๊ทœ์ œ๊ฐ€ ์—†์œผ๋ฉด ๊ฒฐ๊ณผ๋Š” ๋ฐ˜๋“œ์‹œ "์ œํ•œ ์—†์Œ (ํ†ต๊ณผ)" ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
434
+ 5. ๊ทœ์ œ๊ฐ€ ์žˆ๊ณ  ํ•ฉ์‚ฐ์ด ํ•„์š”ํ•˜๋ฉด ์•„๋ž˜ ํ˜•์‹์„ ์šฐ์„  ์‚ฌ์šฉํ•œ๋‹ค.
435
+ "{๊ทœ์ œ๊ตฐ๋ช…} / ์ด {ํ•ต์‹ฌ์„ฑ๋ถ„๋ช…} {์ด๋Ÿ‰}%({ํ•ฉ์‚ฐ์‹}), ํ•œ๋„ {๊ธฐ์ค€์น˜} {๋‹จ์œ„} ์ด๋‚ด(ํ†ต๊ณผ)"
436
+ 6. ๋‹จ์ผ ์„ฑ๋ถ„ ์ œํ•œ์ด๋ฉด ์•„๋ž˜ ํ˜•์‹์„ ์‚ฌ์šฉํ•œ๋‹ค.
437
+ "{๊ทœ์ œ๊ตฐ๋ช…} / {์„ฑ๋ถ„๋ช…} {ํ•จ๋Ÿ‰}%, ํ•œ๋„ {๊ธฐ์ค€์น˜}% ์ด๋‚ด(ํ†ต๊ณผ)"
438
+ 7. ๊ธˆ์ง€ ๋˜๋Š” ์ดˆ๊ณผ์ด๋ฉด ์•„๋ž˜ ํ˜•์‹์„ ์‚ฌ์šฉํ•œ๋‹ค.
439
+ "{๊ทœ์ œ๊ตฐ๋ช…} / ํ•œ๋„ ์ดˆ๊ณผ(๋ถ€์ ํ•ฉ)"
440
+ "{์„ฑ๋ถ„๋ช…} ๊ธˆ์ง€ ์„ฑ๋ถ„(๋ถ€์ ํ•ฉ)"
441
+ 8. ๊ทœ์ œ๋Š” ์žˆ์œผ๋‚˜ leave-on/rinse-off, ์‚ฌ์šฉ๋ถ€์œ„, ์ œํ’ˆ์œ ํ˜• ๋“ฑ ์ •๋ณด๊ฐ€ ๋ถ€์กฑํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์ž‘์„ฑํ•œ๋‹ค.
442
+ "{๊ทœ์ œ๊ตฐ๋ช…} / ์‚ฌ์šฉ ์กฐ๊ฑด ํ™•์ธ ํ•„์š”"
443
+ 9. ๋Œ€ํ‘œ INCI๋Š” ๊ทœ์ œ ํŒ๋‹จ์˜ ์ค‘์‹ฌ์ด ๋˜๋Š” ์„ฑ๋ถ„๋ช…์„ ์ ๋Š”๋‹ค.
444
+ 10. ๋น„๊ณ ๋Š” ํŠน๋ณ„ํ•œ ๋ณด์ถฉ ์„ค๋ช…์ด ์—†์œผ๋ฉด "-" ๋กœ ์ ๋Š”๋‹ค.
445
+
446
+ ์ข‹์€ ์˜ˆ์‹œ:
447
+ ๋Œ€ํ‘œ INCI: Retinol
448
+ ๊ฒฐ๊ณผ: ๋น„ํƒ€๋ฏผA ๊ทœ์ œ / ์ด Retinol 0.1002%(=0.0002+0.100), ํ•œ๋„ 0.3% RE ์ด๋‚ด(ํ†ต๊ณผ)
449
+ ๋น„๊ณ : -
450
 
 
451
  ๋Œ€ํ‘œ INCI: Aqua
452
  ๊ฒฐ๊ณผ: ์ œํ•œ ์—†์Œ (ํ†ต๊ณผ)
453
  ๋น„๊ณ : -
454
 
 
 
 
 
 
 
455
  ๋Œ€ํ‘œ INCI: Methylisothiazolinone
456
  ๊ฒฐ๊ณผ: ๋ณด์กด์ œ ๊ทœ์ œ / ์‚ฌ์šฉ ์กฐ๊ฑด ํ™•์ธ ํ•„์š”
457
  ๋น„๊ณ : leave-on / rinse-off ๊ตฌ๋ถ„ ํ•„์š”
458
+
459
+ ๋‚˜์œ ์˜ˆ์‹œ:
460
+ ๋Œ€ํ‘œ INCI: Retinol
461
+ ๊ฒฐ๊ณผ: ๊ทœ์ œ๋ช… / ์ด๋Ÿ‰ ๊ณ„์‚ฐ, ํ•œ๋„ ์ด๋‚ด(ํ†ต๊ณผ)
462
+ ๋น„๊ณ : -
463
  """
464
 
465
  try:
466
  response = llm.invoke(prompt).content
467
+ parsed = parse_country_response(response)
468
+
469
+ bad_tokens = ["๊ทœ์ œ๋ช…", "์ด๋Ÿ‰ ๊ณ„์‚ฐ", "ํ•œ๋„ ์ด๋‚ด", "๊ทœ์ œ / ์ด๋Ÿ‰"]
470
+ if any(token in parsed["๊ฒฐ๊ณผ"] for token in bad_tokens):
471
+ parsed["๊ฒฐ๊ณผ"] = "ํ™•์ธ ํ•„์š” / ๊ทœ์ œ ์„ธ๋ถ€ ๊ณ„์‚ฐ ์žฌํ™•์ธ ํ•„์š”"
472
+ if parsed["๋น„๊ณ "] == "-":
473
+ parsed["๋น„๊ณ "] = "๋ชจ๋ธ์ด ๊ตฌ์ฒด ๊ทœ์ œ ๋ฌธ๊ตฌ๋ฅผ ์ถฉ๋ถ„ํžˆ ์ƒ์„ฑํ•˜์ง€ ๋ชปํ•จ"
474
+
475
+ return parsed
476
 
477
  except Exception as e:
478
  return {
 
528
 
529
  elif (
530
  "ํ™•์ธ ํ•„์š”" in value
531
+ or ("๊ทœ์ œ" in value and "์ œํ•œ ์—†์Œ" not in value)
 
 
 
532
  ):
533
  cell.fill = yellow_fill
534
  cell.font = red_font
 
572
  if not grouped_materials:
573
  return None, None, "โŒ ์—‘์…€์—์„œ ์›๋ฃŒ ์ •๋ณด๋ฅผ ์ฝ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. ์ปฌ๋Ÿผ๋ช…์„ ํ™•์ธํ•ด์ฃผ์„ธ์š”."
574
 
575
+ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
 
 
 
576
 
577
  output_rows = []
578
 
 
601
  note_list.append(f"{col_name}: {note}")
602
 
603
  row_data["๋น„๊ณ "] = " / ".join(note_list) if note_list else "-"
 
604
  output_rows.append(row_data)
605
 
606
  result_df = pd.DataFrame(output_rows)
 
615
  ])
616
 
617
  out_path = f"screening_result_{safe_country_name}.xlsx"
 
618
  result_df.to_excel(out_path, index=False)
619
  style_excel(out_path, countries)
620