コード例 #1
0
    def mecab_instance(self, request):
        if not request.config.getoption("grpc-real"):
            pytest.importorskip("konlpy")
            pytest.importorskip("MeCab", reason="Mecab is optional.")

        from konlpy_grpc.monkeypatch import patch

        without_jpype_patching = True
        if request.config.getoption("grpc-real"):
            without_jpype_patching = False
        patch(without_jpype=without_jpype_patching)

        from konlpy.tag._mecab import Mecab

        grpc_channel = request.getfixturevalue("grpc_channel")
        return Mecab(grpc_channel=grpc_channel)
コード例 #2
0
    def komoran_instance(self, request):
        if not request.config.getoption("grpc-real"):
            pytest.importorskip("konlpy")
            pytest.importorskip("jpype")

        from konlpy_grpc.monkeypatch import patch

        without_jpype_patching = True
        if request.config.getoption("grpc-real"):
            without_jpype_patching = False
        patch(without_jpype=without_jpype_patching)

        from konlpy.tag._komoran import Komoran

        grpc_channel = request.getfixturevalue("grpc_channel")
        return Komoran(grpc_channel=grpc_channel)
コード例 #3
0
    def hannanum_instance(self, request):
        if not request.config.getoption("grpc-real"):
            pytest.importorskip("konlpy")
            pytest.importorskip("jpype")

        from konlpy_grpc.monkeypatch import patch, revert

        without_jpype_patching = True
        if request.config.getoption("grpc-real"):
            without_jpype_patching = False
        patch(without_jpype=without_jpype_patching)

        from konlpy.tag._hannanum import Hannanum

        grpc_channel = request.getfixturevalue("grpc_channel")
        yield Hannanum(grpc_channel=grpc_channel)
        revert()