25 lines
554 B
Python
25 lines
554 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import MeCab, sys, string
|
|
|
|
term = sys.argv[1]
|
|
#t = MeCab.Tagger('-d /usr/local/lib/mecab/dic/mecab-ko-dic') # ㅐon linux
|
|
t = MeCab.Tagger('-d /opt/homebrew/lib/mecab/dic/mecab-ko-dic') # on macbook air
|
|
|
|
mecabRes = t.parse(term)
|
|
|
|
mArray = mecabRes.split("\n")
|
|
#print(mArray)
|
|
|
|
res = ""
|
|
|
|
for i in range(len(mArray)-2) :
|
|
# res = res + mArray[i] + "\n"
|
|
res = res + mArray[i].split(",")[0] + "\n"
|
|
# if i != len(mArray)-3 :
|
|
# res = res + "\n"
|
|
# if i == 0:
|
|
# res = res + "\n"
|
|
|
|
print(res)
|