안녕하세요 전 정규식을 다루지 않았으며 파이썬과 NLTK로 원시 텍스트를 사전 처리하려고합니다. 내가 사용하여 문서를 토큰 화하려고 할 때 :파이썬 정규 표현식 nltk 웹 사이트 추출
tokens = nltk.regexp_tokenize(corpus, sentence_re)
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
| \w+(-\w+)* # words with optional internal hyphens
| \$?\d+(\.\d+)?%? # currency and percentages, e.g. $12.40, 82%
| \#?\w+|\@?\w+ # hashtags and @ signs
| \.\.\. # ellipsis
| [][.,;"'?()-_`] # these are separate tokens
| ?:http://|www.)[^"\' ]+ # websites
'''
의 하나의 토큰으로 웹 사이트의 모든을 할 수 없습니다 :
print toks[:50]
['on', '#Seamonkey', '(', 'SM', ')', '-', 'I', 'had', 'a', 'short', 'chirp', 'exchange', 'with', '@angie1234p', 'at', 'the', '18thDec', ';', 'btw', 'SM', 'is', 'faster', 'has', 'also', 'an', 'agile', '...', '1', '/', '2', "'", '...', 'user', 'community', '-', 'http', ':', '/', '/', 'bit', '.', 'ly', '/', 'XnF5', '+', 'ICR', 'http', ':', '/', '/']
이 어떤 도움이 크게 appreicated된다. 정말 고마워!
-Florie
이 토크 나이의 RegularExpressions에서
자연어 구문 분석은 정규식 학습을 시작하기에 충분합니다. –