[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes by dapeng

View this thread on steempeak.com
· @dapeng · (edited)
$12.33
[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes
#### Repo

https://github.com/pzhaonet/pinyin

### Brief Intro and curriculum

The 'pinyin' package was developed in R language. It can convert Chinese characters in to Latin letters, officially called pinyin, i.e. the romanization system for Standard Chinese in mainland China, Malaysia, Singapore, and Taiwan. An brief introduction can be referred to the post [pinyin: an R package that converts Chinese characters into Latin letters](https://steemit.com/utopian-io/@dapeng/pinyin-an-r-package-that-converts-chineses-characters-into-latin-letters-r).

### New Features

#### What features did I add?

- Four times faster for converting.
- At the beginning of the year 2018 I received an issue report by [psychelzh](https://github.com/pzhaonet/pinyin/issues/3#issue-295041288) about a polyphone error. Now a new pinyin library has been added, which more or less solved the polyphone problem.
- Convert Chinese characters into Sijiao codes (literally [four corner code](https://en.wikipedia.org/wiki/Four-Corner_Method)).
- and Wubi codes (literally [five-stroke](https://en.wikipedia.org/wiki/Wubi_method)).
- Some minor bugs were fixed.

[![](https://cdn.steemitimages.com/DQmRtco1JZ19PSvq8RKGNN8CYxNKzzHqNdtUqqFjam1b2Zz/pinyin-test.jpg)](https://cdn.steemitimages.com/DQmRtco1JZ19PSvq8RKGNN8CYxNKzzHqNdtUqqFjam1b2Zz/pinyin-test.jpg)
Figure 1:  Test the new features in RStudio IDE

#### How did I implement them?

- Following [Qu Cheng](https://github.com/canalcheng)'s suggestions in personal communications, I converted the pinyin library into an environment to accelerate the converting procedure by the `pylib()` function.
- A new pinyin library '/inst/lib/zh2.txt' was added and a parameter `dic = c('zh', 'zh2')` in the `pylib()` function  allows the users to choose a preferable library for  polyphone.
- New functions `fclib()` and `four_corner()` imports a four-corner library and converts Chinese characters into four-corner codes, according to Qu Cheng's suggestions.
- A new function `wubi()` imports a five-stroke library and converts Chinese characters into five-stroke codes, again according to Qu Cheng's suggestions.
- The downstream functions `bookdown2py()`, `file.rename2py()`, `file2py()` were updated to support the updates mentioned above.

Each part of the functions are well documented. Other files were updated automatically by compilation. 

Link to relevant lines in the code on GitHub can be found mainly in my latest commit (click to see the details):

- [Faster. Users can preload the library. A simple library was added. Four-corner codes are supported.](https://github.com/pzhaonet/pinyin/commit/cbdd753a86744debdfccae1ce63c7870d4e808e1)
- [Convert Chnese characters into Wubi codes](https://github.com/pzhaonet/pinyin/commit/59aaf6aea73c6d73aaec9c6dcc38d402f98e06de)


#### GitHub Account
https://github.com/pzhaonet
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 49 others
properties (23)
post_id64,118,963
authordapeng
permlinkpinyin-wubi
categoryutopian-io
json_metadata{"links":["https:\/\/github.com\/pzhaonet\/pinyin","https:\/\/steemit.com\/utopian-io\/@dapeng\/pinyin-an-r-package-that-converts-chineses-characters-into-latin-letters-r","https:\/\/github.com\/pzhaonet\/pinyin\/issues\/3#issue-295041288","https:\/\/en.wikipedia.org\/wiki\/Four-Corner_Method","https:\/\/en.wikipedia.org\/wiki\/Wubi_method","https:\/\/cdn.steemitimages.com\/DQmRtco1JZ19PSvq8RKGNN8CYxNKzzHqNdtUqqFjam1b2Zz\/pinyin-test.jpg","https:\/\/github.com\/canalcheng","https:\/\/github.com\/pzhaonet\/pinyin\/commit\/cbdd753a86744debdfccae1ce63c7870d4e808e1","https:\/\/github.com\/pzhaonet\/pinyin\/commit\/59aaf6aea73c6d73aaec9c6dcc38d402f98e06de","https:\/\/github.com\/pzhaonet"],"format":"markdown","image":["https:\/\/cdn.steemitimages.com\/DQmRtco1JZ19PSvq8RKGNN8CYxNKzzHqNdtUqqFjam1b2Zz\/pinyin-test.jpg"],"app":"steemit\/0.1","tags":["utopian-io","development","r","promo-steem","cn"]}
created2018-10-12 13:31:42
last_update2018-10-12 13:33:21
depth0
children7
net_rshares9,085,004,642,345
last_payout2018-10-19 13:31:42
cashout_time1969-12-31 23:59:59
total_payout_value9.381 SBD
curator_payout_value2.949 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,853
author_reputation64,235,894,740,263
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (113)
@justyy ·
$9.70
Thank you for your contribution. Converting Chinese Characters to Five-Stroke is very useful and I would suggest you adding the Five Stroke 86 as well - because many others like myself use Five Stroke 86 instead of 98. Anyway, it is a nice piece of work!

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2222222).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
👍  , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id64,138,288
authorjustyy
permlinkre-dapeng-pinyin-wubi-20181012t201139924z
categoryutopian-io
json_metadata{"links":["https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/3\/2222222","https:\/\/support.utopian.io\/","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"],"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-10-12 20:11:39
last_update2018-10-12 20:11:39
depth1
children2
net_rshares7,164,991,935,707
last_payout2018-10-19 20:11:39
cashout_time1969-12-31 23:59:59
total_payout_value7.312 SBD
curator_payout_value2.383 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length745
author_reputation2,073,321,573,485,954
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (20)
@dapeng ·
Thank you for your fast review and kind suggestion! 

The new features of converting to Four-corner codes and Fire-stroke were required by users, although I myself never use them. Supporting Five-stroke-86 would surely enhance the usage of the pinyin package. In the future version, pinyin will be more flexible and allow users to customize their own dictionaries. I am afraid the pinyin package has to be renamed as 'zidian'.

Thank you.
properties (22)
post_id64,139,330
authordapeng
permlinkre-justyy-re-dapeng-pinyin-wubi-20181012t204033490z
categoryutopian-io
json_metadata{"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-10-12 20:40:39
last_update2018-10-12 20:40:39
depth2
children0
net_rshares0
last_payout2018-10-19 20:40:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length438
author_reputation64,235,894,740,263
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
Thank you for your review, @justyy!

So far this week you've reviewed 1 contributions. Keep up the good work!
properties (22)
post_id64,459,168
authorutopian-io
permlinkre-re-dapeng-pinyin-wubi-20181012t201139924z-20181018t061613z
categoryutopian-io
json_metadata{"app":"beem\/0.20.1"}
created2018-10-18 06:16:15
last_update2018-10-18 06:16:15
depth2
children0
net_rshares0
last_payout2018-10-25 06:16:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length109
author_reputation152,913,012,544,965
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-ua ·
#### Hi @dapeng!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
post_id64,138,585
authorsteem-ua
permlinkre-pinyin-wubi-20181012t201941z
categoryutopian-io
json_metadata{"app":"beem\/0.20.7"}
created2018-10-12 20:19:42
last_update2018-10-12 20:19:42
depth1
children0
net_rshares0
last_payout2018-10-19 20:19:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length285
author_reputation23,203,609,903,979
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@xiaoshancun ·
好久不见大鹏老师😄!问个好啦!
properties (22)
post_id64,152,763
authorxiaoshancun
permlinkre-dapeng-pinyin-wubi-20181013t030801737z
categoryutopian-io
json_metadata{"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-10-13 03:08:06
last_update2018-10-13 03:08:06
depth1
children2
net_rshares0
last_payout2018-10-20 03:08:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length15
author_reputation155,278,422,778,942
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@dapeng ·
三哥好!经常读三哥的文字,只是没留言。最近太懒,不好意思:)
properties (22)
post_id64,195,515
authordapeng
permlinkre-xiaoshancun-re-dapeng-pinyin-wubi-20181013t203742670z
categoryutopian-io
json_metadata{"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-10-13 20:37:48
last_update2018-10-13 20:37:48
depth2
children1
net_rshares0
last_payout2018-10-20 20:37:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length30
author_reputation64,235,894,740,263
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@xiaoshancun ·
哈哈!大鹏老师太客气啦😄!
properties (22)
post_id64,204,830
authorxiaoshancun
permlinkre-dapeng-re-xiaoshancun-re-dapeng-pinyin-wubi-20181014t010854767z
categoryutopian-io
json_metadata{"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-10-14 01:09:00
last_update2018-10-14 01:09:00
depth3
children0
net_rshares0
last_payout2018-10-21 01:09:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length13
author_reputation155,278,422,778,942
root_title"[R: New Features on pinyin] Convert Chinese Characters into Sijiao and Wubi codes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000