When writing articles at ordinary times , I always pay attention to the habit of leaving a space between Chinese and English words , This makes the text readable .
But I often ignore some half angle characters ( Numbers and symbols ) The space between and Chinese , Resulting in poor readability , When reading other people's articles or revising other people's articles , I often worry that others don't have the details of this optimization readability .
Now? , There's a great tool , be called pangu , It can be in Chinese 、 Japanese 、 Korean and half width characters ( Letter , Numbers and symbols ) Automatically insert space between .
With it , You can use... Every time you finish writing an article pangu One click beautify the article . It can also be used. pangu Beautify other people's articles , such as :
import pangu new_text = pangu.spacing_text(' You can use... Every time you finish writing an article pangu One click beautify the article . It can also be used. pangu Beautify other people's articles :') print(new_text) # new_text = ' You can use... Every time you finish writing an article pangu One click beautify the article . It can also be used. pangu Beautify other people's articles :'
1. Get ready
Before the start , You have to make sure that Python and pip Has been successfully installed on the computer , without , Installation .
If you use Python The goal is data analysis , It can be installed directly Anaconda:echat_redirect), It has... Built in Python and pip.
Besides , Recommended VSCode Editor , It has many advantages
Please choose one of the following ways to enter the command to install the dependency :
pip install -U pangu
2. Use
After installation , You can try to write some simple sentences and beautify them :
import pangu new_text = pangu.spacing_text('Windows Open in the environment Cmd( Start — function —CMD), Apple system environment, please open Terminal(command+ Space input Terminal)') print(new_text) # new_text = 'Windows Open in the environment Cmd ( Start — function —CMD), Apple system environment, please open Terminal (command + Space input Terminal)'
One click execution
You can also not write python file , Directly through -m Parameter executes the command to beautify the text :
python -m pangu " Why doesn't Xiao Ming have a problem Google? Because he has Bing" # Why doesn't Xiao Ming have a problem Google? Because he has Bing
Besides ,pangu Also support pangu Command to format text directly :
pangu " Please use uname -m Instructions to check your Linux The operating system is 32 Bits or [ Sensitive words have been blocked ] Bit " # Please use uname -m Instructions to check your Linux The operating system is 32 Bits or [ Sensitive words have been blocked ] Bit
Besides ,pangu Also support pangu Command to format text directly :
File support
adopt -f Parameters ,pangu Support the beautification of the specified file content , Then output to another file :
echo " One day in the future ,Gmail Equipped AI May come to a conclusion : The best way to eliminate spam is to eliminate human beings " >> path/to/file.txt pangu -f path/to/file.txt >> pangu_file.txt cat pangu_file.txt # One day in the future ,Gmail Equipped AI May come to a conclusion : The best way to eliminate spam is to eliminate human beings
Pipeline support (UNIX)
stay UNIX In the system , such as Linux and MacOS,pangu It also supports the use of pipes ( | ) Command beautify text :
echo " I was thinking Microservice, What you do is Distributed Monolith" | pangu # I was thinking Microservice, What you do is Distributed Monolith echo " When did you start to have that I didn't use Monkey Patch The illusion of ?" | python -m pangu # When did you start to have that I didn't use Monkey Patch The illusion of ?
Two commands have the same effect , If you can't use it directly pangu command , You can try python -m pangu, They can achieve the same effect .