주석 달기와 학습 데이터 준비
데이터를 수집한 뒤에는 spaCy 모델이 요구하는 형식으로 데이터를 주석 처리할 수 있어요. 이 연습 문제에서는 의료 도메인의 NER 작업을 위해 올바른 주석 데이터 레코드를 만드는 연습을 해 볼 거예요.
sentence와 두 개의 엔티티가 제공되어 있어요. entity_1은 텍스트가 chest pain이고 유형은 SYMPTOM, entity_2는 텍스트가 hyperthyroidism이고 유형은 DISEASE예요.
이 연습은 강의의 일부입니다
spaCy로 배우는 자연어 처리
연습 안내
annotated_data레코드를 올바른 형식으로 완성하세요.- 각 엔티티의 시작과 끝 문자를 추출해 해당 변수에 저장하세요.
- 동일한 입력 문장과 그 엔티티들을 올바른 학습 형식으로
training_data에 저장하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
text = "A patient with chest pain had hyperthyroidism."
entity_1 = "chest pain"
entity_2 = "hyperthyroidism"
# Store annotated data information in the correct format
annotated_data = {"sentence": ____, "entities": [{"label": "SYMPTOM", "value": ____}, {"label": "DISEASE", "value": ____}]}
# Extract start and end characters of each entity
entity_1_start_char = text.____(____)
entity_1_end_char = entity_1_start_char + len(____)
entity_2_start_char = text.____(____)
entity_2_end_char = entity_2_start_char + len(____)
# Store the same input information in the proper format for training
training_data = [(____, {"entities": [(____,____,"SYMPTOM"),
(____,____,"DISEASE")]})]
print(training_data)