Skip to main content

Zemberek gRPC

Latest version 0.16.0

Zemberek-NLP provides some of its functions via a remote procedure call framework called gRPC. gRPC is a high performance, open-source universal RPC framework. Once Zemberek-NLP gRPC server is started, other applications can access remote services natively via automatically generated client libraries.

https://github.com/ahmetaa/zemberek-nlp

Start gRPC server with docker

You can use it from directly in your computer or run with in docker container.

https://hub.docker.com/r/ryts/zemberek-grpc

Run with docker

docker run -d --rm -p 6789:6789 --name zemberek-grpc ryts/zemberek-grpc

Check logs

docker logs -f zemberek-grpc

Install library and example

pip install zemberek-grpc

Python Client Example

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

import grpc

import zemberek_grpc.language_id_pb2 as z_langid
import zemberek_grpc.language_id_pb2_grpc as z_langid_g
import zemberek_grpc.normalization_pb2 as z_normalization
import zemberek_grpc.normalization_pb2_grpc as z_normalization_g
import zemberek_grpc.preprocess_pb2 as z_preprocess
import zemberek_grpc.preprocess_pb2_grpc as z_preprocess_g
import zemberek_grpc.morphology_pb2 as z_morphology
import zemberek_grpc.morphology_pb2_grpc as z_morphology_g

channel = grpc.insecure_channel('localhost:6789')

langid_stub = z_langid_g.LanguageIdServiceStub(channel)
normalization_stub = z_normalization_g.NormalizationServiceStub(channel)
preprocess_stub = z_preprocess_g.PreprocessingServiceStub(channel)
morphology_stub = z_morphology_g.MorphologyServiceStub(channel)

def find_lang_id(i):
    response = langid_stub.Detect(z_langid.LanguageIdRequest(input=i))
    return response.langId

def tokenize(i):
    response = preprocess_stub.Tokenize(z_preprocess.TokenizationRequest(input=i))
    return response.tokens

def normalize(i):
    response = normalization_stub.Normalize(z_normalization.NormalizationRequest(input=i))
    return response

def analyze(i):
    response = morphology_stub.AnalyzeSentence(z_morphology.SentenceAnalysisRequest(input=i))
    return response;

def fix_decode(text):
    """Pass decode."""
    if sys.version_info < (3, 0):
        return text.decode('utf-8')
    else:
        return text

def run():
    lang_detect_input = 'merhaba dünya'
    lang_id = find_lang_id(lang_detect_input)
    print("Language of [" + fix_decode(lang_detect_input) + "] is: " + lang_id)

    print("")
    tokenization_input = 'Merhaba dünya!'
    print('Tokens for input : ' + fix_decode(tokenization_input))
    tokens = tokenize(tokenization_input)
    for t in tokens:
        print(t.token + ':' + t.type)

    print("")
    normalization_input = 'Mrhaba dnya'
    print('Normalization result for input : ' + fix_decode(normalization_input))
    n_response = normalize(normalization_input)
    if n_response.normalized_input:
        print(n_response.normalized_input)
    else:
        print('Problem normalizing input : ' + n_response.error)

    print("")
    analysis_input = 'Kavanozun kapağını açamadım.'
    print('Analysis result for input : ' + fix_decode(analysis_input))
    analysis_result = analyze(analysis_input)
    for a in analysis_result.results:
        best = a.best
        lemmas = ""
        for l in best.lemmas:
          lemmas = lemmas + " " + l
        print("Word = " + a.token + ", Lemmas = " + lemmas + ", POS = [" + best.pos + "], Full Analysis = {" + best.analysis + "}")


if __name__ == '__main__':
    run()

Metadata

Release files for zemberek-grpc 0.16.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zemberek-grpc 0.16.1
File Size Uploaded Provenance Actions
zemberek_grpc-0.16.1.tar.gz 9.2 kB Without provenance Details for zemberek_grpc-0.16.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zemberek-grpc 0.16.1
File Interpreter ABI Platform Actions
zemberek_grpc-0.16.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for zemberek_grpc-0.16.1-py2.py3-none-any.whl

Total release size: 22.3 kB

Release files / zemberek_grpc-0.16.1.tar.gz

Download URL zemberek_grpc-0.16.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d0a46b1999009cc94465ee360497586d152984cdd25005428d64eb4448b669e3
BLAKE2b-256 checksum
How to use checksums
d2f198cde4f1beee119e811a93c795576d9244a303ffb5922ca7667aa688f1da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.8

Release files / zemberek_grpc-0.16.1-py2.py3-none-any.whl

Download URL zemberek_grpc-0.16.1-py2.py3-none-any.whl
Size 13.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6dee76201a45fecf8d94ef052eb53dae578ca92032e4a461bb8066dd78ff071f
BLAKE2b-256 checksum
How to use checksums
125bd0deebc56c4586e26c50a0b63697caa713045ed843b39b608fc46a182889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.8

Security for zemberek-grpc 0.16.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.16.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page