Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|