Super simple one-click to beautify your article-make it more readable

When writing articles, I always pay attention to the habit of keeping a space between Chinese and English words, so that the text has good readability.

However, I often ignore the spaces between certain half-width characters (numbers and symbols) and Chinese, which leads to poor readability. When reading other people’s articles or modifying other people’s articles, I often worry that others do not have this optimization to read Sexual details.

Now, there is a great tool called pangu, which can automatically insert spaces between Chinese, Japanese, Korean and half-width characters (letters, numbers, and symbols).

With it, you can use pangu to beautify the article every time you finish writing an article. You can also use pangu to beautify other people's articles, such as:

import pangu

new_text = pangu.spacing_text('你可以在每次写完文章后利用pangu一键美化文章。也可以用pangu 美化别人的文章:')
print(new_text)
# new_text = '你可以在每次写完文章后利用 pangu 一键美化文章。也可以用 pangu 美化别人的文章:'

 

1. Preparation

 

Please choose any of the following methods to enter the command to install the dependencies :
1. Open Cmd (Start-Run-CMD) in the Windows environment.
2. Open Terminal in MacOS environment (command+space enter Terminal).
3. If you are using VSCode editor or Pycharm, you can directly use Terminal at the bottom of the interface.

pip install -U pangu

 

2. Use

 

 

After the installation is complete, you can try to write some simple sentences and beautify them:

import pangu

new_text = pangu.spacing_text('Windows环境下打开Cmd(开始—运行—CMD),苹果系统环境下请打开Terminal(command+空格输入Terminal)')
print(new_text)
# new_text = 'Windows 环境下打开 Cmd (开始 — 运行 —CMD),苹果系统环境下请打开 Terminal (command + 空格输入 Terminal)'

 

One-click execution

You can also execute the command to beautify the text directly through the -m parameter without writing the python file:

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

 

In addition, pangu also supports the pangu command to format text directly:

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

 

In addition, pangu also supports the pangu command to format text directly:

 

File support

With the -f parameter, pangu supports beautifying the content of the specified file and then outputting it to another file:

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

 

Pipeline support (UNIX)

In UNIX systems, such as Linux and MacOS, pangu also supports the use of pipe (|) commands to beautify text:

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

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

 

The two commands have the same effect. If you can't use the pangu command directly, you can try python -m pangu, they can achieve the same effect.

I still want to recommend the Python learning group I built by myself : 721195303. All students in the group are learning Python. If you want to learn or are learning Python, you are welcome to join. Everyone is a software development party and shares dry goods from time to time (only Python software development related), including a copy of the latest Python advanced materials and zero-based teaching compiled by myself in 2021. Welcome friends who are in advanced and interested in Python to join!

Guess you like

Origin blog.csdn.net/aaahtml/article/details/114299766