Skip to main content

Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).

Project description

pangu.py

https://img.shields.io/travis/vinta/pangu.py/master.svg?style=flat-square https://img.shields.io/codecov/c/github/vinta/pangu.py/master.svg?style=flat-square https://img.shields.io/pypi/v/pangu.svg?style=flat-square https://img.shields.io/pypi/pyversions/pangu.svg?style=flat-square https://img.shields.io/badge/made%20with-%e2%9d%a4-ff69b4.svg?style=flat-square

Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).

Installation

$ pip install -U pangu

Usage

In Python

import pangu

new_text = pangu.spacing_text('當你凝視著bug,bug也凝視著你')
# new_text = '當你凝視著 bug,bug 也凝視著你'

nwe_content = pangu.spacing_file('path/to/file.txt')
# nwe_content = '與 PM 戰鬥的人,應當小心自己不要成為 PM'

In CLI

$ pangu "請使用uname -m指令來檢查你的Linux作業系統是32位元或是[敏感词已被屏蔽]位元"
請使用 uname -m 指令來檢查你的 Linux 作業系統是 32 位元或是 [敏感词已被屏蔽] 位元

$ python -m pangu "為什麼小明有問題都不Google?因為他有Bing"
為什麼小明有問題都不 Google?因為他有 Bing

$ echo "未來的某一天,Gmail配備的AI可能會得出一個結論:想要消滅垃圾郵件最好的辦法就是消滅人類" >> path/to/file.txt
$ pangu -f path/to/file.txt >> pangu_file.txt
$ cat pangu_file.txt
未來的某一天,Gmail 配備的 AI 可能會得出一個結論:想要消滅垃圾郵件最好的辦法就是消滅人類

$ echo "心裡想的是Microservice,手裡做的是Distributed Monolith" | pangu
心裡想的是 Microservice,手裡做的是 Distributed Monolith

$ echo "你從什麼時候開始產生了我沒使用Monkey Patch的錯覺?" | python -m pangu
你從什麼時候開始產生了我沒使用 Monkey Patch 的錯覺?

History

4.0.6 (2019-02-09)

  • Implement Paranoid Text Spacing algorithm v4

  • Support Python 3.7

  • Drop Python 2.7 support

3.3.0.1 (2018-01-20)

  • Support Python 3.6

  • Add a method: pangu.spacing_file()

  • Add a command-line tool: pangu

3.0.0 (2016-01-24)

  • Support Python 3.5

  • Refactoring

  • Rename text_spacing() to spacing_text()

2.5.6.3 (2015-05-18)

  • Add an alias to spacing(): text_spacing()

  • Fix unicode issue in Python 2.x

2.5.6.2 (2015-05-17)

  • Fix setup.py

2.5.6 (2015-05-17)

  • Synchronize version number with pangu.js

  • Improve Paranoid Text Spacing algorithm

1.0.0 (2014-02-12)

  • Hello World

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

pangu-4.0.6.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pangu-4.0.6.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pangu-4.0.6.1.tar.gz.

File metadata

  • Download URL: pangu-4.0.6.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.6

File hashes

Hashes for pangu-4.0.6.1.tar.gz
Algorithm Hash digest
SHA256 f799d127709fe5ecff5d476945ac63d4be758b7bda02efb95715f1dc24472a2f
MD5 c1f566e1ce37b26e56b94d14e19270a9
BLAKE2b-256 78dd55a1e9d35ac17f49869359b2197fc09d17ee024ba545985b49b3e75a870a

See more details on using hashes here.

File details

Details for the file pangu-4.0.6.1-py3-none-any.whl.

File metadata

  • Download URL: pangu-4.0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.6

File hashes

Hashes for pangu-4.0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5023dced34b48da7ec61a2847efcbb8cf4fb748f8e589e1e7dfb008b7ad00206
MD5 d495b259c168d32f30a9d155c57f96d1
BLAKE2b-256 4877b52fac2ca4e4596f22dd6200b99ad515fb64b1ae7d3a12325b45b11e2a67

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