Beispiel #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_tc/konlpy_tc/issues"
            )

        if userdic:
            self.jki.setUserDic(userdic)
Beispiel #2
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)
Beispiel #3
0
    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)
Beispiel #4
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)
Beispiel #5
0
 def __init__(self, dicpath=r'C:\mecab\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_tc.org/en/latest/install/'
         )