boostcampaitech2 / mrc-level2-nlp-14

mrc-level2-nlp-14 created by GitHub Classroom
MIT License
10 stars 8 forks source link

[Data] preprocessing for all data #13

Closed taeukkkim closed 2 years ago

taeukkkim commented 2 years ago

다음과 같이 학습에 방해가 되는 문자들에 대해 추가적으로 전처리를 진행하였습니다.

image image

edit date = 10/20 21:40:00

def preprocess(text):
    text = text.strip()
    text = re.sub(r"\n", " ", text)
    text = re.sub(r"\\n", " ", text)
    text = re.sub(r"#", " ", text)
    text = re.sub(r"loc=§\s{0,2}\d*\s{0,2}and\s{0,2}\d*", " ", text)
    text = re.sub(r"loc=§\s{0,2}\d*", " ", text)
    text = re.sub(r"group=주해|group=주|group=참고"," ",text)
    text = re.sub(r"(p{1,2}=\d*)(-\d*){0,1}"," ",text)
    text = re.sub(r"(\d*년 \d*월 \d*일에 확인)함{0,1}"," ", text)
    text = re.sub(r"(날짜=\d+년\s{0,1}\d+월)(\s{0,1}\d+일){0,1}", " ", text)
    text = re.sub(r"날짜=\d+-\d+-\d+", " ", text)
    text = re.sub(r"\s+", " ", text)
    text = re.sub(r"[^a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣぁ-ゔァ-ヴー々〆〤一-龥<>\/\(\)\s\.\?!\'<>:%\,\+・\"\-\∧\~\°〈≪《「『<≫〉》」』>\"-”]", "", text)
    text = re.sub(r"\(\s*\)", '', text)
    return text