Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,6 +75,17 @@ REG_INDEX_CACHE_DIR = ".reg_index_cache"
|
|
| 75 |
NO_EVIDENCE_TEXT = "ํด๋น ์๋ฃ ๋ด ์ ํ ๊ทผ๊ฑฐ ์์"
|
| 76 |
NEED_CHECK_TEXT = "ํ์ธ ํ์"
|
| 77 |
LIMIT_CHECK_TEXT = "๋ฐฐํฉํ๋ ํ์ธ ํ์"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
MFDS_LIVE_URL = "https://nedrug.mfds.go.kr/pbp/CCBDF01"
|
| 79 |
# ์๋ ์๊ธํจ์น
|
| 80 |
# - ์ ์ฒด ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋์์๋ MFDS ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉํ์ง ์๋๋ค.
|
|
@@ -2203,14 +2214,15 @@ def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=5,
|
|
| 2203 |
final_result = None
|
| 2204 |
source = ""
|
| 2205 |
|
| 2206 |
-
|
| 2207 |
-
|
| 2208 |
-
|
| 2209 |
-
|
| 2210 |
-
|
|
|
|
| 2211 |
|
| 2212 |
-
|
| 2213 |
-
|
| 2214 |
|
| 2215 |
if final_result is None and is_always_pass_component(mat, comp):
|
| 2216 |
final_result = {
|
|
@@ -2221,7 +2233,7 @@ def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=5,
|
|
| 2221 |
}
|
| 2222 |
source = "ALWAYS_PASS_RULE"
|
| 2223 |
|
| 2224 |
-
if final_result is None:
|
| 2225 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 2226 |
country=country,
|
| 2227 |
material=mat,
|
|
@@ -2256,7 +2268,7 @@ def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=5,
|
|
| 2256 |
final_result = file_result
|
| 2257 |
source = "COUNTRY_FILE_FAST"
|
| 2258 |
|
| 2259 |
-
if final_result is None:
|
| 2260 |
local_result = evaluate_local_rules(
|
| 2261 |
country=country,
|
| 2262 |
material=mat,
|
|
@@ -2903,32 +2915,81 @@ def warmup_country_indexes(countries):
|
|
| 2903 |
|
| 2904 |
|
| 2905 |
def extract_limit_condition_from_context(context):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2906 |
text = safe_str(context)
|
| 2907 |
compact = re.sub(r"\s+", " ", text).strip()
|
|
|
|
| 2908 |
if not compact:
|
| 2909 |
return "", ""
|
| 2910 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2911 |
patterns = [
|
| 2912 |
r"([0-9]+(?:\.[0-9]+)?\s*%)",
|
| 2913 |
-
r"([0-9]+(?:\.[0-9]+)?\s*ppm)",
|
| 2914 |
r"([0-9]+(?:\.[0-9]+)?\s*g\s*/\s*100\s*g)",
|
| 2915 |
r"([0-9]+(?:\.[0-9]+)?\s*g\s+per\s+100\s*g)",
|
| 2916 |
-
r"([0-9]+(?:\.[0-9]+)?\s*mg\s*/\s*kg)",
|
| 2917 |
]
|
|
|
|
| 2918 |
limits = []
|
| 2919 |
for pat in patterns:
|
| 2920 |
-
for m in re.finditer(pat,
|
| 2921 |
v = m.group(1).replace(" ", "")
|
| 2922 |
if v not in limits:
|
| 2923 |
limits.append(v)
|
| 2924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2925 |
condition_keywords = [
|
| 2926 |
"leave-on", "rinse-off", "oral", "mucosa", "washed away",
|
| 2927 |
"๋ณด์กด์ ", "๋ฐฉ๋ถ์ ", "์์ธ์ ", "์์", "์ ๋ง", "๊ตฌ๊ฐ",
|
| 2928 |
-
"์ ํ์ฌํญ", "
|
| 2929 |
]
|
|
|
|
| 2930 |
condition_lines = []
|
| 2931 |
-
for line in
|
| 2932 |
l = line.lower()
|
| 2933 |
if any(k.lower() in l for k in condition_keywords):
|
| 2934 |
cleaned = re.sub(r"\s+", " ", line).strip()
|
|
@@ -2949,8 +3010,8 @@ def make_restricted_or_positive_result(country, component, match, reg_type):
|
|
| 2949 |
display = f"๋ฐฐํฉํ๋: {limit_text}"
|
| 2950 |
result = f"{display_country(country)} {label}์์ ์ฑ๋ถ ํ์ธ / ํ๋ {limit_text}"
|
| 2951 |
elif kind.startswith("positive_"):
|
| 2952 |
-
display = "
|
| 2953 |
-
result =
|
| 2954 |
else:
|
| 2955 |
display = "๋ฐฐํฉํ๋/์ ํ ํ์ธ"
|
| 2956 |
result = f"{display_country(country)} {label}์์ ์ฑ๋ถ ํ์ธ / ํ๋ยท์กฐ๊ฑด ํ์ธ ํ์"
|
|
@@ -3227,24 +3288,37 @@ def evaluate_component_from_uploaded_source_records(country, material, component
|
|
| 3227 |
|
| 3228 |
if reg_kind.startswith("positive_"):
|
| 3229 |
limit_text, condition_text = extract_limit_condition_from_context(context)
|
| 3230 |
-
|
| 3231 |
-
|
| 3232 |
-
|
| 3233 |
-
|
| 3234 |
-
|
| 3235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3236 |
log_search_context(target_id, country, component, result["๊ฒฐ๊ณผ"], "UPLOADED_SOURCE_RECORD_POSITIVE", result["๋น๊ณ "])
|
| 3237 |
return result
|
| 3238 |
|
| 3239 |
# ํ์ผ์์๋ ์ฑ๋ถ์ ์ฐพ์์ง๋ง ํ์ผ ์ ํ์ด ๋ถ๋ช
ํํ ๊ฒฝ์ฐ:
|
| 3240 |
-
#
|
| 3241 |
result = {
|
| 3242 |
"๋ํ INCI": representative,
|
| 3243 |
-
"๊ฒฐ๊ณผ":
|
| 3244 |
-
"ํ์๋ฌธ๊ตฌ":
|
| 3245 |
-
"๋น๊ณ ": f"[์ถ์ฒํ์ผ: {best.get('source_file', '')}] [row: {best.get('row_index', '')}] {context[:900]}",
|
| 3246 |
}
|
| 3247 |
-
log_search_context(target_id, country, component, result["๊ฒฐ๊ณผ"], "
|
| 3248 |
return result
|
| 3249 |
|
| 3250 |
|
|
@@ -3266,22 +3340,24 @@ def evaluate_component_from_country_files_only(country, material, component, tar
|
|
| 3266 |
cas_no = safe_str(component.get("CAS.No", ""))
|
| 3267 |
representative = inci_name or korean_name or cas_no or "-"
|
| 3268 |
|
| 3269 |
-
critical_result =
|
| 3270 |
-
|
| 3271 |
-
|
| 3272 |
-
|
| 3273 |
-
|
| 3274 |
-
|
| 3275 |
-
if critical_result is not None:
|
| 3276 |
-
log_search_context(
|
| 3277 |
-
target_id,
|
| 3278 |
-
country,
|
| 3279 |
-
component,
|
| 3280 |
-
critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3281 |
-
"CRITICAL_COUNTRY_RULE",
|
| 3282 |
-
critical_result.get("๋น๊ณ ", "-"),
|
| 3283 |
)
|
| 3284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3285 |
|
| 3286 |
if is_always_pass_component(material, component):
|
| 3287 |
result = {
|
|
@@ -3448,32 +3524,34 @@ def process_single_ingredient(
|
|
| 3448 |
final_result = None
|
| 3449 |
source = ""
|
| 3450 |
|
| 3451 |
-
critical_result =
|
| 3452 |
-
|
| 3453 |
-
|
| 3454 |
-
|
| 3455 |
-
|
|
|
|
|
|
|
| 3456 |
|
| 3457 |
-
|
| 3458 |
-
|
| 3459 |
-
|
| 3460 |
-
|
| 3461 |
-
|
| 3462 |
-
|
| 3463 |
-
|
| 3464 |
-
|
| 3465 |
-
|
| 3466 |
|
| 3467 |
-
|
| 3468 |
-
|
| 3469 |
-
|
| 3470 |
-
|
| 3471 |
-
|
| 3472 |
-
|
| 3473 |
-
|
| 3474 |
-
|
| 3475 |
|
| 3476 |
-
|
| 3477 |
|
| 3478 |
if is_always_pass_component(material, component):
|
| 3479 |
result_rows.append({
|
|
@@ -3496,15 +3574,17 @@ def process_single_ingredient(
|
|
| 3496 |
|
| 3497 |
continue
|
| 3498 |
|
| 3499 |
-
fragrance_result =
|
| 3500 |
-
|
| 3501 |
-
|
| 3502 |
-
|
| 3503 |
-
|
|
|
|
|
|
|
| 3504 |
|
| 3505 |
-
|
| 3506 |
-
|
| 3507 |
-
|
| 3508 |
|
| 3509 |
if final_result is None and mfds_df is not None and not mfds_df.empty:
|
| 3510 |
mfds_result = evaluate_live_detail_rule(
|
|
@@ -3530,7 +3610,7 @@ def process_single_ingredient(
|
|
| 3530 |
final_result = file_result
|
| 3531 |
source = "COUNTRY_FILE_FAST"
|
| 3532 |
|
| 3533 |
-
if final_result is None:
|
| 3534 |
local_result = evaluate_local_rules(
|
| 3535 |
country=country,
|
| 3536 |
material=material,
|
|
|
|
| 75 |
NO_EVIDENCE_TEXT = "ํด๋น ์๋ฃ ๋ด ์ ํ ๊ทผ๊ฑฐ ์์"
|
| 76 |
NEED_CHECK_TEXT = "ํ์ธ ํ์"
|
| 77 |
LIMIT_CHECK_TEXT = "๋ฐฐํฉํ๋ ํ์ธ ํ์"
|
| 78 |
+
|
| 79 |
+
# ============================================================
|
| 80 |
+
# SOURCE_ONLY_MODE
|
| 81 |
+
# True:
|
| 82 |
+
# - ์
๋ก๋๋ ๊ตญ๊ฐ๋ณ ๊ท์ ํ์ผ์์ ์ง์ ์ฐพ์ ๊ทผ๊ฑฐ๋ง ํ์ ์ ์ฌ์ฉ
|
| 83 |
+
# - UV_FILTER_RULES / PRESERVATIVE_RULES / CRITICAL_COUNTRY_RULES ๊ฐ์ ํ๋์ฝ๋ฉ ํ๋ยท๊ธ์ง ์๋ํ์ ๋นํ์ฑํ
|
| 84 |
+
# - ํ์ผ์์ ์ฑ๋ถ๋ช
์ด ๋ฐ๊ฒฌ๋์ด๋ ๊ธ์ง/์ ํ/ํ๋ ํํ์ด ์์ผ๋ฉด ๋ฌธ์ ์ฑ๋ถ์ผ๋ก ํ์ํ์ง ์์
|
| 85 |
+
# False:
|
| 86 |
+
# - ๊ธฐ์กด์ฒ๋ผ ๋ก์ปฌ ํ๋์ฝ๋ฉ ๊ท์น๋ ํจ๊ป ์ฌ์ฉ
|
| 87 |
+
# ============================================================
|
| 88 |
+
SOURCE_ONLY_MODE = True
|
| 89 |
MFDS_LIVE_URL = "https://nedrug.mfds.go.kr/pbp/CCBDF01"
|
| 90 |
# ์๋ ์๊ธํจ์น
|
| 91 |
# - ์ ์ฒด ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋์์๋ MFDS ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉํ์ง ์๋๋ค.
|
|
|
|
| 2214 |
final_result = None
|
| 2215 |
source = ""
|
| 2216 |
|
| 2217 |
+
if not SOURCE_ONLY_MODE:
|
| 2218 |
+
final_result = evaluate_critical_country_rule(
|
| 2219 |
+
country=country,
|
| 2220 |
+
material=mat,
|
| 2221 |
+
component=comp,
|
| 2222 |
+
)
|
| 2223 |
|
| 2224 |
+
if final_result is not None:
|
| 2225 |
+
source = "CRITICAL_COUNTRY_RULE"
|
| 2226 |
|
| 2227 |
if final_result is None and is_always_pass_component(mat, comp):
|
| 2228 |
final_result = {
|
|
|
|
| 2233 |
}
|
| 2234 |
source = "ALWAYS_PASS_RULE"
|
| 2235 |
|
| 2236 |
+
if final_result is None and not SOURCE_ONLY_MODE:
|
| 2237 |
fragrance_result = evaluate_plain_fragrance_rule(
|
| 2238 |
country=country,
|
| 2239 |
material=mat,
|
|
|
|
| 2268 |
final_result = file_result
|
| 2269 |
source = "COUNTRY_FILE_FAST"
|
| 2270 |
|
| 2271 |
+
if final_result is None and not SOURCE_ONLY_MODE:
|
| 2272 |
local_result = evaluate_local_rules(
|
| 2273 |
country=country,
|
| 2274 |
material=mat,
|
|
|
|
| 2915 |
|
| 2916 |
|
| 2917 |
def extract_limit_condition_from_context(context):
|
| 2918 |
+
"""
|
| 2919 |
+
ํ๋ ์ถ์ถ ๊ฐํ ๋ฒ์ .
|
| 2920 |
+
๊ธฐ์กด ๋ฌธ์ :
|
| 2921 |
+
- ๋ฌธ๋งฅ์ ์ซ์/%๊ฐ ์๊ธฐ๋ง ํด๋ ๋ฐฐํฉํ๋์ฒ๋ผ ์กํ ์ ์์.
|
| 2922 |
+
๊ฐ์ :
|
| 2923 |
+
- ์ฑ๋ถ ์ฃผ๋ณ ๋ฌธ๋งฅ์ '๋ฐฐํฉํ๋/maximum/limit/not exceed/์ดํ/์ต๋/์ ํ์ฌํญ' ๊ฐ์ ์ ํ ํค์๋๊ฐ ์์ด์ผ๋ง ํ๋ ์ถ์ถ.
|
| 2924 |
+
- ํ์/๋ผ๋ฒจ/์๋ ๋ฅด๊ฒ/๋ถ์๋ฌผ/์ํ๋ฒ/ppm ๊ด๋ฆฌ๊ฐ ๋ฑ์ ๋ฐฐํฉํ๋๋ก ๋ณด์ง ์์.
|
| 2925 |
+
"""
|
| 2926 |
text = safe_str(context)
|
| 2927 |
compact = re.sub(r"\s+", " ", text).strip()
|
| 2928 |
+
|
| 2929 |
if not compact:
|
| 2930 |
return "", ""
|
| 2931 |
|
| 2932 |
+
limit_keywords = [
|
| 2933 |
+
"๋ฐฐํฉํ๋", "๋ฐฐํฉ ํ๋", "์ฌ์ฉํ๋", "์ฌ์ฉ ํ๋", "์ ํ์ฌํญ", "์ฌ์ฉ์ ํ", "์ฌ์ฉ ์ ํ",
|
| 2934 |
+
"์ต๋", "์ดํ", "ํ๋", "maximum", "max.", "limit", "limits", "limited",
|
| 2935 |
+
"restriction", "restricted", "not exceed", "not exceeding", "no more than",
|
| 2936 |
+
]
|
| 2937 |
+
|
| 2938 |
+
false_limit_keywords = [
|
| 2939 |
+
"label", "labeling", "labelling", "๋ผ๋ฒจ", "ํ์", "์๋ ๋ฅด๊ฒ", "allergen",
|
| 2940 |
+
"warning", "๊ฒฝ๊ณ ", "๋ถ์๋ฌผ", "impurity", "์ํ", "์ํ๋ฒ", "test method",
|
| 2941 |
+
"analysis", "๊ฒ์ฌ", "๊ด๋ฆฌ๊ฐ", "๊ฒ์ถํ๊ณ", "detection limit",
|
| 2942 |
+
"peroxide value", "์ฐ๊ฐ", "์๋", "purity",
|
| 2943 |
+
]
|
| 2944 |
+
|
| 2945 |
+
candidate_lines = []
|
| 2946 |
+
lines = [safe_str(x) for x in text.splitlines() if safe_str(x)]
|
| 2947 |
+
|
| 2948 |
+
for line in lines:
|
| 2949 |
+
low = line.lower()
|
| 2950 |
+
if any(k.lower() in low for k in false_limit_keywords):
|
| 2951 |
+
continue
|
| 2952 |
+
if any(k.lower() in low for k in limit_keywords):
|
| 2953 |
+
candidate_lines.append(line)
|
| 2954 |
+
|
| 2955 |
+
search_text = "\n".join(candidate_lines)
|
| 2956 |
+
if not search_text and any(k.lower() in compact.lower() for k in limit_keywords):
|
| 2957 |
+
if not any(k.lower() in compact.lower() for k in false_limit_keywords):
|
| 2958 |
+
search_text = compact
|
| 2959 |
+
|
| 2960 |
+
if not search_text:
|
| 2961 |
+
return "", ""
|
| 2962 |
+
|
| 2963 |
patterns = [
|
| 2964 |
r"([0-9]+(?:\.[0-9]+)?\s*%)",
|
|
|
|
| 2965 |
r"([0-9]+(?:\.[0-9]+)?\s*g\s*/\s*100\s*g)",
|
| 2966 |
r"([0-9]+(?:\.[0-9]+)?\s*g\s+per\s+100\s*g)",
|
|
|
|
| 2967 |
]
|
| 2968 |
+
|
| 2969 |
limits = []
|
| 2970 |
for pat in patterns:
|
| 2971 |
+
for m in re.finditer(pat, search_text, flags=re.IGNORECASE):
|
| 2972 |
v = m.group(1).replace(" ", "")
|
| 2973 |
if v not in limits:
|
| 2974 |
limits.append(v)
|
| 2975 |
|
| 2976 |
+
# ppm์ ๋ถ์๋ฌผ ๊ด๋ฆฌ๊ฐ์ธ ๊ฒฝ์ฐ๊ฐ ๋ง์ผ๋ฏ๋ก 'maximum concentration/๋ฐฐํฉํ๋'๊ฐ ๊ฐ์ ๋ฌธ์ฅ์ ์์ ๋๋ง ํ์ฉ
|
| 2977 |
+
for line in candidate_lines:
|
| 2978 |
+
low = line.lower()
|
| 2979 |
+
if ("ppm" in low) and any(k in low for k in ["maximum concentration", "max concentration", "๋ฐฐํฉํ๋", "์ฌ์ฉํ๋"]):
|
| 2980 |
+
for m in re.finditer(r"([0-9]+(?:\.[0-9]+)?\s*ppm)", line, flags=re.IGNORECASE):
|
| 2981 |
+
v = m.group(1).replace(" ", "")
|
| 2982 |
+
if v not in limits:
|
| 2983 |
+
limits.append(v)
|
| 2984 |
+
|
| 2985 |
condition_keywords = [
|
| 2986 |
"leave-on", "rinse-off", "oral", "mucosa", "washed away",
|
| 2987 |
"๋ณด์กด์ ", "๋ฐฉ๋ถ์ ", "์์ธ์ ", "์์", "์ ๋ง", "๊ตฌ๊ฐ",
|
| 2988 |
+
"์ ํ์ฌํญ", "condition", "ํ๋", "์ ํ", "maximum", "limit",
|
| 2989 |
]
|
| 2990 |
+
|
| 2991 |
condition_lines = []
|
| 2992 |
+
for line in candidate_lines:
|
| 2993 |
l = line.lower()
|
| 2994 |
if any(k.lower() in l for k in condition_keywords):
|
| 2995 |
cleaned = re.sub(r"\s+", " ", line).strip()
|
|
|
|
| 3010 |
display = f"๋ฐฐํฉํ๋: {limit_text}"
|
| 3011 |
result = f"{display_country(country)} {label}์์ ์ฑ๋ถ ํ์ธ / ํ๋ {limit_text}"
|
| 3012 |
elif kind.startswith("positive_"):
|
| 3013 |
+
display = "Pass"
|
| 3014 |
+
result = NO_EVIDENCE_TEXT
|
| 3015 |
else:
|
| 3016 |
display = "๋ฐฐํฉํ๋/์ ํ ํ์ธ"
|
| 3017 |
result = f"{display_country(country)} {label}์์ ์ฑ๋ถ ํ์ธ / ํ๋ยท์กฐ๊ฑด ํ์ธ ํ์"
|
|
|
|
| 3288 |
|
| 3289 |
if reg_kind.startswith("positive_"):
|
| 3290 |
limit_text, condition_text = extract_limit_condition_from_context(context)
|
| 3291 |
+
|
| 3292 |
+
# Positive List์ ์ฑ๋ถ์ด ์๋ค๋ ์ฌ์ค๋ง์ผ๋ก๋ ๋ฌธ์ ์ฑ๋ถ์ด ์๋๋ค.
|
| 3293 |
+
# ๋ช
ํํ ํ๋ ์์น๊ฐ ์์ ๋๋ง ๋ฐฐํฉํ๋๋ก ํ์ํ๊ณ ,
|
| 3294 |
+
# ํ๋ ์์น๊ฐ ์์ผ๋ฉด Pass๋ก ๋๋ ๊ทผ๊ฑฐํ์ผ์ ๋น๊ณ /Evidence Log์ ๋จ๊ธด๋ค.
|
| 3295 |
+
if limit_text:
|
| 3296 |
+
result = {
|
| 3297 |
+
"๋ํ INCI": representative,
|
| 3298 |
+
"๊ฒฐ๊ณผ": f"{country_col} {reg_label}์์ ์ฑ๋ถ ์ง์ ํ์ธ / ํ๋ {limit_text}" + (f" / ์กฐ๊ฑด: {condition_text}" if condition_text else ""),
|
| 3299 |
+
"ํ์๋ฌธ๊ตฌ": f"๋ฐฐํฉํ๋: {limit_text}",
|
| 3300 |
+
"๋น๊ณ ": f"[์ถ์ฒํ์ผ: {best.get('source_file', '')}] [row: {best.get('row_index', '')}] {context[:900]}",
|
| 3301 |
+
}
|
| 3302 |
+
else:
|
| 3303 |
+
result = {
|
| 3304 |
+
"๋ํ INCI": representative,
|
| 3305 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 3306 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 3307 |
+
"๋น๊ณ ": f"ํ์ฉ๋ชฉ๋ก์์ ์ฑ๋ถ๋ช
์ ํ์ธ๋์์ผ๋ ๋ฐฐํฉํ๋ ์์น ๊ทผ๊ฑฐ ์์ / [์ถ์ฒํ์ผ: {best.get('source_file', '')}] [row: {best.get('row_index', '')}] {context[:900]}",
|
| 3308 |
+
}
|
| 3309 |
+
|
| 3310 |
log_search_context(target_id, country, component, result["๊ฒฐ๊ณผ"], "UPLOADED_SOURCE_RECORD_POSITIVE", result["๋น๊ณ "])
|
| 3311 |
return result
|
| 3312 |
|
| 3313 |
# ํ์ผ์์๋ ์ฑ๋ถ์ ์ฐพ์์ง๋ง ํ์ผ ์ ํ์ด ๋ถ๋ช
ํํ ๊ฒฝ์ฐ:
|
| 3314 |
+
# ๊ธ์ง/์ ํ/ํ๋ ํค์๋๊ฐ ๋ช
ํํ์ง ์์ผ๋ฉด ๋ฌธ์ ์ฑ๋ถ์ผ๋ก ๋ง๋ค์ง ์๋๋ค.
|
| 3315 |
result = {
|
| 3316 |
"๋ํ INCI": representative,
|
| 3317 |
+
"๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
|
| 3318 |
+
"ํ์๋ฌธ๊ตฌ": "Pass",
|
| 3319 |
+
"๋น๊ณ ": f"ํ์ผ์์ ์ฑ๋ถ๋ช
์ ๋ฐ๊ฒฌ๋์์ผ๋ ๊ธ์ง/์ ํ/ํ๋ ๊ทผ๊ฑฐ ์์ / [์ถ์ฒํ์ผ: {best.get('source_file', '')}] [row: {best.get('row_index', '')}] {context[:900]}",
|
| 3320 |
}
|
| 3321 |
+
log_search_context(target_id, country, component, result["๊ฒฐ๊ณผ"], "UPLOADED_SOURCE_RECORD_UNKNOWN_PASS", result["๋น๊ณ "])
|
| 3322 |
return result
|
| 3323 |
|
| 3324 |
|
|
|
|
| 3340 |
cas_no = safe_str(component.get("CAS.No", ""))
|
| 3341 |
representative = inci_name or korean_name or cas_no or "-"
|
| 3342 |
|
| 3343 |
+
critical_result = None
|
| 3344 |
+
if not SOURCE_ONLY_MODE:
|
| 3345 |
+
critical_result = evaluate_critical_country_rule(
|
| 3346 |
+
country=country,
|
| 3347 |
+
material=material,
|
| 3348 |
+
component=component,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3349 |
)
|
| 3350 |
+
|
| 3351 |
+
if critical_result is not None:
|
| 3352 |
+
log_search_context(
|
| 3353 |
+
target_id,
|
| 3354 |
+
country,
|
| 3355 |
+
component,
|
| 3356 |
+
critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3357 |
+
"CRITICAL_COUNTRY_RULE",
|
| 3358 |
+
critical_result.get("๋น๊ณ ", "-"),
|
| 3359 |
+
)
|
| 3360 |
+
return critical_result
|
| 3361 |
|
| 3362 |
if is_always_pass_component(material, component):
|
| 3363 |
result = {
|
|
|
|
| 3524 |
final_result = None
|
| 3525 |
source = ""
|
| 3526 |
|
| 3527 |
+
critical_result = None
|
| 3528 |
+
if not SOURCE_ONLY_MODE:
|
| 3529 |
+
critical_result = evaluate_critical_country_rule(
|
| 3530 |
+
country=country,
|
| 3531 |
+
material=material,
|
| 3532 |
+
component=component,
|
| 3533 |
+
)
|
| 3534 |
|
| 3535 |
+
if critical_result is not None:
|
| 3536 |
+
result_rows.append({
|
| 3537 |
+
"๊ตญ๊ฐ": country_col,
|
| 3538 |
+
"๊ฒ์์ด": shorten_for_table(single_query, 80),
|
| 3539 |
+
"๋ฐฐํฉํ๋/๊ธ์ง": critical_result.get("ํ์๋ฌธ๊ตฌ", "๋ฐฐํฉ๊ธ์ง"),
|
| 3540 |
+
"์์ธ ํ์ ": critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3541 |
+
"ํ์ ์ถ์ฒ": "CRITICAL_COUNTRY_RULE",
|
| 3542 |
+
"๋น๊ณ ": simplify_single_note(critical_result.get("๋น๊ณ ", "-")),
|
| 3543 |
+
})
|
| 3544 |
|
| 3545 |
+
log_search_context(
|
| 3546 |
+
"single_ingredient",
|
| 3547 |
+
country,
|
| 3548 |
+
component,
|
| 3549 |
+
critical_result.get("๊ฒฐ๊ณผ", ""),
|
| 3550 |
+
"CRITICAL_COUNTRY_RULE",
|
| 3551 |
+
critical_result.get("๋น๊ณ ", "-"),
|
| 3552 |
+
)
|
| 3553 |
|
| 3554 |
+
continue
|
| 3555 |
|
| 3556 |
if is_always_pass_component(material, component):
|
| 3557 |
result_rows.append({
|
|
|
|
| 3574 |
|
| 3575 |
continue
|
| 3576 |
|
| 3577 |
+
fragrance_result = None
|
| 3578 |
+
if not SOURCE_ONLY_MODE:
|
| 3579 |
+
fragrance_result = evaluate_plain_fragrance_rule(
|
| 3580 |
+
country=country,
|
| 3581 |
+
material=material,
|
| 3582 |
+
component=component,
|
| 3583 |
+
)
|
| 3584 |
|
| 3585 |
+
if fragrance_result is not None:
|
| 3586 |
+
final_result = fragrance_result
|
| 3587 |
+
source = "FRAGRANCE_RULE"
|
| 3588 |
|
| 3589 |
if final_result is None and mfds_df is not None and not mfds_df.empty:
|
| 3590 |
mfds_result = evaluate_live_detail_rule(
|
|
|
|
| 3610 |
final_result = file_result
|
| 3611 |
source = "COUNTRY_FILE_FAST"
|
| 3612 |
|
| 3613 |
+
if final_result is None and not SOURCE_ONLY_MODE:
|
| 3614 |
local_result = evaluate_local_rules(
|
| 3615 |
country=country,
|
| 3616 |
material=material,
|