【发布时间】:2009-06-23 00:51:14
【问题描述】:
所以我有这个 shell 脚本:
echo "Enter text to be classified, hit return to run classification."
read text
if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "1.000000" ]
then
echo "Text is not likely to be stupid."
fi
if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "0.000000" ]
then
echo "Text is likely to be stupid."
fi
我想用python写它。我该怎么做?
(如您所见,它使用库http://stupidfilter.org/stupidfilter-0.2-1.tar.gz)
【问题讨论】:
-
我改了标题,所以搜索这个的人会发现 noskio 的优秀答案
-
作为 shell 脚本,您可以通过将反引号中的命令输出保存到变量中进行优化,然后比较两个 if 语句中的变量 - 而不是运行两次代码。