Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Python - spaCy를 사용한 PoS 태깅 및 표제화

<시간/>

spaCy는 최고의 텍스트 분석 라이브러리 중 하나입니다. spaCy는 대규모 정보 추출 작업에 탁월하며 세계에서 가장 빠른 것 중 하나입니다. 딥 러닝을 위한 텍스트를 준비하는 가장 좋은 방법이기도 합니다. spaCy는 NLTKTagger 및 TextBlob보다 훨씬 빠르고 정확합니다.

설치 방법

pip install spacy
python -m spacy download en_core_web_sm

#importing loading the library
import spacy
# python -m spacy download en_core_web_sm
nlp = spacy.load("en_core_web_sm")
#POS-TAGGING
# Process whole documents
text = ("""My name is Vishesh. I love to work on data science problems. Please check out my github profile!""")
doc = nlp(text)
# Token and Tag
for token in doc:
print(token, token.pos_)
# You want list of Verb tokens
print("Verbs:", [token.text for token in doc if token.pos_ == "VERB"])
#Lemmatization : It is a process of grouping together the inflected #forms of a word so they can be analyzed as a single item, #identified by the word’s lemma, or dictionary form.
import spacy
# Load English tokenizer, tagger,
# parser, NER and word vectors
nlp = spacy.load("en_core_web_sm")
# Process whole documents
text = ("""My name is Vishesh. I love to work on data science problems. Please check out my github profile!""")
doc = nlp(text)
for token in doc:
print(token, token.lemma_)