[Chinese-commits] [fortune-zh] 01/01: util: update statistic script
Zhou Mo
cdluminate-guest at moszumanska.debian.org
Thu Dec 8 05:57:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
cdluminate-guest pushed a commit to branch master
in repository fortune-zh.
commit d97094e646e52f2927681ee35f9f0f73a2030ee8
Author: Zhou Mo <cdluminate at gmail.com>
Date: Thu Dec 8 05:57:20 2016 +0000
util: update statistic script
---
fortune-zh | 3 ++-
util/statistic.sh | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/fortune-zh b/fortune-zh
index 1b2892e..e18701d 100755
--- a/fortune-zh
+++ b/fortune-zh
@@ -5,7 +5,8 @@ set -e
FORTUNE="/usr/games/fortune"
[ -x $FORTUNE ] || ( echo "E: Please install package 'fortune-mod'."; false )
-# the old version (1.*) of fortune-zh contains only tang300 and song100
+# The old version (1.*) of fortune-zh contains only tang300 and song100.
+# Note, $\sum_{i} P_i = 1$, i.e. all the possibilities must sum to 1.
DICT="18% tang300 05% song100 77% chinese"
# check LANG
diff --git a/util/statistic.sh b/util/statistic.sh
index 9d468b1..c173820 100755
--- a/util/statistic.sh
+++ b/util/statistic.sh
@@ -13,4 +13,14 @@ for ITEM in ${DICT}; do
grep -c '^%' ${ITEM}
done
+total=$((
+ $(grep -c '^%' tang300) +
+ $(grep -c '^%' song100) +
+ $(grep -c '^%' chinese)
+))
+echo ":: " \
+ $(( 100 * $(grep -c '^%' tang300) / $total ))% \
+ $(( 100 * $(grep -c '^%' song100) / $total ))% \
+ $(( 100 * $(grep -c '^%' chinese) / $total ))%
+
printf "\x1B[m"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/chinese/fortune-zh.git
More information about the Chinese-commits
mailing list