示例#1
0
    def __init__(self,
                 jvmpath=None,
                 userdic=None,
                 modelpath=None,
                 max_heap_size=1024):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath, max_heap_size)

        if modelpath:
            self.modelpath = modelpath
        else:
            # FIXME: Cannot execute without sudoing
            # java.lang.NoClassDefFoundErrorPyRaisable: java.lang.NoClassDefFoundError: kr/co/shineware/nlp/komoran/core/analyzer/Komoran
            self.modelpath = os.path.join(utils.installpath, 'java', 'data',
                                          'models')
        self.tagset = utils.read_json('%s/data/tagset/komoran.json' %
                                      utils.installpath)

        komoranJavaPackage = jpype.JPackage('kr.co.shineware.nlp.komoran.core')

        try:
            self.jki = komoranJavaPackage.Komoran(self.modelpath)
        except TypeError:  # Package kr.lucypark.komoran.KomoranInterface is not Callable
            raise IOError(
                "Cannot access komoran-dic. Please leave an issue at https://github.com/konlpy/konlpy/issues"
            )

        if userdic:
            self.jki.setUserDic(userdic)
示例#2
0
    def __init__(self, jvmpath=None, max_heap_size=1024):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath, max_heap_size)

        oktJavaPackage = jpype.JPackage('kr.lucypark.okt')
        OktInterfaceJavaClass = oktJavaPackage.OktInterface
        self.jki = OktInterfaceJavaClass()
        self.tagset = utils.read_json('%s/data/tagset/twitter.json' % utils.installpath)
示例#3
0
文件: _mecab.py 项目: konlpy/konlpy
 def __init__(self, dicpath='/usr/local/lib/mecab/dic/mecab-ko-dic'):
     try:
         self.tagger = Tagger('-d %s' % dicpath)
         self.tagset = utils.read_json('%s/data/tagset/mecab.json' % utils.installpath)
     except RuntimeError:
         raise Exception('The MeCab dictionary does not exist at "%s". Is the dictionary correctly installed?\nYou can also try entering the dictionary path when initializing the Mecab class: "Mecab(\'/some/dic/path\')"' % dicpath)
     except NameError:
         raise Exception('Install MeCab in order to use it: http://konlpy.org/en/latest/install/')
示例#4
0
    def __init__(self, jvmpath=None):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath)

        tktJavaPackage = jpype.JPackage('kr.lucypark.tkt')
        TktInterfaceJavaClass = tktJavaPackage.TktInterface
        self.jki = TktInterfaceJavaClass()
        self.tagset = utils.read_json('%s/data/tagset/twitter.json' % utils.installpath)
示例#5
0
    def __init__(self, jvmpath=None, max_heap_size=1024):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath, max_heap_size)

        jhannanumJavaPackage = jpype.JPackage('kr.lucypark.jhannanum.comm')
        HannanumInterfaceJavaClass = jhannanumJavaPackage.HannanumInterface
        self.jhi = HannanumInterfaceJavaClass()  # Java instance
        self.tagset = utils.read_json('%s/data/tagset/hannanum.json' % utils.installpath)
示例#6
0
文件: _kkma.py 项目: konlpy/konlpy
    def __init__(self, jvmpath=None, max_heap_size=1024):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath, max_heap_size)

        kkmaJavaPackage = jpype.JPackage('kr.lucypark.kkma')
        KkmaInterfaceJavaClass = kkmaJavaPackage.KkmaInterface
        self.jki = KkmaInterfaceJavaClass()  # Java instance
        self.tagset = utils.read_json('%s/data/tagset/kkma.json' % utils.installpath)
示例#7
0
    def __init__(self, jvmpath=None):
        if not jpype.isJVMStarted():
            jvm.init_jvm(jvmpath)

        kkmaJavaPackage = jpype.JPackage('kr.lucypark.kkma')
        KkmaInterfaceJavaClass = kkmaJavaPackage.KkmaInterface
        self.jki = KkmaInterfaceJavaClass()  # Java instance
        self.tagset = utils.read_json('%s/data/tagset/kkma.json' %
                                      utils.installpath)
示例#8
0
 def __init__(self, dicpath='/usr/local/lib/mecab/dic/mecab-ko-dic'):
     try:
         self.tagger = Tagger('-d %s' % dicpath)
         self.tagset = utils.read_json('%s/data/tagset/mecab.json' %
                                       utils.installpath)
     except RuntimeError:
         raise Exception(
             'The MeCab dictionary does not exist at "%s". Is the dictionary correctly installed?\nYou can also try entering the dictionary path when initializing the Mecab class: "Mecab(\'/some/dic/path\')"'
             % dicpath)
     except NameError:
         raise Exception(
             'Install MeCab in order to use it: http://konlpy.org/en/latest/install/'
         )