| 1 | #!/bin/sh |
| 2 | # Smoke-test the opencc-jieba segmentation plugin: the *_jieba.json |
| 3 | # configurations only work when the plugin and its dictionary load. |
| 4 | |
| 5 | set -eu |
| 6 | |
| 7 | check() { |
| 8 | config="$1" |
| 9 | input="$2" |
| 10 | expected="$3" |
| 11 | actual="$(printf '%s\n' "$input" | opencc -c "$config")" |
| 12 | if [ "$actual" != "$expected" ]; then |
| 13 | echo "FAIL: $config: '$input' -> '$actual', expected '$expected'" >&2 |
| 14 | exit 1 |
| 15 | fi |
| 16 | echo "PASS: $config: '$input' -> '$actual'" |
| 17 | } |
| 18 | |
| 19 | test -e /usr/lib/*/opencc/plugins/libopencc-jieba.so |
| 20 | |
| 21 | check s2twp_jieba.json '为什么你要学习编程?因为软件开发的信道很宽。' \ |
| 22 | '為什麼你要學習程式設計?因為軟體開發的通道很寬。' |
| 23 | check s2twp_jieba.json '鼠标里面有内存条吗?还有硬盘和数据库。' \ |
| 24 | '滑鼠裡面有記憶體條嗎?還有硬碟和資料庫。' |
| 25 | check s2t_jieba.json '着重号用在这里。' '着重號用在這裏。' |
| 26 | # Without segmentation, plain s2twp mangles 的士兵 into 計程車兵. |
| 27 | check s2twp_jieba.json '城堡里的士兵' '城堡裡的士兵' |