How to use the konlpy.tag.Komoran function in konlpy

To help you get started, we’ve selected a few konlpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github konlpy / konlpy / test / test_komoran.py View on Github external
def komoran_instance():
        from konlpy.tag import Komoran
        k = Komoran()
        return k
github dsindex / syntaxnet / api / parsey_sejong_client.py View on Github external
def do_inference(hostport):
  host, port = hostport.split(':')
  channel = implementations.insecure_channel(host, int(port))
  stub = parsey_api_pb2.beta_create_ParseyService_stub(channel)

  komoran = Komoran()

  while 1 :
    try : line = sys.stdin.readline()
    except KeyboardInterrupt : break
    if not line : break
    line = line.strip()
    request = parsey_api_pb2.ParseyRequest()
    conll_in = do_tagging(komoran, line)
    request.text.append(conll_in)
    response = stub.Parse(request, 5.0) # timeout 5 seconds
    json_obj=protobuf_json.pb2json(response)
    ret = json.dumps(json_obj,ensure_ascii=False,encoding='utf-8')
    print "Input : ", line
    print "Parsing :"
    print ret
github ratsgo / embedding / preprocess / supervised_nlputils.py View on Github external
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
github dsindex / syntaxnet / dragnn_examples / inference_dragnn_sejong.py View on Github external
# Loading model
    m = model.load_model(FLAGS.dragnn_spec,
                         FLAGS.resource_path,
                         FLAGS.checkpoint_filename,
                         enable_tracing=FLAGS.enable_tracing,
                         tf_master=FLAGS.tf_master)
    sess = m['session']
    graph = m['graph']
    builder = m['builder']
    annotator = m['annotator']

    # Analyze
    # Prepare korean morphological analyzer for segmentation
    from konlpy.tag import Komoran
    komoran = Komoran()
    startTime = time.time()
    while 1 :
        try : line = sys.stdin.readline()
        except KeyboardInterrupt : break
        if not line : break
        line = line.strip()
        if not line : continue
        segmented, tagged = model.segment_by_konlpy(line, komoran)
        # ex) line = '제주 로 가다 는 비행기 가 심하다 는 비바람 에 회항 하 었 다 .'
        line = ' '.join(segmented)
        parsed_sentence = model.inference(sess, graph, builder, annotator, line, FLAGS.enable_tracing)
        out = model.parse_to_conll(parsed_sentence, tagged)
        f = sys.stdout
        f.write('# text = ' + line.encode('utf-8') + '\n')
        for entry in out['conll'] :
            id = entry['id']
github dsindex / syntaxnet / dragnn_examples / www / dragnn_dm.py View on Github external
]

		tornado.web.Application.__init__(self, handlers, **settings)
		autoreload.add_reload_hook(self.finalize)

		self.log = setupAppLogger()
		ppid = os.getpid()
		self.log.info('initialize parent process[%s] ...' % (ppid))
		self.ppid = ppid
		self.enable_tracing = options.enable_tracing
		# import konlpy if enabled
		self.enable_konlpy = options.enable_konlpy
		self.komoran = None
		if options.enable_konlpy :
			from konlpy.tag import Komoran
			komoran = Komoran()
			self.komoran = komoran
		self.log.info('initialize parent process[%s] ... done' % (ppid))

		log.info('start http start...')