Skip to main content

bareunai-apis contains the python classes generated from the bareun ai APIs, which includes tagger, and so on.

Project description

What is this?

bareun-apis is the generated python classes of GRPC API for bareun.ai.

The bareun.ai provides several service for deep learning NLP features. This api has all of main features, which provides tokenizing, POS tagging for Korean. It has also customized dictionary service.

How to install

pip3 install bareun-apis

How to use

  • You can create your own baikal language service client.
  • It is used for bareunlpy, the official bareun package for python.
from google.protobuf.json_format import MessageToDict

import bareun.language_service_pb2 as pb
import bareun.language_service_pb2_grpc as ls

MAX_MESSAGE_LENGTH = 100*1024*1024

class BareunLanguageServiceClient:

    def __init__(self, remote):
        channel = grpc.insecure_channel(
            remote,
            options=[
                ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
                ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH),
            ])

        self.stub = ls.LanguageServiceStub(channel)

    def analyze_syntax(self, document, auto_split=False):
        req = pb.AnalyzeSyntaxRequest()
        req.document.content = document
        req.document.language = "ko_KR"
        req.encoding_type = pb.EncodingType.UTF32
        req.auto_split_sentence = auto_split

        res = self.stub.AnalyzeSyntax(req)
        # print_syntax_as_json(res)
        return res

    def tokenize(self, document, auto_split=False):
        req = pb.TokenizeRequest()
        req.document.content = document
        req.document.language = "ko_KR"
        req.encoding_type = pb.EncodingType.UTF32
        req.auto_split_sentence = auto_split

        res = self.stub.Tokenize(req)
        # print_tokens_as_json(res)
        return res

def print_syntax_as_json(res: pb.AnalyzeSyntaxResponse, logf=sys.stdout):
    d = MessageToDict(res)
    import json
    json_str = json.dumps(d, ensure_ascii=False, indent=2)
    logf.write(json_str)
    logf.write('\n')

def print_tokens_as_json(res: pb.TokenizeResponse, logf=sys.stdout):
    d = MessageToDict(res)
    import json
    json_str = json.dumps(d, ensure_ascii=False, indent=2)
    logf.write(json_str)
    logf.write('\n')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bareun_apis-0.14.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bareun_apis-0.14.0-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file bareun_apis-0.14.0.tar.gz.

File metadata

  • Download URL: bareun_apis-0.14.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.9.6 Darwin/24.3.0

File hashes

Hashes for bareun_apis-0.14.0.tar.gz
Algorithm Hash digest
SHA256 d25f69acc4e766b588beebb7b9a21238f6c9025a05e7a5c4a4d26a513810d18d
MD5 fe1663db31f4ede153c78ec794fd4447
BLAKE2b-256 e91b974612538de96121f038b6f08fd4b820b740adfa780d2823493cd6c0389a

See more details on using hashes here.

File details

Details for the file bareun_apis-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: bareun_apis-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.9.6 Darwin/24.3.0

File hashes

Hashes for bareun_apis-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb8fdd26e64a990d751535ccef947a622e8c0b9c13dcdf8451693a573c5299b4
MD5 1abf6ca5f875f5fef76d785c91d95d48
BLAKE2b-256 bde1c9c47f2a50fface61b064f46176a10f46ccf2c1fb9ae4d511ca5a2438168

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page