Skip to content

Commit

Permalink
2016/05/09 00:13:58
Browse files Browse the repository at this point in the history
  • Loading branch information
MasahikoIto committed May 8, 2016
1 parent 014e7d1 commit 119c98d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ o 2006/10/19 Ver. 0.3
- README��nkf�����Ѥ��Ƥ�����ɵ���
- README��fetchmail�˴ؤ��뵭���ɵ���
- ������ʸ�������᡼��Υ����������0�ˤʤäƤ����Τ�����
o 2006/10/24 Ver. 0.4
- sf_check.sh���select̿���ľ����
- sf_add.sh, sf_del.sh, sf_check.sh ������ñ��˴ؤ������
�����礬���ä��Τ�����
13 changes: 9 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

sf-0.3 -- spam filter for UNIX-like systems
sf-0.4 -- spam filter for UNIX-like systems

Copyright (C) 2006 Masahiko Ito

Expand Down Expand Up @@ -30,6 +30,10 @@ History
- README��nkf�����Ѥ��Ƥ�����ɵ���
- README��fetchmail�˴ؤ��뵭���ɵ���
- ������ʸ�������᡼��Υ����������0�ˤʤäƤ����Τ�����
�� 2006/10/24 Ver. 0.4 released
- sf_check.sh���select̿���ľ����
- sf_add.sh, sf_del.sh, sf_check.sh ������ñ��˴ؤ������
�����礬���ä��Τ�����

What's this ?
=============
Expand All @@ -43,17 +47,18 @@ What's this ?
Preinstall
==========

sf-0.3�ϡ��ʲ��Υ��եȥ����������Ѥ��Ƥ��ޤ��������˥��󥹥ȡ��뤬ɬ�פǤ���
sf-0.4�ϡ��ʲ��Υ��եȥ����������Ѥ��Ƥ��ޤ��������˥��󥹥ȡ��뤬ɬ�פǤ���

�� KAKASI - ����������(�����޻�)�Ѵ��ץ������ (http://kakasi.namazu.org/)
�� SQLite home page (http://www.sqlite.org/)
�� nkf Network Kanji Filter (http://sourceforge.jp/projects/nkf/)
�� GNU Textutils - Text utilities (http://www.gnu.org/software/textutils/textutils.html)

Install
=======

�� tar xvzf sf-0.3.tar.gz
�� cd sf-0.3
�� tar xvzf sf-0.4.tar.gz
�� cd sf-0.4
�� cp sf-*.sh /anywhere/bin/
�� mkdir ~/.sf

Expand Down
34 changes: 14 additions & 20 deletions sf_add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,22 @@ then
exit 0
fi
#
echo "begin;" >/tmp/sf_add.1.$$.tmp
#
for i in `cat ${file} |\
nkf -e -X |\
kakasi -w -ieuc -oeuc |\
sed -e "s/${zsp}/ /g;s/${tab}/ /g" |\
awk '{gsub(/ /,"\n");print}' |\
awk 'BEGIN{ \
maxlength = ENVIRON["maxlength"]; \
} \
{ \
if (length($0) <= maxlength){ \
print; \
} \
awk 'BEGIN{\
maxlength = ENVIRON["maxlength"];\
}\
{\
if (length($0) <= maxlength){\
print;\
}\
}' |\
tr -d '"'`
do
echo -n $i | tr -d '[:cntrl:]'
echo ""
done >/tmp/sf_add.1.$$.tmp
#
echo "begin;" >/tmp/sf_add.2.$$.tmp
#
for i in `cat /tmp/sf_add.1.$$.tmp |\
tr -d '"\000-\011\013-\037\177' |\
sort |\
uniq -c |\
sed -e "s/^ *//;s/${tab}/,/"`
Expand All @@ -104,15 +98,15 @@ do
sqlite3 ${SFDB_PATH}`
if [ "X${result}" = "X" ]
then
echo "insert into ${table} values (\"${term}\",${count});" >>/tmp/sf_add.2.$$.tmp
echo "insert into ${table} values (\"${term}\",${count});" >>/tmp/sf_add.1.$$.tmp
else
echo "update ${table} set count=count+${count} where term=\"${term}\"; " >>/tmp/sf_add.2.$$.tmp
echo "update ${table} set count=count+${count} where term=\"${term}\"; " >>/tmp/sf_add.1.$$.tmp
fi
fi
done
#
echo "end;" >>/tmp/sf_add.2.$$.tmp
cat /tmp/sf_add.2.$$.tmp |\
echo "end;" >>/tmp/sf_add.1.$$.tmp
cat /tmp/sf_add.1.$$.tmp |\
sqlite3 ${SFDB_PATH}
#
result=`echo "select sum(count) from ${table};" |\
Expand Down
36 changes: 15 additions & 21 deletions sf_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ then
exit 0
fi
#
echo ".separator \"\t\"" >/tmp/sf_check.1.$$.tmp
echo "begin;" >>/tmp/sf_check.1.$$.tmp
echo "select tablenm,count from t_total where tablenm=\"t_white\";" >>/tmp/sf_check.1.$$.tmp
echo "select tablenm,count from t_total where tablenm=\"t_black\";" >>/tmp/sf_check.1.$$.tmp
echo "end;" >>/tmp/sf_check.1.$$.tmp
#
echo ".separator \"\t\"" >/tmp/sf_check.2.$$.tmp
echo "begin;" >>/tmp/sf_check.2.$$.tmp
#
for i in `cat ${file} |\
nkf -e -X |\
kakasi -w -ieuc -oeuc |\
Expand All @@ -78,22 +87,7 @@ for i in `cat ${file} |\
print; \
} \
}' |\
tr -d '"'`
do
echo -n $i | tr -d '[:cntrl:]'
echo ""
done >/tmp/sf_check.1.$$.tmp
#
echo ".separator \"\t\"" >/tmp/sf_check.2.$$.tmp
echo "begin;" >>/tmp/sf_check.2.$$.tmp
echo "select tablenm,count from t_total where tablenm=\"t_white\";" >>/tmp/sf_check.2.$$.tmp
echo "select tablenm,count from t_total where tablenm=\"t_black\";" >>/tmp/sf_check.2.$$.tmp
echo "end;" >>/tmp/sf_check.2.$$.tmp
#
echo ".separator \"\t\"" >/tmp/sf_check.3.$$.tmp
echo "begin;" >>/tmp/sf_check.3.$$.tmp
#
for i in `cat /tmp/sf_check.1.$$.tmp |\
tr -d '"\000-\011\013-\037\177' |\
sort |\
uniq -c |\
sed -e "s/^ *//;s/${tab}/,/"`
Expand All @@ -105,18 +99,18 @@ do
then
: # do nothing
else
echo "select t_white.term,t_white.count*${count},t_black.count*${count} from t_white left join t_black on t_white.term = t_black.term where t_white.term=\"${term}\";" >>/tmp/sf_check.3.$$.tmp
echo "select t_black.term,t_white.count*${count},t_black.count*${count} from t_black left join t_white on t_white.term = t_black.term where t_black.term=\"${term}\";" >>/tmp/sf_check.3.$$.tmp
echo "select t_white.term,t_white.count*${count},t_black.count*${count} from t_white left join t_black on t_white.term = t_black.term where t_white.term=\"${term}\";" >>/tmp/sf_check.2.$$.tmp
echo "select t_black.term,t_white.count*${count},t_black.count*${count} from t_black left join t_white on t_white.term = t_black.term where t_black.term=\"${term}\" and t_white.term is NULL;" >>/tmp/sf_check.2.$$.tmp
fi
done
#
echo "end;" >>/tmp/sf_check.3.$$.tmp
echo "end;" >>/tmp/sf_check.2.$$.tmp
#
(
cat /tmp/sf_check.2.$$.tmp |\
cat /tmp/sf_check.1.$$.tmp |\
sqlite3 ${SFDB_PATH}
#
cat /tmp/sf_check.3.$$.tmp |\
cat /tmp/sf_check.2.$$.tmp |\
sqlite3 ${SFDB_PATH} |\
sort |\
uniq
Expand Down
20 changes: 7 additions & 13 deletions sf_del.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ then
exit 0
fi
#
echo "begin;" >/tmp/sf_del.1.$$.tmp
#
for i in `cat ${file} |\
nkf -e -X |\
kakasi -w -ieuc -oeuc |\
Expand All @@ -81,15 +83,7 @@ for i in `cat ${file} |\
print; \
} \
}' |\
tr -d '"'`
do
echo -n $i | tr -d '[:cntrl:]'
echo ""
done >/tmp/sf_del.1.$$.tmp
#
echo "begin;" >/tmp/sf_del.2.$$.tmp
#
for i in `cat /tmp/sf_del.1.$$.tmp |\
tr -d '"\000-\011\013-\037\177' |\
sort |\
uniq -c |\
sed -e "s/^ *//;s/${tab}/,/"`
Expand All @@ -108,16 +102,16 @@ do
else
if [ ${result} -le ${count} ]
then
echo "delete from ${table} where term=\"${term}\"; " >>/tmp/sf_del.2.$$.tmp
echo "delete from ${table} where term=\"${term}\"; " >>/tmp/sf_del.1.$$.tmp
else
echo "update ${table} set count=count-${count} where term=\"${term}\"; " >>/tmp/sf_del.2.$$.tmp
echo "update ${table} set count=count-${count} where term=\"${term}\"; " >>/tmp/sf_del.1.$$.tmp
fi
fi
fi
done
#
echo "end;" >>/tmp/sf_del.2.$$.tmp
cat /tmp/sf_del.2.$$.tmp |\
echo "end;" >>/tmp/sf_del.1.$$.tmp
cat /tmp/sf_del.1.$$.tmp |\
sqlite3 ${SFDB_PATH}
#
result=`echo "select sum(count) from ${table};" |\
Expand Down

0 comments on commit 119c98d

Please sign in to comment.