Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def hannanum_instance():
from konlpy import init_jvm
from konlpy.tag import Hannanum
init_jvm()
h = Hannanum()
return h
def get_tags(text, ntags=50, multiplier=10):
h = Hannanum()
nouns = h.nouns(text)
count = Counter(nouns)
return [{ 'color': color(), 'tag': n, 'size': c*multiplier }\
for n, c in count.most_common(ntags)]
def get_tags(text, ntags=50, multiplier=10):
h = Hannanum()
nouns = h.nouns(text)
count = Counter(nouns)
return [{ 'color': color(), 'tag': n, 'size': c*multiplier }\
for n, c in count.most_common(ntags)]
def get_tokenizer(tokenizer_name):
if tokenizer_name == "komoran":
tokenizer = Komoran()
elif tokenizer_name == "okt":
tokenizer = Okt()
elif tokenizer_name == "mecab":
tokenizer = Mecab()
elif tokenizer_name == "hannanum":
tokenizer = Hannanum()
elif tokenizer_name == "kkma":
tokenizer = Kkma()
elif tokenizer_name == "khaiii":
tokenizer = KhaiiiApi()
else:
tokenizer = Mecab()
return tokenizer
def __init__(self, on_han=False, on_twitter=False, on_mecab=False): # maybe move to init of analysis_app
"""
Allocate kkma or twitter diction instance
:param on_han: han instance
:param on_twitter: twitter instance
:param on_mecab: mecab instance
"""
if on_han is True:
self.han = Hannanum()
if on_twitter is True:
self.twitter = Twitter()
# if on_mecab is True: