텍스트 분석을 위한 품사 태깅
한 언어 학습 앱에서 사용자들이 문장 구조를 이해할 수 있도록 각 단어의 문법적 역할을 하이라이트하려고 합니다. 여러분의 과제는 Hugging Face pipeline을 사용해 주어진 문장의 각 단어에 해당하는 품사(PoS) 태그를 라벨링하는 것입니다.
이 연습은 강의의 일부입니다
Python으로 배우는 Natural Language Processing (NLP)
연습 안내
"vblagoje/bert-english-uncased-finetuned-pos"모델로pos_pipeline을 생성하세요.- 제공된
sentence에 이 pipeline을 적용하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
from transformers import pipeline
# Create the PoS tagging pipeline
pos_pipeline = pipeline(
task="____",
model="____",
grouped_entities=True
)
sentence = "I am meeting my friends for coffee this afternoon."
# Get PoS tags
pos_tags = ____
for token in pos_tags:
print(f"{token['word']}: {token['entity_group']}")