Metadata-Version: 2.1
Name: bareun-apis
Version: 0.11.0
Summary: bareunai-apis contains the python classes generated from the bareun ai APIs, which includes tagger, and so on.
Home-page: https://bareun.ai/
License: BSD-3-Clause
Keywords: bareun,grpc,protobuf,POS tagger,Korean
Author: Gihyun YUN
Author-email: gih2yun@baikal.ai
Requires-Python: >=3.6,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: Korean
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: googleapis-common-protos (>=1.56.0,<2.0.0)
Requires-Dist: grpcio (>=1.46.0,<2.0.0)
Requires-Dist: protobuf (>=3.19.4,<4.0.0)
Project-URL: Repository, https://github.com/bareun-nlp/bareun-apis
Description-Content-Type: text/markdown

# 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

```shell
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.


```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')

```

