spaCy로 배우는 자연어 처리
Azadeh Mobasher
Principal data scientist
annotated_data = {
"sentence": "An antiviral drugs used against influenza is neuraminidase inhibitors.",
"entities": {
"label": "Medicine",
"value": "neuraminidase inhibitors",
}
}
annotated_data = {
"sentence": "Bill Gates visited the SFO Airport.",
"entities": [{"label": "PERSON", "value": "Bill Gates"},
{"label": "LOC", "value": "SFO Airport"}]
}
training_data = [
("I will visit you in Austin.", {"entities": [(20, 26, "GPE")]}),
("I'm going to Sam's house.", {"entities": [(13,18, "PERSON"), (19, 24, "GPE")]}),
("I will go.", {"entities": []})
]
세 개의 예시 쌍:
원시 텍스트를 그대로 spaCy에 넣을 수는 없습니다
각 훈련 예시에 대해 Example 객체를 만들어야 합니다
import spacy from spacy.training import Example nlp = spacy.load("en_core_web_sm") doc = nlp("I will visit you in Austin.")annotations = {"entities": [(20, 26, "GPE")]} example_sentence = Example.from_dict(doc, annotations)print(example_sentence.to_dict())
spaCy로 배우는 자연어 처리