Skip to main content

[Unofficial] Python wrapper for Papago translation service

Project description

pypapago codecov

Unofficial python wrapper for papago translate service.

Install

pip install -U pypapago

Usage

Basic usage (English to Korean)

from pypapago import Translator

translator = Translator()

result = translator.translate('I am GROOT')
print(result) # 나는 그루트다

Set Source/Target Language

from pypapago import Translator

translator = Translator()

result = translator.translate(
    '카카오는 파파고를 좋아해',
    source='ko',
    target='en',
)
print(result) # Kakao likes papago.

Supported Language Codes

Code Desc
ko Korean
en English
ja Japanese
zh-CN Chinese
zh-TW Chinese traditional
es Spanish
fr French
vi Vietnamese
th Thai
id Indonesia

Bulk Translation

Parallel bulk translation with Multiprocessing.

from pypapago import Translator

translator = Translator()

result = translator.bulk_translate(['apple', 'banana'])
print(result) # ['사과', '바나나']

You can also set how many workers to run manually.

(The more workers make your code faster but requires more system resources.)

Default to CPU Cores (HyperThreading = x2)

  • ex) Run with 2cores
from pypapago import Translator

translator = Translator()

result = translator.bulk_translate(
    ['apple', 'banana'], 
    workers=2
)
print(result) # ['사과', '바나나']

Verbose output

If you need raw result from papago API, you can set verbose to True.

from pypapago import Translator

translator = Translator()

result = translator.translate('I am GROOT', verbose=True)
print(result) # RAW JSON Result
#{'delay': 400,
# 'delaySmt': 400,
# 'dict': {'items': [{'entry': '<b>I</b>',
# ...
# 'translatedText': '나는 그루트다'}
#}

Detail results may change.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pypapago-0.1.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pypapago-0.1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pypapago-0.1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.6

File hashes

Hashes for pypapago-0.1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ebf9fbfac27564206214f0d97c35e650b448511a7281952879d285c2e168c1
MD5 1143db02be2758ad6fc94dd5741752aa
BLAKE2b-256 bef149e134c97e03ad5b1161b8000624d85c3199c2d20f6f48a183a0767e6c2c

See more details on using hashes here.

Supported by

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