FLYAI4 / focus-point-research

Focus Point 리서치를 위한 Repo 입니다.
0 stars 2 forks source link

[DS][BUG] ChatGPT 파싱 수정 요청 #14

Open robert-min opened 5 months ago

robert-min commented 5 months ago

📌 Description

현재 처리하는 코드

def extract_coord_keyword(content: str):
    from collections import defaultdict
    pattern = r"'(.*?)':\[(.*?\n)"

    # TODO : 좌표 추출 코드 수정
    matches = re.findall(pattern, content)
    all_coords = defaultdict(list)
    for name, coords in matches:
        coords = coords.replace("\n", "")[1:-1].split("],[")
        for idx, coord in enumerate(coords):
            if idx == len(coords) - 1:
                while coord[-1] == "]":
                    coord = coord[:-1]
            temp = list(map(int, coord.split(",")))
            all_coords[name].append(temp)
    return all_coords

예외 상황

  1. 위의 코드로 현재 처리하는 경우

    • 괄호 안에 값들이 좌표별로 잘 들어 가있음
    • 'hot air balloons': [[143,38,225,119], [198,49,274,132], [348,69,394,113]]\n
    • 'river': [[354,187,637,423]]\n
    • 'terraced fields': [[43,241,802,707]]"
  2. 에러가 발생하는 경우

    • 좌표마다 괄호 두개를 해서 값을 보냄
    • 'hot air balloons':[[58,31,139,85]], [[176,15,243,68]], [[282,7,324,39]]\n
    • 'river':[[179,237,429,292]]\n
    • 'terraced fields':[[88,308,394,600]]


🎈 Goal

$\tiny{구체적인\ 산출물을\ 포함한\ 목표를\ 작성해주세요.}$

둘 중 더 편한 방법으로 진행!!


✏️ Todo

$\tiny{목표\ 달성을\ 위해\ 해야할\ 일을\ 세부적으로\ 작성해주세요.}$

kimdoeon commented 5 months ago

📌 Description

수정사항

kimdoeon commented 5 months ago

📌 Description

  1. response로 받은 raw content에서 개행/탭 제거하는 refine_ouput_first 함수 추가
  2. 키워드/좌표 추출 함수 extract_coord_keyword 수정
kimdoeon commented 5 months ago

📌 Description

1. extract_coord_keyword 수정

kimdoeon commented 5 months ago

📌 Description

출력 형식이 수정되어 refine_output 함수 수정.

kimdoeon commented 5 months ago

📌 Description

refine_output 함수 수정. 해설 앞 부분 AI의 변명(I cannot, i do not ~) 제거, json, JSON, {, 정수 들어간 문장 제거.

def refine_output(content: str) -> str:
    # AI 변명, focus-pointing에서 걸러지지 않은 문장 제거
    words=["cannot", "AI", "do not", "can't", "json", "JSON", "{",]
    output = ""

    sentences = content.split(". ")
    for sentence in sentences:
        if not any(word in sentence for word in words) and not re.search(r'\d',sentence):
            output+=sentence

    if not output:
        return content

    else:
        return output
robert-min commented 5 months ago

240213 기준 프롬프팅

"You are an expert art historian with vast knowledge about artists throughout history who revolutionized their craft.",
"You will begin by briefly summarizing the personal life and achievements of the artist.",
"Then you will go on to explain the medium, style, and influences of their works.",
"Then you will provide short descriptions of what they depict and any notable characteristics they might have.",
"Fianlly identify THREE keywords in the picture and provide each coordinate of the keywords in the last sentence.",
"For example, Give the coordinate value of the keywords in json format.",
"if the keyword is pretty_woman and big_ball, value is  ```json{\"pretty_woman\", [[x0,y0,x1,y1]], \"big_ball\", [[x0,y0,x1,y1], [x2,y2,x3,y3]]}```",
"The values ​​entered in x0, y0, x1, y1 are unconditionally the coordinate values ​​of each keyword.",