# 스탠포드 고유명사 태깅 프로그램(zip) 다운로드 경로 : https://nlp.stanford.edu/software/CRF-NER.shtml#Download
# import nltk
# nltk.download('punkt')
## 1. 고유명사 태깅하기
from nltk.tag import StanfordNERTagger
from nltk.tokenize import word_tokenize
STANFORD_NER_CLASSIFIER_PATH = 'F:/1_Study/1_BigData/7_FirstML/stanford-ner-2020-11-17/classifiers/english.muc.7class.distsim.crf.ser.gz'
STANFORD_NER_JAR_PATH = 'F:/1_Study/1_BigData/7_FirstML/stanford-ner-2020-11-17/stanford-ner-4.2.0.jar'
ner_tagger = StanfordNERTagger(STANFORD_NER_CLASSIFIER_PATH, STANFORD_NER_JAR_PATH)
text = 'One day in November 2016, the two authors of this book, Seungyeon and Youngjoo, had a coffer at Red Back cafe, which is very popular place in Mountain View.'
tokens = word_tokenize(text)
print(ner_tagger.tag(tokens))
# 장소 정보만 추출
all_locations = []
for token in ner_tagger.tag(tokens):
if token[1] == 'LOCATION':
all_locations.append(token[0])
print(', '.join(all_locations))
출처 : 처음 배우는 머신러닝 : 기초부터 모델링, 실전 예제, 문제 해결까지
'데이터분석 > Python' 카테고리의 다른 글
머신러닝 Example by Python - 주성분 분석을 이용한 사람 얼굴 인식 (이미지 인식 시스템) (0) | 2022.01.14 |
---|---|
머신러닝 Example by Python - 이미지 데이터를 이용한 K-평균 군집화 (이미지 인식 시스템) (0) | 2022.01.14 |
머신러닝 Example by Python - 품사 분석 시스템 만들기 (문서 분류) (0) | 2022.01.14 |
머신러닝 Example by Python - 토픽 모델 시스템 만들기 (문서 분류) (0) | 2022.01.14 |
머신러닝 Example by Python - 스팸 문자 필터 만들기 (문서 분류) (0) | 2022.01.14 |