Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Beomi/pypapago

🐧[Archived][Unofficial] Python wrapper for Papago translation service
https://github.com/Beomi/pypapago

papago pypi-package translate

Last synced: 3 months ago
JSON representation

🐧[Archived][Unofficial] Python wrapper for Papago translation service

Awesome Lists containing this project

README

        

# THIS PROJECT is ARCHIVED!

This project is no longer maintained by the author.
No additional support is provided.

If you're still interested in the Papago's translation service, plz follow the direction below:

https://developers.naver.com/docs/papago/papago-nmt-overview.md

---

# pypapago [![codecov](https://codecov.io/gh/Beomi/pypapago/branch/master/graph/badge.svg)](https://codecov.io/gh/Beomi/pypapago)

Unofficial python wrapper for [papago translate service](https://papago.naver.com).

## Install

```bash
pip install -U pypapago
```

## Usage

### Basic usage (English to Korean)

```python
from pypapago import Translator

translator = Translator()

result = translator.translate('I am GROOT')
print(result) # λ‚˜λŠ” κ·Έλ£¨νŠΈλ‹€
```

### Set Source/Target Language

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

```python
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

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

```python
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': 'I',
# ...
# 'translatedText': 'λ‚˜λŠ” κ·Έλ£¨νŠΈλ‹€'}
#}
```

Detail results may change.