[New R Package] sinx: R fortunes in Chinese

in #utopian-io3 years ago (edited)

Repo

https://github.com/pzhaonet/sinx

What is the project about?

One of the funniest things I found when I (as a Windows user) leant Ubuntu was that there is a command fortune, which prints a random/pseudorandom message from a database of quotations. It is said that this old feature has been available since 1970s. It was a pity that this feature was unavailable in boring Windows OS, until the R community developed in 2012 a package called 'fortunes,' which displays funny messages taken from the talks or communications in the R community. It supports external database as well. Unfortunately, it does not support Chinese texts, probably because (1) the 'fortunes' package cannot read multibyte characters such as Chinese, and (2) no one contributes Chinese database of fortunes.

It is a great loss, as fortunes actually come from Chinese restaurants.

R has been developing very rapidly in the Chinese community in recent years. There are online Chinese forums such as the Capital of Statistics, annually organized R conference in China, and numerous books on R. Many interesting 'fortunes' are hidden there. What if bring them into a 'fortunes'-like package? Or bring some more fun into it?

It is a pity that the 'fortunes' package is read-only. Therefore, I develop a brand new package, called 'sinx'. It displays fortunes in any language, only if a database is available.

The name originated from the name cosx, which is the domain of the Capital of Statistics. sin(x) is the derivative of -cos(x), or I would like to explain 'sinx' as 'Sino Xmen Said'.

I designed a logo for 'sinx', which can be printed on a T-shirt.

What are the current features?

Briefly speaking, the current features of 'sinx' are as follows.

  • Like the 'fortunes' package, the main feature of 'sinx' prints randomly a Chinese message taken from the R community by default. See ?sinx().
  • External data bases can be imported into sinx. Users can customize their own fortunes in their favorite languages. See ?cscx().
  • One advantage of a 'sinx' database is that it can be organized either in markdown format besides the table format. Users can easily contribute good fortunes to 'sinx' via github. See the source database.
  • Another funny thing is 'cowsay'. The 'sinx' package can print messages in a cowsay way, which means that a colored pet can be displayed behind the sinx message. See ?tanx().
  • A useful feature is that users can easily convert a database into an E-book (demo) or slides (demo). See ?secx().
  • Users can easily choose whether to display a sinx message at the startup of R. See ?ctanx()
  • I have prepared six databases including famous poems in ancient China and famous sayings worldwide besides the default one.

Here is an example, which prints randomly a poem by the top poet Li Bai, in the cowsay mode (spoken by a frog):

libs <- read.sinxs(lib = c("tangshi", "songshi", "chinese", "yangsheng", "english","jinyong"))
tanx(sinxs.data = libs)
#> 
#> 
#>  ----- 
#> 风吹柳花满店香,吴姬压酒唤客尝。
#> 金陵子弟来相送,欲行不行各尽觞。
#> 请君试问东流水,别意与之谁短长。
#> 
#> --- 李白 (金陵酒肆留别) 
#>  ------ 
#>     \   
#>      \
#>         (.)_(.)
#>      _ (   _   ) _
#>     / \/`-----'\/ \
#>   __\ ( (     ) ) /__
#>   )   /\ \._./ /\   (
#>    )_/ /|\   /|\ \_(  [nosig]

More details can be found on the online documentation.

Technology Stack

'sinx' is developed in R language.

Roadmap

In the future, more features will be brought into 'sinx' as follows.

  1. Create more funny database.
  2. Develop an RStudio addin for users to easily contribute new fortunes.
  3. Create a new feature for quizzes. Let users fill blanks in the message.

How to contribute?

Anyone can get in touch with me by leaving me a reply on steem @dapeng or on https://github.com/pzhaonet/sinx.

Sort:  

Thank you @dapeng for your contribution. It is nice to see you are back to steemit, at least for @utopian-io.

The fortune is actually a well-known Linux tool, as you said, and I've developed an online fortune tool that also provides an API. It is interesting to know that there are actually fortune databases which you can choose, e.g. print random Chinese poems.

At the first glance, I thought this would be related to mathematics.. especially you have cosx, tanx... The naming may be confusing for most people.

You also have some commented-out code, which in general is better to be removed to keep your code clean.

You may also want to put the English description in your README.md

Your contribution has been evaluated according to Utopian policies and 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.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your comments! An English readme will come soon. The fortune API is so interesting that I cannot help importing it into sinx next time!

Thank you for your review, @justyy! Keep up the good work!

这个非撸审查不可😂

Posted using Partiko Android

非撸审查是什么意思?我的中文水平好像退步了。

先在大佬来点赞前,先点个赞来赚大佬的审查赏金😅

Posted using Partiko Android

哦,原来这就叫撸啊~

呵呵。就是撸管的撸😂

Posted using Partiko Android

用词不当。这明明叫"蹭"。

不管,只要与点赞和收益有关的一律就是撸! @julian2013 快来撸鹏鹏🤗

Posted using Partiko Android

哈哈,我今天停了auto upvote,恢复一下,前面看到大鸟发帖,小小的蹭了一下😄

Posted using Partiko iOS

文韬武略的感觉,赞一个

Posted using Partiko Android

大伟哥好!好久不见!

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

Hey, @dapeng!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.68
TRX 0.10
JST 0.075
BTC 57155.56
ETH 4437.90
BNB 617.95
SBD 7.01