31 lines
1019 B
Python
31 lines
1019 B
Python
from descriptor import describe_input
|
|
|
|
def decriminate(json_result, thold_high, thold_low):
|
|
"""
|
|
광고 이미지 평가 결과(JSON)를 기반으로 합격/불합격 판정. - GPT API 사용
|
|
조건:
|
|
- thold_high : 최소 '상' 등급 요구치
|
|
- thold_low : 최대 '하' 등급 허용치
|
|
→ 두 조건을 모두 만족하면 '합격', 그렇지 않으면 '불합격'
|
|
"""
|
|
if not isinstance(json_result, dict):
|
|
print("입력 데이터가 JSON(dict) 형식이 아닙니다.")
|
|
return False
|
|
|
|
high_count = 0
|
|
low_count = 0
|
|
|
|
# 설명(description) 키 제외, 주요 평가 항목만 체크
|
|
for key, value in json_result.items():
|
|
if key == "설명":
|
|
continue
|
|
if isinstance(value, str):
|
|
if "상" in value:
|
|
high_count += 1
|
|
elif "하" in value:
|
|
low_count += 1
|
|
|
|
if high_count >= thold_high and low_count == thold_low:
|
|
return True
|
|
else:
|
|
return False |