from konlpy.tag import Twitter
twitter = Twitter()
twitter.pos('파이썬을 활용한 자연어 수업자료')
[('파이썬', 'Noun'), ('을', 'Josa'), ('활용한', 'Verb'), ('자연어', 'Noun'), ('수업', 'Noun'), ('자료', 'Noun')]
text = "워런 버핏은 삼성전자가 아닌 애플주식을 왜 샀을까"
%%time
print(twitter.pos(text, stem=True))
[('워런', 'Noun'), ('버핏', 'Noun'), ('은', 'Josa'), ('삼성', 'Noun'), ('전자', 'Noun'), ('가', 'Josa'), ('아니다', 'Adjective'), ('애플', 'Noun'), ('주식', 'Noun'), ('을', 'Josa'), ('왜', 'Noun'), ('사다', 'Verb')] CPU times: user 821 ms, sys: 34 ms, total: 855 ms Wall time: 564 ms
%%time
print(twitter.pos(text))
[('워런', 'Noun'), ('버핏', 'Noun'), ('은', 'Josa'), ('삼성', 'Noun'), ('전자', 'Noun'), ('가', 'Josa'), ('아닌', 'Adjective'), ('애플', 'Noun'), ('주식', 'Noun'), ('을', 'Josa'), ('왜', 'Noun'), ('샀', 'Verb'), ('을까', 'Eomi')] CPU times: user 48.4 ms, sys: 26 µs, total: 48.4 ms Wall time: 67 ms
%%time
from konlpy.tag import Kkma
kkma = Kkma()
print(kkma.pos(text))
[('워', 'UN'), ('런', 'NNG'), ('버핏', 'UN'), ('은', 'JX'), ('삼성전자', 'NNG'), ('가', 'JKS'), ('아니', 'VV'), ('ㄴ', 'ETD'), ('애플', 'NNP'), ('주식', 'NNG'), ('을', 'JKO'), ('왜', 'MAG'), ('사', 'VV'), ('었', 'EPT'), ('을까', 'EFQ')] CPU times: user 21.6 s, sys: 229 ms, total: 21.8 s Wall time: 16.1 s
%%time
from konlpy.tag import Hannanum
han = Hannanum()
print(han.pos(text))
[('워런', 'N'), ('버핏', 'N'), ('은', 'J'), ('삼성전자', 'N'), ('가', 'J'), ('아니', 'P'), ('ㄴ', 'E'), ('애플주식', 'N'), ('을', 'J'), ('왜', 'M'), ('사', 'P'), ('아ㄹ까', 'E')] CPU times: user 8.6 s, sys: 77 ms, total: 8.68 s Wall time: 5.29 s