본문 바로가기
Data/자연어 처리

cdQA-annotator 데이터셋 구성

by forestlim 2020. 12. 10.
728x90
반응형

cdQA-annotator는 node.js기반으로 squad(korquad) 데이터셋을 쉽게 만들어주는 도구이다.

github.com/cdqa-suite/cdQA-annotator

 

cdqa-suite/cdQA-annotator

⛔ [NOT MAINTAINED] A web-based annotator for closed-domain question answering datasets with SQuAD format. - cdqa-suite/cdQA-annotator

github.com

paragraphs안에 context와 question과 answer를 넣어서 json을 만들 필요 없이 context만 잘 정리해서 넣어주면 된다.

실험삼아 wikipedia dataset을 불러와서 csv로 저장한 후 python으로 json 형태로 만드는 작업을 진행하였다.

import pandas as pd
import json
data = pd.read_csv('./data/wiki.csv')
for i in range(len(data)):
    squad_data={
        "title": data['title'][i],
        "paragraphs": [
            {
            "context": data['paragraphs1'][i],
            "qas": []
            },
            {
            "context": data['paragraphs2'][i],
            "qas": []
            }
        ]
    }
    with open('./data/wiki_make2.json','a') as outfile:
        outfile.write(json.dumps(squad_data))
        outfile.write(',')
        outfile.close()
with open('./data/wiki_make2.json','r',encoding='utf-8') as outfile:
    data = json.load(outfile)

question 없이 json파일로 잘 생성된 것을 볼 수 있다.

이제 cdQA-annotator에 파일을 넣어보자

Upload를 누르게 되면 이와 같은 페이지가 나오고 질문을 입력하고 해당하는 답변을 드래그 한 후 Add annotation을 누르게 되면 질문과 답변 형식으로 들어가게 된다.

모든 context에 이와 같은 작업을 진행한 후 완전한 KorQuAD 파일을 json형식으로 내려받을 수 있다.

728x90
반응형

댓글