Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,17 +19,20 @@
|
|
| 19 |
# - ์์
์ ์ฑ๋ถ ์ ์ฒด ์คํฌ๋ฆฌ๋
|
| 20 |
# - ๋จ์ผ ์ฑ๋ถ ๊ฒ์
|
| 21 |
# - ์ ์ฒด ์คํฌ๋ฆฌ๋: MFDS ๊ฒ์์ด 0๊ฐ ๋ฐฉ์ง
|
| 22 |
-
# - ๋จ์ผ ์ฑ๋ถ ๊ฒ์์ ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ
|
| 23 |
# - ๊ตญ๊ฐ๋ณ ๊ท์ ํด๋ ๊ฒ์
|
| 24 |
# - FAISS ๋์คํฌ ์บ์
|
| 25 |
# - COOS ์ ๊ฑฐ
|
| 26 |
# - ํฅ๋ฃ๋ ์ ๊ตญ๊ฐ ํ์ธ ํ์
|
|
|
|
|
|
|
|
|
|
| 27 |
# - ๊ณ ์ํ ์ฑ๋ถ Pass ์๋ ๋ฐฉ์ง
|
| 28 |
# - Formular Ingredients Statement ์์ ์ถ๋ ฅ
|
| 29 |
# - ์๋ณธ TOTAL ํ ์ ๊ฑฐ ํ ์ TOTAL ํ 1๊ฐ๋ง ์์ฑ
|
| 30 |
# - ์ซ์ ์๋ '๋ฐฐํฉํ๋'๋ '๋ฐฐํฉํ๋ ํ์ธ ํ์'๋ก ํ์
|
| 31 |
# - Salicylic Acid ์์ฒด๋ง ์ ํ ํ๋ณด ์ฒ๋ฆฌ
|
| 32 |
-
#
|
| 33 |
# ============================================================
|
| 34 |
|
| 35 |
import os
|
|
@@ -392,6 +395,36 @@ FRAGRANCE_ALLERGEN_RULES = {
|
|
| 392 |
},
|
| 393 |
}
|
| 394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
# ============================================================
|
| 397 |
# 2. ๊ณตํต ์ ํธ
|
|
@@ -411,7 +444,7 @@ def safe_str(x):
|
|
| 411 |
def normalize_text(text):
|
| 412 |
text = safe_str(text).lower()
|
| 413 |
text = text.replace("ฮฑ", "alpha").replace("ฮฒ", "beta")
|
| 414 |
-
text = re.sub(r"[^a-z0-9๊ฐ-ํฃ]+", " ", text)
|
| 415 |
return re.sub(r"\s+", " ", text).strip()
|
| 416 |
|
| 417 |
|
|
@@ -591,6 +624,31 @@ def match_rule_key(material, component, rule_dict):
|
|
| 591 |
return None
|
| 592 |
|
| 593 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
def is_cas_like(text):
|
| 595 |
text = safe_str(text)
|
| 596 |
return bool(re.match(r"^\d{2,7}-\d{2}-\d$", text))
|
|
@@ -632,6 +690,12 @@ def evaluate_plain_fragrance_rule(country, material, component):
|
|
| 632 |
|
| 633 |
|
| 634 |
def get_restricted_candidate_reason(material, component):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
if is_plain_fragrance_component(material, component):
|
| 636 |
return "ํฅ๋ฃ"
|
| 637 |
|
|
@@ -643,10 +707,6 @@ def get_restricted_candidate_reason(material, component):
|
|
| 643 |
if preservative_key:
|
| 644 |
return "๋ณด์กด์ /์ ํ์ฑ๋ถ"
|
| 645 |
|
| 646 |
-
functional_key = match_rule_key(material, component, FUNCTIONAL_KOREA_RULES)
|
| 647 |
-
if functional_key:
|
| 648 |
-
return "๊ธฐ๋ฅ์ฑ ์ฑ๋ถ"
|
| 649 |
-
|
| 650 |
identity = get_identity_text(material, component)
|
| 651 |
for _, rule in FRAGRANCE_ALLERGEN_RULES.items():
|
| 652 |
for alias in rule.get("aliases", []):
|
|
@@ -656,7 +716,6 @@ def get_restricted_candidate_reason(material, component):
|
|
| 656 |
|
| 657 |
function_text = normalize_text(component.get("FUNCTION", ""))
|
| 658 |
inci_text = normalize_text(component.get("INCI Name", ""))
|
| 659 |
-
korean_text = normalize_text(component.get("ํ๊ธ ์ฑ๋ถ๋ช
", ""))
|
| 660 |
|
| 661 |
high_risk_words = [
|
| 662 |
"sunscreen",
|
|
@@ -672,9 +731,6 @@ def get_restricted_candidate_reason(material, component):
|
|
| 672 |
if any(w in function_text for w in high_risk_words) or any(w in inci_text for w in high_risk_words):
|
| 673 |
return "์ ํ ๊ฐ๋ฅ์ฑ ์ฑ๋ถ"
|
| 674 |
|
| 675 |
-
# Salicylic Acid ์์ฒด๋ง ์ ํ ๊ฐ๋ฅ์ฑ ์ฑ๋ถ์ผ๋ก ์ฒ๋ฆฌํ๋ค.
|
| 676 |
-
# Capryloyl Salicylic Acid, Betaine Salicylate, Ethylhexyl Salicylate ๋ฑ
|
| 677 |
-
# ์ด๋ฆ์ salicylic/salicylate๊ฐ ํฌํจ๋ ์ ๋์ฒด๋ ์ฌ๊ธฐ์ ์๋ ํ์ธ ํ์ ์ฒ๋ฆฌํ์ง ์๋๋ค.
|
| 678 |
if normalize_compact(component.get("INCI Name", "")) == normalize_compact("Salicylic Acid"):
|
| 679 |
return "์ ํ ๊ฐ๋ฅ์ฑ ์ฑ๋ถ"
|
| 680 |
|
|
@@ -704,6 +760,8 @@ def is_country_result_issue(text):
|
|
| 704 |
"์ฃผ์",
|
| 705 |
"๊ฒฝ๊ณ ",
|
| 706 |
"๋ฐฐํฉํ๋ ํ์ธ ํ์",
|
|
|
|
|
|
|
| 707 |
]
|
| 708 |
|
| 709 |
return any(k in text for k in keywords)
|
|
@@ -731,6 +789,16 @@ def normalize_formula_country_text(text, country_col="", inci_name="", amount_te
|
|
| 731 |
|
| 732 |
lower = text.lower()
|
| 733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
if LIMIT_CHECK_TEXT in text:
|
| 735 |
return LIMIT_CHECK_TEXT
|
| 736 |
|
|
@@ -740,6 +808,12 @@ def normalize_formula_country_text(text, country_col="", inci_name="", amount_te
|
|
| 740 |
if "ํฅ๋ฃ" in text or "fragrance" in lower or "parfum" in lower:
|
| 741 |
return NEED_CHECK_TEXT
|
| 742 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 743 |
if "octocrylene" in inci_norm or "์ฅํ ํฌ๋ฆด๋ " in inci_norm:
|
| 744 |
if country_col == "EU":
|
| 745 |
return "๋ฐฐํฉ ํ๋:\n์คํ๋ ์ด: 9% /\n๊ธฐํ์ ํ: 10%"
|
|
@@ -774,16 +848,6 @@ def normalize_formula_country_text(text, country_col="", inci_name="", amount_te
|
|
| 774 |
return "๋ฐฐํฉํ๋: 3%"
|
| 775 |
return "๋ฐฐํฉํ๋: 5%"
|
| 776 |
|
| 777 |
-
if (
|
| 778 |
-
"๋ฐฐํฉ๊ธ์ง" in text
|
| 779 |
-
or "์ฌ์ฉ๊ธ์ง" in text
|
| 780 |
-
or "๊ธ์ง" in text
|
| 781 |
-
or "prohibited" in lower
|
| 782 |
-
or "banned" in lower
|
| 783 |
-
or "not allowed" in lower
|
| 784 |
-
):
|
| 785 |
-
return "๋ฐฐํฉ๊ธ์ง"
|
| 786 |
-
|
| 787 |
if (
|
| 788 |
"์ด๊ณผ" in text
|
| 789 |
or "๋ถ์ ํฉ" in text
|
|
@@ -1164,6 +1228,7 @@ def find_best_col(df, keywords, default_index=None, exclude_cols=None):
|
|
| 1164 |
"ceramide",
|
| 1165 |
"glycol",
|
| 1166 |
"retinol",
|
|
|
|
| 1167 |
]
|
| 1168 |
|
| 1169 |
if any(x in sample for x in markers):
|
|
@@ -1508,11 +1573,6 @@ def install_playwright_chromium_once():
|
|
| 1508 |
|
| 1509 |
|
| 1510 |
def extract_terms_for_live_lookup(row_items):
|
| 1511 |
-
"""
|
| 1512 |
-
์ ์ฒด ์์
์คํฌ๋ฆฌ๋์์ ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ์ฉ ๊ฒ์์ด๋ฅผ ๋ง๋ ๋ค.
|
| 1513 |
-
ํฅ๋ฃ๋ฅผ ์ ์ธํ ๋ชจ๋ ์ฑ๋ถ์์ INCI Name โ ํ๊ธ ์ฑ๋ถ๋ช
โ CAS.No ์์๋ก 1๊ฐ์ฉ ์ถ์ถํ๋ค.
|
| 1514 |
-
"""
|
| 1515 |
-
|
| 1516 |
terms = []
|
| 1517 |
|
| 1518 |
for item in row_items:
|
|
@@ -1522,6 +1582,9 @@ def extract_terms_for_live_lookup(row_items):
|
|
| 1522 |
if is_plain_fragrance_component(material, comp):
|
| 1523 |
continue
|
| 1524 |
|
|
|
|
|
|
|
|
|
|
| 1525 |
candidate_values = [
|
| 1526 |
comp.get("INCI Name", ""),
|
| 1527 |
comp.get("ํ๊ธ ์ฑ๋ถ๋ช
", ""),
|
|
@@ -1998,6 +2061,55 @@ def evaluate_live_detail_rule(country, material, component, live_df):
|
|
| 1998 |
# 7. ๋ก์ปฌ ๊ท์น ํ์
|
| 1999 |
# ============================================================
|
| 2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2001 |
def evaluate_limit_rule(country, material, component, rule_group, rule_type_name):
|
| 2002 |
ckey = country_key(country)
|
| 2003 |
key = match_rule_key(material, component, rule_group)
|
|
@@ -2059,6 +2171,18 @@ def evaluate_local_rules(country, material, component, ingredient_totals, ingred
|
|
| 2059 |
ckey = country_key(country)
|
| 2060 |
amount = component.get("amount_float")
|
| 2061 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2062 |
plain_fragrance = evaluate_plain_fragrance_rule(country, material, component)
|
| 2063 |
if plain_fragrance is not None:
|
| 2064 |
return plain_fragrance
|
|
@@ -2171,6 +2295,14 @@ def sanitize_country_result(parsed, country_col="", component=None, high_risk_re
|
|
| 2171 |
|
| 2172 |
display_text = safe_str(parsed.get("ํ์๋ฌธ๊ตฌ", ""))
|
| 2173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2174 |
if high_risk_reason and result_text == NO_EVIDENCE_TEXT:
|
| 2175 |
result_text = f"{high_risk_reason} / {representative} / {country_col} ์ ํ ์ฌ๋ถ ํ์ธ ํ์"
|
| 2176 |
display_text = NEED_CHECK_TEXT
|
|
@@ -2259,6 +2391,18 @@ def evaluate_component_with_llm(country, material, component, llm, target_id="")
|
|
| 2259 |
amount_text = format_percent(amount) if amount is not None else "ํจ๋ ํ์ธ ํ์"
|
| 2260 |
high_risk_reason = get_restricted_candidate_reason(material, component)
|
| 2261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2262 |
if not inci_name and not korean_name and not cas_no:
|
| 2263 |
return {"๋ํ INCI": "-", "๊ฒฐ๊ณผ": "", "ํ์๋ฌธ๊ตฌ": "", "๋น๊ณ ": "-"}
|
| 2264 |
|
|
@@ -2401,9 +2545,20 @@ def evaluate_components_with_llm_batch(country, targets, llm):
|
|
| 2401 |
inci_name = safe_str(comp.get("INCI Name", ""))
|
| 2402 |
korean_name = safe_str(comp.get("ํ๊ธ ์ฑ๋ถ๋ช
", ""))
|
| 2403 |
cas_no = safe_str(comp.get("CAS.No", ""))
|
|
|
|
|
|
|
| 2404 |
high_risk_reason = get_restricted_candidate_reason(material, comp)
|
| 2405 |
|
| 2406 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2407 |
result = {
|
| 2408 |
"๋ํ INCI": inci_name or korean_name or cas_no or "-",
|
| 2409 |
"๊ฒฐ๊ณผ": f"{high_risk_reason} / {inci_name or korean_name or cas_no} / {country_col} ์ ํ ์ฌ๋ถ ํ์ธ ํ์",
|
|
@@ -2447,6 +2602,26 @@ def evaluate_components_with_llm_batch(country, targets, llm):
|
|
| 2447 |
amount_text = format_percent(amount) if amount is not None else "ํจ๋ ํ์ธ ํ์"
|
| 2448 |
high_risk_reason = get_restricted_candidate_reason(material, comp)
|
| 2449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2450 |
search_text = f"""
|
| 2451 |
๊ตญ๊ฐ/์ฑ๋: {country}
|
| 2452 |
์๋ฃ๋ช
๊ตญ๋ฌธ: {material.get("Trade name(๊ตญ๋ฌธ)", "")}
|
|
@@ -3014,6 +3189,44 @@ def process(
|
|
| 3014 |
gpt_targets = []
|
| 3015 |
|
| 3016 |
for item in row_items:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3017 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 3018 |
country=country,
|
| 3019 |
material=item["material"],
|
|
@@ -3225,6 +3438,9 @@ def extract_single_lookup_terms(query, material, component):
|
|
| 3225 |
if not query:
|
| 3226 |
return []
|
| 3227 |
|
|
|
|
|
|
|
|
|
|
| 3228 |
return [query]
|
| 3229 |
|
| 3230 |
|
|
@@ -3271,6 +3487,8 @@ def simplify_single_note(note):
|
|
| 3271 |
"๊ณ ์ํ๊ตฐ ํ๋ณด์ด๋ ๊ตญ๊ฐ๋ณ ๊ท์ ํ์ผ์์ ์ง์ ๊ทผ๊ฑฐ ๋ฏธ๊ฒ์ถ. Pass ์ฒ๋ฆฌํ์ง ์์.": "๊ตญ๊ฐ๋ณ ๊ท์ ํ์ผ ๋ด ์ง์ ๊ทผ๊ฑฐ ๋ฏธ๊ฒ์ถ",
|
| 3272 |
"ํด๋น ๊ตญ๊ฐ/์ฑ๋ ๊ท์ DB ์์. ๊ณ ์ํ๊ตฐ ํ๋ณด์ด๋ฏ๋ก Pass ์ฒ๋ฆฌํ์ง ์์.": "ํด๋น ๊ตญ๊ฐ ๊ท์ DB ์์",
|
| 3273 |
"ํฅ๋ฃ๋ ์ธ๋ถ ๊ตฌ์ฑ์ฑ๋ถ ๋ฐ ์๋ ๋ฅด๊ฒ ํ์๋์ ์ฌ๋ถ ํ์ธ ํ์. ์๋ Pass ์ฒ๋ฆฌ ๊ธ์ง.": "ํฅ๋ฃ ์ธ๋ถ ์กฐ์ฑ ๋ฐ ์๋ ๋ฅด๊ฒ ํ์ธ ํ์",
|
|
|
|
|
|
|
| 3274 |
}
|
| 3275 |
|
| 3276 |
if note in replace_map:
|
|
@@ -3315,15 +3533,18 @@ def process_single_ingredient(
|
|
| 3315 |
mfds_df = pd.DataFrame()
|
| 3316 |
terms = extract_single_lookup_terms(single_query, material, component)
|
| 3317 |
|
| 3318 |
-
|
| 3319 |
-
|
| 3320 |
-
|
| 3321 |
-
|
| 3322 |
-
|
| 3323 |
-
|
| 3324 |
-
|
| 3325 |
-
|
| 3326 |
-
|
|
|
|
|
|
|
|
|
|
| 3327 |
|
| 3328 |
ingredient_totals = defaultdict(float)
|
| 3329 |
ingredient_amount_parts = defaultdict(list)
|
|
@@ -3347,6 +3568,54 @@ def process_single_ingredient(
|
|
| 3347 |
final_result = None
|
| 3348 |
source = ""
|
| 3349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3350 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 3351 |
country=country,
|
| 3352 |
material=material,
|
|
@@ -3433,7 +3702,7 @@ def process_single_ingredient(
|
|
| 3433 |
f"- ์ ํ ๊ตญ๊ฐ ์: {len(countries)}๊ฐ\n"
|
| 3434 |
f"- MFDS ์ํ: {mfds_live_msg}\n"
|
| 3435 |
f"- MFDS ์กฐํ ๋์: {', '.join(terms) if terms else '์์'}\n"
|
| 3436 |
-
"- ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ:
|
| 3437 |
)
|
| 3438 |
|
| 3439 |
return result_df, msg
|
|
@@ -3550,7 +3819,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3550 |
|
| 3551 |
with gr.Tab("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์"):
|
| 3552 |
gr.Markdown("## ๐ ๋จ์ผ ์ฑ๋ถ ๊ท์ ๊ฒ์")
|
| 3553 |
-
gr.Markdown("์์
์
๋ก๋ ์์ด ๊ตญ๊ฐ๋ฅผ ์ ํํ๊ณ ์ฑ๋ถ๋ช
, INCI, CAS.No ์ค ์๋ฌด๊ฑฐ๋ ํ๋๋ง ์
๋ ฅํด์ ๋ฐ๋ก ์คํฌ๋ฆฌ๋ํฉ๋๋ค.
|
| 3554 |
|
| 3555 |
single_country = gr.CheckboxGroup(
|
| 3556 |
choices=get_country_folders(),
|
|
@@ -3563,7 +3832,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3563 |
|
| 3564 |
single_query = gr.Textbox(
|
| 3565 |
label="๊ฒ์์ด",
|
| 3566 |
-
placeholder="์: ํธ๋ชจ์ด๋ ์ดํธ / Homosalate / 118-56-9 / Octocrylene / ํฅ๋ฃ",
|
| 3567 |
)
|
| 3568 |
|
| 3569 |
with gr.Row():
|
|
|
|
| 19 |
# - ์์
์ ์ฑ๋ถ ์ ์ฒด ์คํฌ๋ฆฌ๋
|
| 20 |
# - ๋จ์ผ ์ฑ๋ถ ๊ฒ์
|
| 21 |
# - ์ ์ฒด ์คํฌ๋ฆฌ๋: MFDS ๊ฒ์์ด 0๊ฐ ๋ฐฉ์ง
|
| 22 |
+
# - ๋จ์ผ ์ฑ๋ถ ๊ฒ์์ ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ
|
| 23 |
# - ๊ตญ๊ฐ๋ณ ๊ท์ ํด๋ ๊ฒ์
|
| 24 |
# - FAISS ๋์คํฌ ์บ์
|
| 25 |
# - COOS ์ ๊ฑฐ
|
| 26 |
# - ํฅ๋ฃ๋ ์ ๊ตญ๊ฐ ํ์ธ ํ์
|
| 27 |
+
# - ์ ์ ์ / Water / Aqua๋ ์ ๊ตญ๊ฐ ๊ธฐ๋ณธ Pass
|
| 28 |
+
# - ๊ตญ๊ฐ๋ณ ํต์ฌ ๊ธ์ง/์ ํ ์ฑ๋ถ์ GPT/RAG๋ณด๋ค ์ฐ์ ํ์
|
| 29 |
+
# - Tranexamic Acid๋ ์ผ๋ณธ ๋ฐฐํฉ๊ธ์ง ์ฐ์ ์ฒ๋ฆฌ
|
| 30 |
# - ๊ณ ์ํ ์ฑ๋ถ Pass ์๋ ๋ฐฉ์ง
|
| 31 |
# - Formular Ingredients Statement ์์ ์ถ๋ ฅ
|
| 32 |
# - ์๋ณธ TOTAL ํ ์ ๊ฑฐ ํ ์ TOTAL ํ 1๊ฐ๋ง ์์ฑ
|
| 33 |
# - ์ซ์ ์๋ '๋ฐฐํฉํ๋'๋ '๋ฐฐํฉํ๋ ํ์ธ ํ์'๋ก ํ์
|
| 34 |
# - Salicylic Acid ์์ฒด๋ง ์ ํ ํ๋ณด ์ฒ๋ฆฌ
|
| 35 |
+
# - Niacinamide/Adenosine์ ํ๊ตญ์์๋ง ๊ธฐ๋ฅ์ฑ ํ์ธ ์ฒ๋ฆฌ
|
| 36 |
# ============================================================
|
| 37 |
|
| 38 |
import os
|
|
|
|
| 395 |
},
|
| 396 |
}
|
| 397 |
|
| 398 |
+
ALWAYS_PASS_INGREDIENTS = {
|
| 399 |
+
"water": {
|
| 400 |
+
"label": "Water",
|
| 401 |
+
"aliases": ["water", "aqua", "์ ์ ์", "7732-18-5"],
|
| 402 |
+
},
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
CRITICAL_COUNTRY_RULES = {
|
| 406 |
+
"tranexamic acid": {
|
| 407 |
+
"label": "Tranexamic Acid",
|
| 408 |
+
"aliases": [
|
| 409 |
+
"tranexamic acid",
|
| 410 |
+
"ํธ๋ผ๋ฅ์ฌ๋ฏน์ ์จ๋",
|
| 411 |
+
"ํธ๋ผ๋ฅ์ฌ๋ฏน ์ ์จ๋",
|
| 412 |
+
"ํธ๋ผ๋ฅ์ผ์ฐ",
|
| 413 |
+
"ํธ๋ผ๋ฅ์ฌ๋ฏผ์ฐ",
|
| 414 |
+
"ํธ๋ผ๋คํค์ผ์ฐ",
|
| 415 |
+
"ใใฉใใญใตใ ้
ธ",
|
| 416 |
+
"ใใฉใใญใตใ ใตใณ",
|
| 417 |
+
"1197-18-8",
|
| 418 |
+
],
|
| 419 |
+
"JAPAN": {
|
| 420 |
+
"status": "prohibited",
|
| 421 |
+
"formula_text": "๋ฐฐํฉ๊ธ์ง",
|
| 422 |
+
"result": "์ผ๋ณธ ๋ฐฐํฉ๊ธ์ง ์ฑ๋ถ / Tranexamic Acid / ์ฌ๊ฒํ ํ์",
|
| 423 |
+
"note": "์ผ๋ณธ ์์ถ์ฉ ์ ํ ์ฌ์ฉ ๋ถ๊ฐ ์ฌ๋ถ ํ์ธ ํ์",
|
| 424 |
+
},
|
| 425 |
+
},
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
|
| 429 |
# ============================================================
|
| 430 |
# 2. ๊ณตํต ์ ํธ
|
|
|
|
| 444 |
def normalize_text(text):
|
| 445 |
text = safe_str(text).lower()
|
| 446 |
text = text.replace("ฮฑ", "alpha").replace("ฮฒ", "beta")
|
| 447 |
+
text = re.sub(r"[^a-z0-9๊ฐ-ํฃใ-ใใก-ใณไธ-้พฅ]+", " ", text)
|
| 448 |
return re.sub(r"\s+", " ", text).strip()
|
| 449 |
|
| 450 |
|
|
|
|
| 624 |
return None
|
| 625 |
|
| 626 |
|
| 627 |
+
def is_always_pass_component(material, component):
|
| 628 |
+
identity = get_identity_text(material, component)
|
| 629 |
+
|
| 630 |
+
for _, rule in ALWAYS_PASS_INGREDIENTS.items():
|
| 631 |
+
for alias in rule.get("aliases", []):
|
| 632 |
+
alias_norm = normalize_text(alias)
|
| 633 |
+
|
| 634 |
+
if alias_norm and alias_norm in identity:
|
| 635 |
+
return True
|
| 636 |
+
|
| 637 |
+
return False
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
def is_critical_country_candidate(material, component):
|
| 641 |
+
identity = get_identity_text(material, component)
|
| 642 |
+
|
| 643 |
+
for _, rule in CRITICAL_COUNTRY_RULES.items():
|
| 644 |
+
for alias in rule.get("aliases", []):
|
| 645 |
+
alias_norm = normalize_text(alias)
|
| 646 |
+
if alias_norm and alias_norm in identity:
|
| 647 |
+
return True
|
| 648 |
+
|
| 649 |
+
return False
|
| 650 |
+
|
| 651 |
+
|
| 652 |
def is_cas_like(text):
|
| 653 |
text = safe_str(text)
|
| 654 |
return bool(re.match(r"^\d{2,7}-\d{2}-\d$", text))
|
|
|
|
| 690 |
|
| 691 |
|
| 692 |
def get_restricted_candidate_reason(material, component):
|
| 693 |
+
if is_always_pass_component(material, component):
|
| 694 |
+
return ""
|
| 695 |
+
|
| 696 |
+
if is_critical_country_candidate(material, component):
|
| 697 |
+
return "๊ตญ๊ฐ๋ณ ๊ธ์ง/์ ํ ํต์ฌ ์ฑ๋ถ"
|
| 698 |
+
|
| 699 |
if is_plain_fragrance_component(material, component):
|
| 700 |
return "ํฅ๋ฃ"
|
| 701 |
|
|
|
|
| 707 |
if preservative_key:
|
| 708 |
return "๋ณด์กด์ /์ ํ์ฑ๋ถ"
|
| 709 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
identity = get_identity_text(material, component)
|
| 711 |
for _, rule in FRAGRANCE_ALLERGEN_RULES.items():
|
| 712 |
for alias in rule.get("aliases", []):
|
|
|
|
| 716 |
|
| 717 |
function_text = normalize_text(component.get("FUNCTION", ""))
|
| 718 |
inci_text = normalize_text(component.get("INCI Name", ""))
|
|
|
|
| 719 |
|
| 720 |
high_risk_words = [
|
| 721 |
"sunscreen",
|
|
|
|
| 731 |
if any(w in function_text for w in high_risk_words) or any(w in inci_text for w in high_risk_words):
|
| 732 |
return "์ ํ ๊ฐ๋ฅ์ฑ ์ฑ๋ถ"
|
| 733 |
|
|
|
|
|
|
|
|
|
|
| 734 |
if normalize_compact(component.get("INCI Name", "")) == normalize_compact("Salicylic Acid"):
|
| 735 |
return "์ ํ ๊ฐ๋ฅ์ฑ ์ฑ๋ถ"
|
| 736 |
|
|
|
|
| 760 |
"์ฃผ์",
|
| 761 |
"๊ฒฝ๊ณ ",
|
| 762 |
"๋ฐฐํฉํ๋ ํ์ธ ํ์",
|
| 763 |
+
"๊ธฐ๋ฅ์ฑ ํ์ธ",
|
| 764 |
+
"ํจ๋ ํ์ธ",
|
| 765 |
]
|
| 766 |
|
| 767 |
return any(k in text for k in keywords)
|
|
|
|
| 789 |
|
| 790 |
lower = text.lower()
|
| 791 |
|
| 792 |
+
if (
|
| 793 |
+
"๋ฐฐํฉ๊ธ์ง" in text
|
| 794 |
+
or "์ฌ์ฉ๊ธ์ง" in text
|
| 795 |
+
or "๊ธ์ง" in text
|
| 796 |
+
or "prohibited" in lower
|
| 797 |
+
or "banned" in lower
|
| 798 |
+
or "not allowed" in lower
|
| 799 |
+
):
|
| 800 |
+
return "๋ฐฐํฉ๊ธ์ง"
|
| 801 |
+
|
| 802 |
if LIMIT_CHECK_TEXT in text:
|
| 803 |
return LIMIT_CHECK_TEXT
|
| 804 |
|
|
|
|
| 808 |
if "ํฅ๋ฃ" in text or "fragrance" in lower or "parfum" in lower:
|
| 809 |
return NEED_CHECK_TEXT
|
| 810 |
|
| 811 |
+
if "๊ธฐ๋ฅ์ฑ" in text:
|
| 812 |
+
return "๊ธฐ๋ฅ์ฑ ํ์ธ"
|
| 813 |
+
|
| 814 |
+
if "ํจ๋ ์ ๋ณด ์์" in text or "ํจ๋ ํ์ธ" in text:
|
| 815 |
+
return "ํจ๋ ํ์ธ"
|
| 816 |
+
|
| 817 |
if "octocrylene" in inci_norm or "์ฅํ ํฌ๋ฆด๋ " in inci_norm:
|
| 818 |
if country_col == "EU":
|
| 819 |
return "๋ฐฐํฉ ํ๋:\n์คํ๋ ์ด: 9% /\n๊ธฐํ์ ํ: 10%"
|
|
|
|
| 848 |
return "๋ฐฐํฉํ๋: 3%"
|
| 849 |
return "๋ฐฐํฉํ๋: 5%"
|
| 850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
if (
|
| 852 |
"์ด๊ณผ" in text
|
| 853 |
or "๋ถ์ ํฉ" in text
|
|
|
|
| 1228 |
"ceramide",
|
| 1229 |
"glycol",
|
| 1230 |
"retinol",
|
| 1231 |
+
"tranexamic",
|
| 1232 |
]
|
| 1233 |
|
| 1234 |
if any(x in sample for x in markers):
|
|
|
|
| 1573 |
|
| 1574 |
|
| 1575 |
def extract_terms_for_live_lookup(row_items):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1576 |
terms = []
|
| 1577 |
|
| 1578 |
for item in row_items:
|
|
|
|
| 1582 |
if is_plain_fragrance_component(material, comp):
|
| 1583 |
continue
|
| 1584 |
|
| 1585 |
+
if is_always_pass_component(material, comp):
|
| 1586 |
+
continue
|
| 1587 |
+
|
| 1588 |
candidate_values = [
|
| 1589 |
comp.get("INCI Name", ""),
|
| 1590 |
comp.get("ํ๊ธ ์ฑ๋ถ๋ช
", ""),
|
|
|
|
| 2061 |
# 7. ๋ก์ปฌ ๊ท์น ํ์
|
| 2062 |
# ============================================================
|
| 2063 |
|
| 2064 |
+
def evaluate_critical_country_rule(country, material, component):
|
| 2065 |
+
ckey = country_key(country)
|
| 2066 |
+
identity = get_identity_text(material, component)
|
| 2067 |
+
|
| 2068 |
+
for _, rule in CRITICAL_COUNTRY_RULES.items():
|
| 2069 |
+
matched = False
|
| 2070 |
+
|
| 2071 |
+
for alias in rule.get("aliases", []):
|
| 2072 |
+
alias_norm = normalize_text(alias)
|
| 2073 |
+
|
| 2074 |
+
if alias_norm and alias_norm in identity:
|
| 2075 |
+
matched = True
|
| 2076 |
+
break
|
| 2077 |
+
|
| 2078 |
+
if not matched:
|
| 2079 |
+
continue
|
| 2080 |
+
|
| 2081 |
+
country_rule = rule.get(ckey)
|
| 2082 |
+
|
| 2083 |
+
if not country_rule:
|
| 2084 |
+
return None
|
| 2085 |
+
|
| 2086 |
+
status = country_rule.get("status", "")
|
| 2087 |
+
|
| 2088 |
+
if status == "prohibited":
|
| 2089 |
+
return {
|
| 2090 |
+
"๋ํ INCI": rule.get("label", "-"),
|
| 2091 |
+
"๊ฒฐ๊ณผ": country_rule.get(
|
| 2092 |
+
"result",
|
| 2093 |
+
f"{display_country(country)} ๋ฐฐํฉ๊ธ์ง ์ฑ๋ถ / {rule.get('label', '-')}"
|
| 2094 |
+
),
|
| 2095 |
+
"ํ์๋ฌธ๊ตฌ": country_rule.get("formula_text", "๋ฐฐํฉ๊ธ์ง"),
|
| 2096 |
+
"๋น๊ณ ": country_rule.get("note", "-"),
|
| 2097 |
+
}
|
| 2098 |
+
|
| 2099 |
+
if status == "restricted":
|
| 2100 |
+
return {
|
| 2101 |
+
"๋ํ INCI": rule.get("label", "-"),
|
| 2102 |
+
"๊ฒฐ๊ณผ": country_rule.get(
|
| 2103 |
+
"result",
|
| 2104 |
+
f"{display_country(country)} ์ ํ ์ฑ๋ถ / {rule.get('label', '-')}"
|
| 2105 |
+
),
|
| 2106 |
+
"ํ์๋ฌธ๊ตฌ": country_rule.get("formula_text", LIMIT_CHECK_TEXT),
|
| 2107 |
+
"๋น๊ณ ": country_rule.get("note", "-"),
|
| 2108 |
+
}
|
| 2109 |
+
|
| 2110 |
+
return None
|
| 2111 |
+
|
| 2112 |
+
|
| 2113 |
def evaluate_limit_rule(country, material, component, rule_group, rule_type_name):
|
| 2114 |
ckey = country_key(country)
|
| 2115 |
key = match_rule_key(material, component, rule_group)
|
|
|
|
| 2171 |
ckey = country_key(country)
|
| 2172 |
amount = component.get("amount_float")
|
| 2173 |
|
| 2174 |
+
critical_result = evaluate_critical_country_rule(country, material, component)
|
| 2175 |
+
if critical_result is not None:
|
| 2176 |
+
return critical_result
|
| 2177 |
+
|
| 2178 |
+
if is_always_pass_component(material, component):
|
| 2179 |
+
return {
|
| 2180 |
+
"๋ํ INCI": safe_str(component.get("INCI Name", "")) or "Water",
|
| 2181 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 2182 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 2183 |
+
"๋น๊ณ ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 2184 |
+
}
|
| 2185 |
+
|
| 2186 |
plain_fragrance = evaluate_plain_fragrance_rule(country, material, component)
|
| 2187 |
if plain_fragrance is not None:
|
| 2188 |
return plain_fragrance
|
|
|
|
| 2295 |
|
| 2296 |
display_text = safe_str(parsed.get("ํ์๋ฌธ๊ตฌ", ""))
|
| 2297 |
|
| 2298 |
+
if is_always_pass_component({}, component):
|
| 2299 |
+
return {
|
| 2300 |
+
"๋ํ INCI": representative,
|
| 2301 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 2302 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 2303 |
+
"๋น๊ณ ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 2304 |
+
}
|
| 2305 |
+
|
| 2306 |
if high_risk_reason and result_text == NO_EVIDENCE_TEXT:
|
| 2307 |
result_text = f"{high_risk_reason} / {representative} / {country_col} ์ ํ ์ฌ๋ถ ํ์ธ ํ์"
|
| 2308 |
display_text = NEED_CHECK_TEXT
|
|
|
|
| 2391 |
amount_text = format_percent(amount) if amount is not None else "ํจ๋ ํ์ธ ํ์"
|
| 2392 |
high_risk_reason = get_restricted_candidate_reason(material, component)
|
| 2393 |
|
| 2394 |
+
critical_result = evaluate_critical_country_rule(country, material, component)
|
| 2395 |
+
if critical_result is not None:
|
| 2396 |
+
return critical_result
|
| 2397 |
+
|
| 2398 |
+
if is_always_pass_component(material, component):
|
| 2399 |
+
return {
|
| 2400 |
+
"๋ํ INCI": inci_name or korean_name or cas_no or "Water",
|
| 2401 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 2402 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 2403 |
+
"๋น๊ณ ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 2404 |
+
}
|
| 2405 |
+
|
| 2406 |
if not inci_name and not korean_name and not cas_no:
|
| 2407 |
return {"๋ํ INCI": "-", "๊ฒฐ๊ณผ": "", "ํ์๋ฌธ๊ตฌ": "", "๋น๊ณ ": "-"}
|
| 2408 |
|
|
|
|
| 2545 |
inci_name = safe_str(comp.get("INCI Name", ""))
|
| 2546 |
korean_name = safe_str(comp.get("ํ๊ธ ์ฑ๋ถ๋ช
", ""))
|
| 2547 |
cas_no = safe_str(comp.get("CAS.No", ""))
|
| 2548 |
+
|
| 2549 |
+
critical_result = evaluate_critical_country_rule(country, material, comp)
|
| 2550 |
high_risk_reason = get_restricted_candidate_reason(material, comp)
|
| 2551 |
|
| 2552 |
+
if critical_result is not None:
|
| 2553 |
+
result = critical_result
|
| 2554 |
+
elif is_always_pass_component(material, comp):
|
| 2555 |
+
result = {
|
| 2556 |
+
"๋ํ INCI": inci_name or korean_name or cas_no or "Water",
|
| 2557 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 2558 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 2559 |
+
"๋น๊ณ ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 2560 |
+
}
|
| 2561 |
+
elif high_risk_reason:
|
| 2562 |
result = {
|
| 2563 |
"๋ํ INCI": inci_name or korean_name or cas_no or "-",
|
| 2564 |
"๊ฒฐ๊ณผ": f"{high_risk_reason} / {inci_name or korean_name or cas_no} / {country_col} ์ ํ ์ฌ๋ถ ํ์ธ ํ์",
|
|
|
|
| 2602 |
amount_text = format_percent(amount) if amount is not None else "ํจ๋ ํ์ธ ํ์"
|
| 2603 |
high_risk_reason = get_restricted_candidate_reason(material, comp)
|
| 2604 |
|
| 2605 |
+
critical_result = evaluate_critical_country_rule(country, material, comp)
|
| 2606 |
+
if critical_result is not None:
|
| 2607 |
+
result = critical_result
|
| 2608 |
+
results[item["target_id"]] = result
|
| 2609 |
+
EVAL_CACHE[make_eval_cache_key(country, comp)] = result
|
| 2610 |
+
log_search_context(item["target_id"], country, comp, result["๊ฒฐ๊ณผ"], "CRITICAL_COUNTRY_RULE", result.get("๋น๊ณ ", "-"))
|
| 2611 |
+
continue
|
| 2612 |
+
|
| 2613 |
+
if is_always_pass_component(material, comp):
|
| 2614 |
+
result = {
|
| 2615 |
+
"๋ํ INCI": inci_name or korean_name or cas_no or "Water",
|
| 2616 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 2617 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 2618 |
+
"๋น๊ณ ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 2619 |
+
}
|
| 2620 |
+
results[item["target_id"]] = result
|
| 2621 |
+
EVAL_CACHE[make_eval_cache_key(country, comp)] = result
|
| 2622 |
+
log_search_context(item["target_id"], country, comp, result["๊ฒฐ๊ณผ"], "ALWAYS_PASS_RULE", "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ")
|
| 2623 |
+
continue
|
| 2624 |
+
|
| 2625 |
search_text = f"""
|
| 2626 |
๊ตญ๊ฐ/์ฑ๋: {country}
|
| 2627 |
์๋ฃ๋ช
๊ตญ๋ฌธ: {material.get("Trade name(๊ตญ๋ฌธ)", "")}
|
|
|
|
| 3189 |
gpt_targets = []
|
| 3190 |
|
| 3191 |
for item in row_items:
|
| 3192 |
+
critical_result = evaluate_critical_country_rule(
|
| 3193 |
+
country=country,
|
| 3194 |
+
material=item["material"],
|
| 3195 |
+
component=item["component"],
|
| 3196 |
+
)
|
| 3197 |
+
|
| 3198 |
+
if critical_result is not None:
|
| 3199 |
+
item["row_data"][col_name] = critical_result.get("๊ฒฐ๏ฟฝ๏ฟฝ๏ฟฝ", "")
|
| 3200 |
+
item["row_data"][col_name + "_display"] = critical_result.get("ํ์๋ฌธ๊ตฌ", "๋ฐฐํฉ๊ธ์ง")
|
| 3201 |
+
|
| 3202 |
+
note = safe_str(critical_result.get("๋น๊ณ ", "-"))
|
| 3203 |
+
if note and note != "-":
|
| 3204 |
+
item["notes"].append(f"{col_name}: {note}")
|
| 3205 |
+
|
| 3206 |
+
log_search_context(
|
| 3207 |
+
item["target_id"],
|
| 3208 |
+
country,
|
| 3209 |
+
item["component"],
|
| 3210 |
+
critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3211 |
+
"CRITICAL_COUNTRY_RULE",
|
| 3212 |
+
note,
|
| 3213 |
+
)
|
| 3214 |
+
continue
|
| 3215 |
+
|
| 3216 |
+
if is_always_pass_component(item["material"], item["component"]):
|
| 3217 |
+
item["row_data"][col_name] = NO_EVIDENCE_TEXT
|
| 3218 |
+
item["row_data"][col_name + "_display"] = "Pass"
|
| 3219 |
+
|
| 3220 |
+
log_search_context(
|
| 3221 |
+
item["target_id"],
|
| 3222 |
+
country,
|
| 3223 |
+
item["component"],
|
| 3224 |
+
"Pass",
|
| 3225 |
+
"ALWAYS_PASS_RULE",
|
| 3226 |
+
"์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 3227 |
+
)
|
| 3228 |
+
continue
|
| 3229 |
+
|
| 3230 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 3231 |
country=country,
|
| 3232 |
material=item["material"],
|
|
|
|
| 3438 |
if not query:
|
| 3439 |
return []
|
| 3440 |
|
| 3441 |
+
if is_always_pass_component(material, component):
|
| 3442 |
+
return []
|
| 3443 |
+
|
| 3444 |
return [query]
|
| 3445 |
|
| 3446 |
|
|
|
|
| 3487 |
"๊ณ ์ํ๊ตฐ ํ๋ณด์ด๋ ๊ตญ๊ฐ๋ณ ๊ท์ ํ์ผ์์ ์ง์ ๊ทผ๊ฑฐ ๋ฏธ๊ฒ์ถ. Pass ์ฒ๋ฆฌํ์ง ์์.": "๊ตญ๊ฐ๋ณ ๊ท์ ํ์ผ ๋ด ์ง์ ๊ทผ๊ฑฐ ๋ฏธ๊ฒ์ถ",
|
| 3488 |
"ํด๋น ๊ตญ๊ฐ/์ฑ๋ ๊ท์ DB ์์. ๊ณ ์ํ๊ตฐ ํ๋ณด์ด๋ฏ๋ก Pass ์ฒ๋ฆฌํ์ง ์์.": "ํด๋น ๊ตญ๊ฐ ๊ท์ DB ์์",
|
| 3489 |
"ํฅ๋ฃ๋ ์ธ๋ถ ๊ตฌ์ฑ์ฑ๋ถ ๋ฐ ์๋ ๋ฅด๊ฒ ํ์๋์ ์ฌ๋ถ ํ์ธ ํ์. ์๋ Pass ์ฒ๋ฆฌ ๊ธ์ง.": "ํฅ๋ฃ ์ธ๋ถ ์กฐ์ฑ ๋ฐ ์๋ ๋ฅด๊ฒ ํ์ธ ํ์",
|
| 3490 |
+
"์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ": "์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 3491 |
+
"์ผ๋ณธ ์์ถ์ฉ ์ ํ ์ฌ์ฉ ๋ถ๊ฐ ์ฌ๋ถ ํ์ธ ํ์": "์ผ๋ณธ ์์ถ์ฉ ์ ํ ์ฌ์ฉ ๋ถ๊ฐ ์ฌ๋ถ ํ์ธ ํ์",
|
| 3492 |
}
|
| 3493 |
|
| 3494 |
if note in replace_map:
|
|
|
|
| 3533 |
mfds_df = pd.DataFrame()
|
| 3534 |
terms = extract_single_lookup_terms(single_query, material, component)
|
| 3535 |
|
| 3536 |
+
if terms:
|
| 3537 |
+
try:
|
| 3538 |
+
mfds_df, mfds_live_msg = mfds_live_lookup_terms(
|
| 3539 |
+
terms=terms,
|
| 3540 |
+
max_terms=1,
|
| 3541 |
+
headless=True,
|
| 3542 |
+
)
|
| 3543 |
+
except Exception as e:
|
| 3544 |
+
mfds_df = pd.DataFrame()
|
| 3545 |
+
mfds_live_msg = f"MFDS ์ค์๊ฐ ์กฐํ ์คํจ: {e}"
|
| 3546 |
+
else:
|
| 3547 |
+
mfds_live_msg = "MFDS ์ค์๊ฐ ์กฐํ ์๋ต: ๊ธฐ๋ณธ Pass ์ฑ๋ถ ๋๋ ๊ฒ์์ด ์์"
|
| 3548 |
|
| 3549 |
ingredient_totals = defaultdict(float)
|
| 3550 |
ingredient_amount_parts = defaultdict(list)
|
|
|
|
| 3568 |
final_result = None
|
| 3569 |
source = ""
|
| 3570 |
|
| 3571 |
+
critical_result = evaluate_critical_country_rule(
|
| 3572 |
+
country=country,
|
| 3573 |
+
material=material,
|
| 3574 |
+
component=component,
|
| 3575 |
+
)
|
| 3576 |
+
|
| 3577 |
+
if critical_result is not None:
|
| 3578 |
+
result_rows.append({
|
| 3579 |
+
"๊ตญ๊ฐ": country_col,
|
| 3580 |
+
"๊ฒ์์ด": safe_str(single_query),
|
| 3581 |
+
"๋ฐฐํฉํ๋/๊ธ์ง": critical_result.get("ํ์๋ฌธ๊ตฌ", "๋ฐฐํฉ๊ธ์ง"),
|
| 3582 |
+
"์์ธ ํ์ ": critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3583 |
+
"ํ์ ์ถ์ฒ": "CRITICAL_COUNTRY_RULE",
|
| 3584 |
+
"๋น๊ณ ": simplify_single_note(critical_result.get("๋น๊ณ ", "-")),
|
| 3585 |
+
})
|
| 3586 |
+
|
| 3587 |
+
log_search_context(
|
| 3588 |
+
"single_ingredient",
|
| 3589 |
+
country,
|
| 3590 |
+
component,
|
| 3591 |
+
critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3592 |
+
"CRITICAL_COUNTRY_RULE",
|
| 3593 |
+
critical_result.get("๋น๊ณ ", "-"),
|
| 3594 |
+
)
|
| 3595 |
+
|
| 3596 |
+
continue
|
| 3597 |
+
|
| 3598 |
+
if is_always_pass_component(material, component):
|
| 3599 |
+
result_rows.append({
|
| 3600 |
+
"๊ตญ๊ฐ": country_col,
|
| 3601 |
+
"๊ฒ์์ด": safe_str(single_query),
|
| 3602 |
+
"๋ฐฐํฉํ๋/๊ธ์ง": "Pass",
|
| 3603 |
+
"์์ธ ํ์ ": NO_EVIDENCE_TEXT,
|
| 3604 |
+
"ํ์ ์ถ์ฒ": "ALWAYS_PASS_RULE",
|
| 3605 |
+
"๋น๊ณ ": "์ ์ ๏ฟฝ๏ฟฝ/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 3606 |
+
})
|
| 3607 |
+
|
| 3608 |
+
log_search_context(
|
| 3609 |
+
"single_ingredient",
|
| 3610 |
+
country,
|
| 3611 |
+
component,
|
| 3612 |
+
"Pass",
|
| 3613 |
+
"ALWAYS_PASS_RULE",
|
| 3614 |
+
"์ ์ ์/Water/Aqua ๊ธฐ๋ณธ Pass ์ฒ๋ฆฌ",
|
| 3615 |
+
)
|
| 3616 |
+
|
| 3617 |
+
continue
|
| 3618 |
+
|
| 3619 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 3620 |
country=country,
|
| 3621 |
material=material,
|
|
|
|
| 3702 |
f"- ์ ํ ๊ตญ๊ฐ ์: {len(countries)}๊ฐ\n"
|
| 3703 |
f"- MFDS ์ํ: {mfds_live_msg}\n"
|
| 3704 |
f"- MFDS ์กฐํ ๋์: {', '.join(terms) if terms else '์์'}\n"
|
| 3705 |
+
"- ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ: ๊ธฐ๋ณธ Pass ์ฑ๋ถ ์ ์ธ ํ ์ฌ์ฉ\n"
|
| 3706 |
)
|
| 3707 |
|
| 3708 |
return result_df, msg
|
|
|
|
| 3819 |
|
| 3820 |
with gr.Tab("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์"):
|
| 3821 |
gr.Markdown("## ๐ ๋จ์ผ ์ฑ๋ถ ๊ท์ ๊ฒ์")
|
| 3822 |
+
gr.Markdown("์์
์
๋ก๋ ์์ด ๊ตญ๊ฐ๋ฅผ ์ ํํ๊ณ ์ฑ๋ถ๋ช
, INCI, CAS.No ์ค ์๋ฌด๊ฑฐ๋ ํ๋๋ง ์
๋ ฅํด์ ๋ฐ๋ก ์คํฌ๋ฆฌ๋ํฉ๋๋ค.")
|
| 3823 |
|
| 3824 |
single_country = gr.CheckboxGroup(
|
| 3825 |
choices=get_country_folders(),
|
|
|
|
| 3832 |
|
| 3833 |
single_query = gr.Textbox(
|
| 3834 |
label="๊ฒ์์ด",
|
| 3835 |
+
placeholder="์: ํธ๋ชจ์ด๋ ์ดํธ / Homosalate / 118-56-9 / Octocrylene / ์ ์ ์ / Water / ํธ๋ผ๋ฅ์ฌ๋ฏน์ ์จ๋ / Tranexamic Acid / ํฅ๋ฃ",
|
| 3836 |
)
|
| 3837 |
|
| 3838 |
with gr.Row():
|